将AllReduce拆分为树状流水线,利用率达89% 三、性能核爆:数据背后的真相 在8×A100集群上的实测结果令人震撼: 指标 Llama2-7B Llama2-70B 单步耗时 58ms (Unsloth 四、实战指南:从入门到精通 4.1 极速微调实战 from unsloth import FastLanguageModel import torch.optim as optim # 加载预训练模型 (自动应用优化) model, tokenizer = FastLanguageModel.from_pretrained( "unsloth/llama2-7b-bnb-4bit", Unsloth的实测数据证明:通过系统级创新,我们能在不增加硬件的前提下将训练效率提升3.6倍。 一位使用Unsloth的AI初创公司CTO感慨:“原本需要200张A100的微调任务,现在56张卡就能完成,这改变了我们的产品路线图”。
关键成果速览 Unsloth 团队在对 DeepSeek-V3.1 进行动态量化后,得出了以下令人振奋的结果: 1-bit Unsloth 动态 GGUF: 体积: 将 DeepSeek-V3.1 从 普遍优势: Unsloth 的动态 GGUF 在所有测试中,其表现始终优于其他非 Unsloth 的 imatrix GGUF 模型。 值得注意的是,其他非 Unsloth 的 1-bit 和 2-bit 量化版本要么无法加载,要么产生乱码,这凸显了 Unsloth 动态量化方法的稳定性和有效性。 Aider 基准测试图表 思考模式 (Thinking Mode) 非思考模式 (Non-Thinking Mode) Unsloth 动态量化技术揭秘 Unsloth 动态量化的核心思想是 “选择性量化 /unsloth-dynamic-2.0-ggufs/unsloth-dynamic-ggufs-on-aider-polyglot
Unsloth 是什么? 最后: pip install unsloth 还有 Docker 方案,完全零配置: docker pull unsloth/unsloth 更新也是一行: pip install --upgrade --force-reinstall --no-cache-dir unsloth unsloth_zoo 用 VS Code + Colab 免费微调 这是我觉得 Unsloth 最「降维打击」的功能 /unsloth.ai/docs 开源了! 官方 notebook 列表: https://unsloth.ai/docs/get-started/unsloth-notebooks
本教程整理自视频《Get Started with Unsloth Studio: Generate Data & Fine-Tune LLMs Locally on any NVIDIA GPU》: 资源: Unsloth and Unsloth Studio: https://unsloth.ai/docs/new/studio/ NVIDIA NeMo Data Designer: https ://github.com/NVIDIA-NeMo/DataDesigner Unsloth是一款主打高效低显存的开源AI模型训练与推理框架,专为消费级硬件优化,能大幅降低大语言模型微调、部署的硬件门槛 本教程基于Unsloth Studio界面,搭配NVIDIA NeMo Data Designer合成数据引擎,手把手带你完成小语言模型能力增强全流程:构建合成数据pipeline、借助Nemotron 软件安装 安装最新版 Unsloth(含 Unsloth Studio)执行官方推荐安装命令,确保 Studio 可视化界面完整部署 本地部署 Nemotron-3 Nano通过 Llama CPP 执行部署命令
、视觉、强化学习三条路线全打通 Qwen3.5 微调概览 先说结论:Qwen3.5 + Unsloth 是目前性价比最高的开源模型微调方案。 Studio(无代码方案) 如果你不想写一行代码,Unsloth 新推出的开源 Web UI —— Unsloth Studio 是最佳选择。 ://unsloth.ai/install.ps1 | iex 安装很快,大约 1-2 分钟。 参考链接: Unsloth 微调文档:https://unsloth.ai/docs/zh/mo-xing/qwen3.5/fine-tune GGUF 基准测试:https://unsloth.ai/ GitHub:https://github.com/unslothai/unsloth #Qwen3.5 #Unsloth #微调 #GGUF #大模型 制作不易,如果这篇文章觉得对你有用,可否点个关注
害得是 Unsloth! ❝⚠️ 一个大坑:不要用 CUDA 13.2,会输出乱码,NVIDIA 在修。 建议 12.9 或 13.0 方式一:Unsloth Studio(最省事) Unsloth 自己出了一个 Web UI,叫 Unsloth Studio,可以本地跑 GGUF、对比模型、聊天、传图传音频 Unsloth Studio 界面 MacOS / Linux / WSL 一键安装: curl -fsSL https://unsloth.ai/main/install.sh | sh source unsloth_studio/bin/activate unsloth studio -H 0.0.0.0 -p 8888 Windows PowerShell: irm https://unsloth.ai \unsloth_studio\Scripts\unsloth.exe studio -H 0.0.0.0 -p 8888 然后浏览器打开 http://localhost:8888,搜 Nemotron
本文将从微调痛点出发,介绍 Unsloth 的核心加速能力、Studio 的新特性、以及对视觉模型(VLM)微调的支持。 项目信息项目名称:Unsloth / Unsloth Studio团队:Unsloth AIGitHub:https://github.com/unslothai/unsloth许可证:Apache 2.0 :irm https://unsloth.ai/install.ps1 | iex& . \unsloth_studio\Scripts\unsloth.exe studio -H 0.0.0.0 -p 8888也提供 Docker 镜像(unsloth/unsloth),适合服务器部署。 Unsloth 提供 UnslothVisionDataCollator 处理图像裁剪、多图对话和填充对齐等细节。
通过 Unsloth Studio 仅用 4GB RAM 本地运行, 4B 模型通过在思考过程中直接执行工具调用+网络搜索实现 简介 一句话说,Unsloth Studio 是 一个本地 Web UI, 把“本地模型桌面化”,风格上很像把本地模型管理、聊天、参数调节整合到了一起: Unsloth Studio 运行模型界面 2. unsloth --torch-backend=auto 最后再跑 unsloth studio setup Windows Powershell 安装完成后,启动命令如下: source unsloth_studio 我这次在本机实测时,一键安装脚本跑了 35 分钟,进程依然停留在 uv pip install unsloth --torch-backend=auto 这一步。 总结 Unsloth Studio 最吸引我的地方,在于它试图把本地 AI 这条链路真正串起来,单点功能反而不是我最看重的部分。
答案就在于我们引入了 Unsloth + LoRA。 Unsloth GitHub:https://github.com/unslothai/unsloth 环境搭建 安装 Unsloth 环境搭建部分在之前的公众号文章中已有详细说明,这里只需在原有基础上补充安装 Unsloth 及指定版本的 trl 库即可。 具体命令如下: # 安装 unsloth 和 vllm pip install unsloth vllm # 安装指定版本的 trl(兼容 unsloth) pip install trl==0.15.0 python train_Datawhale-R1_unsloth.py --config Datawhale-R1_unsloth.yaml 训练代码优化解读 基于 Unsloth 框架,我们对原始代码做了简化和优化
python=3.10 -y conda activate unsloth_env # 安装核心库(自动匹配CUDA版本) pip install "unsloth[colab-new] @ git from unsloth import is_unsloth_available print(f"Unsloth可用状态: {is_unsloth_available()}") # 输出显存优化报告 import unsloth; unsloth.report_memory_optimization() 二、模型加载:4行代码启动百亿大模型 2.1 基础加载模式 from unsloth import 启用kernel融合 export UNSLOTH_KERNEL_FUSION_MODE=aggressive # 3. ") Unsloth正以惊人的速度改变大模型训练的游戏规则。
Unsloth Dynamic 2.0 GGUF(推荐) unsloth/Qwen3.6-27B-GGUF Unsloth 家的 Dynamic 2.0 量化,基于真实世界数据集做校准,关键层做 upcast 量化质量上,比 Unsloth Dynamic 2.0 略朴素——没有针对关键层 upcast,但胜在工具链集成完整、开箱即用 3. Unsloth UD-MLX-4bit(Mac 专属) unsloth/Qwen3.6-27B-UD-MLX-4bit Unsloth 团队也出了动态 MLX 4bit 版本,专门给 Apple Silicon Unsloth 给了一键脚本: curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/scripts /install_qwen3_6_mlx.sh | sh source ~/.unsloth/unsloth_qwen3_6_mlx/bin/activate python -m mlx_vlm.chat
Unsloth 文档详细说明了量化流程(https://docs.unsloth.ai/basics/unsloth-dynamic-2.0-ggufs),并支持GGUF格式(如`DeepSeek-R1 Unsloth建议搭配64GB RAM 以提升性能。 Unsloth 澄清这些是官方 8B 蒸馏模型,适合低配设备。 8B 模型在编码任务中表现优异,但缺乏网页访问和 PDF 处理功能,需依赖外部框架。 /DeepSeek-R1-0528-GGUF [3] 完整运行指南: https://docs.unsloth.ai/basics/deepseek-r1-0528 [4] https://docs.unsloth.ai /basics/unsloth-dynamic-2.0-ggufs),并支持GGUF格式(如DeepSeek-R1-0528-GGUF:TQ1_0): https://docs.unsloth.ai/basics
听起来吓人,但实际上,得益于 Unsloth 的 Dynamic 2.0 量化技术,192GB 内存的 Mac 就能跑 3-bit 版本,256GB 的 Mac 就能跑 4-bit 版本。 Unsloth Dynamic 2.0 量化 Unsloth 其实是第一时间就发布了 Qwen3.5-397B-A17B 的 GGUF 格式文件(Qwen 给了 Unsloth day zero 访问权限 -local-dir unsloth/Qwen3.5-397B-A17B-GGUF \ --include "*UD-Q2_K_XL*" 3. 思考模式(适合复杂推理、数学、编程): export LLAMA_CACHE="unsloth/Qwen3.5-397B-A17B-GGUF" . 虽然 397B 的模型跑起来还是需要不小的投入,但 Unsloth Dynamic 2.0 量化 + MoE 架构的稀疏激活,已经把门槛拉到了"一台高配 Mac"的水平。
聊个让我非常兴奋的项目——mlx-tune 一句话概括:在你的 Mac 上,用 Unsloth 的 API 微调一切 LLM、视觉模型、TTS、STT、OCR、Embedding,全都能在 Apple Silicon 上本地微调 Mac 用户的微调困境 做大模型微调的同学应该都有过这种体验:想在本地跑个小实验验证下 idea,结果发现 Unsloth 依赖 Triton,而 Triton 不支持 Mac 用 mlx-lm 原生 API —— 但代码和 unsloth 完全不兼容,到了云上还得重写一遍 mlx-tune(github.com/ARahim3/mlx-tune)的作者也遇到了一模一样的问题 他的解决思路非常简单粗暴:把 MLX 包装成 Unsloth 的 API 你在 Mac 上写的训练脚本,换个 import 就能直接在 CUDA 集群跑 # Unsloth (CUDA) # MLX-Tune (Apple Silicon) from unsloth import FastLanguageModel from mlx_tune import FastLanguageModel
为什么要关注 Unsloth 的 GGUF? Unsloth 提供了一堆量化版本,初学者可能看花眼。 推荐采样参数 Unsloth 和 Qwen 官方都给了推荐参数 进阶:用 Unsloth 免费微调 Qwen3.5 小模型 光能跑推理还不过瘾? 先装好 Unsloth: pip install --upgrade --force-reinstall --no-cache-dir unsloth unsloth_zoo 然后是一个最简的 SFT 相关链接: Unsloth 本地部署指南:https://unsloth.ai/docs/models/qwen3.5 Unsloth 微调指南:https://unsloth.ai/docs/models
选自 unsloth.ai 作者:Unsloth Team 强化学习(RL)已经成为当今 LLM 不可或缺的技术之一。 原文地址:https://docs.unsloth.ai/basics/reinforcement-learning-guide 开源项目:https://github.com/unslothai/unsloth Unsloth 能为强化学习提供什么? 这里有一些示例笔记本: https://docs.unsloth.ai/get-started/unsloth-notebooks#grpo-reasoning-notebooks 基础知识/技巧 Unsloth -2025 通过 Unsloth 构建的高级 GRPO 笔记本。
而Unsloth将VRAM减少了90%,降至仅54.3GB。 减少长上下文90%VRAM 和使用Flash Attention 2的标准实现相比,Unsloth使用多种技巧,巧妙地把GRPO的VRAM使用量减少了90%多! 在20K的上下文长度下,每个提示生成8次,Unsloth在Llama-3.1-8B模型上仅使用54.3GB的VRAM,而标准实现需要510.8GB(Unsloth减少了90%)。 Unsloth将长上下文GRPO的内存使用量削减了8倍,因此对于20K的上下文长度,只需要额外的9.8GBVRAM! 还需要以16位格式存储KV缓存。 在所有实现中,还利用了logsumexp技巧: Unsloth高效GRPO算法 但没想到华人工程师Horace He的线性交叉熵实现,带给unsloth灵感并成功应用于GRPO!
和 vLLM 或者 SGLang 部署的在线 API 不同,这里 Unsloth 提供的是量化后本地跑的方案,适合没有 H100 集群的普通玩家。 Unsloth 量化后精度损失有多少? 这就是 Unsloth Dynamic 2.0 量化技术的杀疯了之处——重要的层会被自动提升到 8-bit 甚至 16-bit,而不是一刀切全部压缩。 你的设备能跑哪个? 一键运行(Thinking 模式) # 精确编码任务用这个(temperature=0.6,更稳定) export LLAMA_CACHE="unsloth/Qwen3.5-35B-A3B-GGUF" 非思考模式(更快响应) # 不需要深度推理时,关掉 thinking 模式 export LLAMA_CACHE="unsloth/Qwen3.5-35B-A3B-GGUF" . /Qwen3.5-35B-A3B-GGUF \ --local-dir unsloth/Qwen3.5-35B-A3B-GGUF \ --include "*MXFP4_MOE*" # 如果想下
0.简介本教程参考了Unsloth上有关Qwen3.5部署的教程,但是国内由于网络等原因,部署的时候会遇到一系列问题,因此以下给出逐一解决的方法。后续会持续更新Qwen3.5其他系列模型。 根据你的用例,遵循下面的特定命令之一:1.2.2.1.思考模式精确编码任务:exportLLAMA_CACHE="unsloth/Qwen3.5-35B-A3B-GGUF". 35B-A3B-GGUF:UD-Q4_K_XL\--ctx-size16384\--temp0.6\--top-p0.95\--top-k20\--min-p0.00通用任务:exportLLAMA_CACHE="unsloth K_XL\--ctx-size16384\--temp1.0\--top-p0.95\--top-k20\--min-p0.001.2.2.2.非思考模式通用任务:exportLLAMA_CACHE="unsloth top-p0.8\--top-k20\--min-p0.00\--chat-template-kwargs'{"enable_thinking":false}'推理任务:exportLLAMA_CACHE="unsloth
这里我特别推荐大家去UnslothNotebooks上找相应的案例,Unsloth官方提供了几乎目前所有开源模型的基于Unsloth框架训练的colab笔记本,而且Unsloth自身也是一个特别优秀的框架 #Unsloth支持的4bit预量化模型,模型大小小4倍且能防止显存溢出(OOM)。 #在ModelScope社区有Unsloth的镜像,可以预先下载到本地来跳过从HuggingFace上下载fourbit_models=["unsloth/Qwen3-4B","unsloth/Phi- 4-mini-instruct","unsloth/gemma-3-12b-it",]model,tokenizer=FastLanguageModel.from_pretrained(model_name ="none",#偏置:支持任意值,但"none"是经过优化的use_gradient_checkpointing="unsloth",#使用梯度检查点:设置为"unsloth"以支持极长上下文并节省显存