# Unsloth

Unsloth 是一个面向大语言模型的开源微调与量化工具包，于 2023 年 11 月 29 日由 Daniel Han 和 Michael Han 以 GitHub 仓库的形式首次发布。它用手写的 Triton 内核、手工推导的反向传播和融合算子取代了标准的 [Hugging Face](https://www.edgepedia.org/zh/hugging-face) 训练路径；据项目方报告，对于开放权重模型的 LoRA（一种只添加小型可训练权重矩阵、而非训练整个模型的微调方法）和 QLoRA 适配，这一做法使训练速度达到原来的约 2 倍、显存占用减少 70%，且精度无损。<sup>[1](https://github.com/unslothai/unsloth?search=1)</sup><sup> • </sup><sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup> 此后它已成为开放权重生态中的核心节点，既是训练工具，也是通过 Hugging Face 分发的量化 [GGUF](https://www.edgepedia.org/zh/gguf) 模型文件的生产者。

| 关键事实 | 数值 |
|---|---|
| 创始人 | Daniel Han、Michael Han<sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup> |
| 首次发布 | 2023 年 11 月 29 日（创建仓库）<sup>[1](https://github.com/unslothai/unsloth?search=1)</sup> |
| 许可证 | 核心为 Apache 2.0；Unsloth Studio UI 等可选组件为 AGPL-3.0<sup>[1](https://github.com/unslothai/unsloth?search=1)</sup> |
| GitHub 星标数（2026 年 9 月） | 75,556<sup>[1](https://github.com/unslothai/unsloth?search=1)</sup> |
| 宣称的提升（厂商数据） | 训练速度为原来的 2 倍、显存减少 70%、精度无损<sup>[1](https://github.com/unslothai/unsloth?search=1)</sup> |
| 开源版 GPU 限制 | 单 GPU；H100 80GB 上可跑 70B 模型，H200 上约 141B<sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup> |
| 支持的模型家族 | 约 10 个家族、50 多个模型（Llama、Mistral、Gemma、Qwen、Phi、DeepSeek、Mixtral 等）<sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup> |

## 工作原理

Unsloth 加速微调的方式是重写训练循环中的算术运算，而不是改变训练算法。它的所有内核都用 OpenAI 的 Triton 语言编写，配有手写的反向传播引擎，而不是完全依赖 PyTorch 的自动微分；它支持 2018 年及以后的 NVIDIA GPU（最低 CUDA 计算能力 7.0），也支持 AMD 和 Intel GPU。<sup>[3](https://github.com/unslothai/unsloth/blob/37a4c826a0d6cbd97d7e741f069ab6dc012611c6/README.md)</sup> 项目方声明不使用任何近似方法，精度损失为 0%。<sup>[3](https://github.com/unslothai/unsloth/blob/37a4c826a0d6cbd97d7e741f069ab6dc012611c6/README.md)</sup>

据一份第三方知识库介绍，大部分节省来自三项具体技术。第一，选择性激活重计算：标准的梯度检查点在反向传播时重算所有内容，带来约 30% 的额外计算量；而 Unsloth 只重算开销低廉的运算（RMSNorm、SiLU、残差），并缓存开销高昂的注意力输出，在获得相近显存节省的同时只增加约 10% 的计算量。<sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup> 第二，融合交叉熵内核，它从不实际生成完整的 logits 张量，使 Llama 3.1 8B 在 4k 上下文下损失计算步骤的峰值显存减少 5 至 10 GB。<sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup> 第三，注意力变体：Unsloth 与 Apple 合作加入了 Cut Cross Entropy，<sup>[3](https://github.com/unslothai/unsloth/blob/37a4c826a0d6cbd97d7e741f069ab6dc012611c6/README.md)</sup> 其 Gemma-3 Flex-Attention 默认将注意力显存从 O(N²) 降到 O(N)，把 8K 上下文的峰值显存从 52.3 GB 降至 27.5 GB（节省 47%），并使此前会显存不足的 64K 上下文训练成为可能。<sup>[4](https://unsloth.ai/docs/basics/faster-moe)</sup>

对于混合专家（MoE）模型，Unsloth 推出了定制的 Triton 分组 GEMM 和 LoRA 内核，与 Hugging Face 合作开发，使用了 PyTorch 的 torch._grouped_mm；厂商报告称，MoE 训练速度约为原来的 12 倍、显存减少 35% 以上、上下文长度约为原来的 6 倍。<sup>[4](https://unsloth.ai/docs/basics/faster-moe)</sup> 在 A100 上，厂商报告称经过约两分钟的一次性自动调优后，其 Triton MoE 内核的速度约为 torch._grouped_mm 的 2.5 倍。<sup>[4](https://unsloth.ai/docs/basics/faster-moe)</sup>

## 发布与版本历史

仓库创建于 2023 年 11 月 29 日，项目的引用信息将功劳归于 Daniel Han、Michael Han 和 Unsloth 团队，日期为 2023 年。<sup>[1](https://github.com/unslothai/unsloth?search=1)</sup><sup> • </sup><sup>[3](https://github.com/unslothai/unsloth/blob/37a4c826a0d6cbd97d7e741f069ab6dc012611c6/README.md)</sup>

量化产品线分三步发展。Dynamic 2.0 引入了逐层量化，利用一个包含超过 150 万 token 人工精选数据的校准数据集，为每一层调整量化类型；与此前仅适用于 MoE 的 1.58 比特 [DeepSeek-R1](https://www.edgepedia.org/zh/deepseek-r1) 量化不同，Dynamic 2.0 适用于包括非 MoE 模型在内的所有架构。<sup>[5](https://unsloth.ai/docs/basics/dynamic-3.0-ggufs)</sup> 2025 年 9 月 10 日的一次更新报告称，Unsloth 的 Dynamic 3 比特 DeepSeek V3.1 GGUF 在 Aider Polyglot 基准上得分 75.6%，厂商称这超过了许多全精度前沿模型。<sup>[5](https://unsloth.ai/docs/basics/dynamic-3.0-ggufs)</sup> Dynamic 3.0 于 2026 年推出，厂商报告称在相同文件大小下，与其他提供商的量化相比，top-1% 精度提升超过 10%；Qwen3.8-27B Dynamic v3.0 GGUF 可在 llama.cpp 和 Unsloth Desktop 中运行。<sup>[5](https://unsloth.ai/docs/basics/dynamic-3.0-ggufs)</sup>

模型支持紧跟发布节奏：Unsloth 表示曾与 Qwen3、Meta（Llama 4）、Mistral（Devstral）、Google（Gemma 1–3）和 Microsoft（Phi-3/4）背后的团队直接合作，贡献了若干修复，例如 [Llama 4](https://www.edgepedia.org/zh/llama-4) 的 QK-norm 修正（该归一化被所有注意力头共享，本不应如此），使 MMLU Pro 精度从 68.58% 提升到 71.53%。<sup>[5](https://unsloth.ai/docs/basics/dynamic-3.0-ggufs)</sup>

## 数据一览

厂商的基准测试表报告，在 80GB GPU 上对 Llama 3.3（70B）做 QLoRA，与 Hugging Face + Flash Attention 2 相比，速度为 2 倍、显存减少 75% 以上、上下文长度为原来的 13 倍。<sup>[3](https://github.com/unslothai/unsloth/blob/37a4c826a0d6cbd97d7e741f069ab6dc012611c6/README.md)</sup> Llama 3.1（8B）4 比特 QLoRA 的上下文长度基准显示：8GB 显存上可处理 2,972 token（HF+FA2 在此显存不足），80GB 上最高可达 342,733 token，而 HF+FA2 为 28,454 token。<sup>[3](https://github.com/unslothai/unsloth/blob/37a4c826a0d6cbd97d7e741f069ab6dc012611c6/README.md)</sup>

一份第三方知识库（Yobitel）给出了 H100 80GB 在 4k 序列长度下的吞吐数据：Llama 3.1 8B QLoRA 约 6,500 token/秒，而原版 HF+PEFT 约 3,200；Mistral 7B 约 7,200 对 3,800；Gemma 2 9B 约 5,800 对 2,900；Llama 3.1 70B QLoRA 可在 4k 上下文下运行，而原版路径会显存不足。<sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup> 同一来源描述，一次 Llama 3.1 8B QLoRA 运行在原版 HF 上耗时 7 小时，用 Unsloth 约 3.5 小时完成，峰值显存从约 22 GB 降至约 10 GB。<sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup>

解读这些数字时应注意两点。首先，70% 的显存节省是厂商宣称；第三方来源给出的节省幅度为 50% 至 70%，视模型家族而定（Llama 3.1 和 Mistral 为 50% 至 55%，Gemma 2 为 55% 至 60%，Qwen 2.5 约 50%，Phi-3 约 45%，提速从 2 倍递减至 1.5 倍）。<sup>[1](https://github.com/unslothai/unsloth?search=1)</sup><sup> • </sup><sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup> 其次，本文未能找到对所称提速的真正独立基准测试；唯一的第三方来源可能只是转述厂商数据，因此无法进行独立与厂商数据的交叉验证。<sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup>

在采用情况方面，截至 2026 年 9 月检索时，该仓库有 75,556 个星标和 6,863 个复刻；Unsloth 报告其 Qwen3.8 量化版本在发布后五天内下载量超过 510 万次。<sup>[1](https://github.com/unslothai/unsloth?search=1)</sup><sup> • </sup><sup>[5](https://unsloth.ai/docs/basics/dynamic-3.0-ggufs)</sup>

## 量化：Dynamic GGUF 与格式

Unsloth 为 llama.cpp 及其他本地运行时生成 GGUF 文件，并从训练中导出 NVFP4 和 FP8 格式。<sup>[1](https://github.com/unslothai/unsloth?search=1)</sup><sup> • </sup><sup>[5](https://unsloth.ai/docs/basics/dynamic-3.0-ggufs)</sup> 其 Dynamic 量化在重要性矩阵（imatrix）校准数据集的引导下为每一层选择不同的量化类型，该数据集包含超过 150 万 token 的人工精选、清洗过的数据；项目方公开该数据集供社区评估，并声明不做 QAT 或 QAD，只使用训练后量化。<sup>[5](https://unsloth.ai/docs/basics/dynamic-3.0-ggufs)</sup>

厂商的质量对比全部为自报数据。针对 Google 为 Llama 4 Scout 提供的量化感知训练（QAT），Unsloth 声称其动态 4 比特版本文件小 2 GB，而在其 5-shot MMLU 评测中得分为 71.47% 对 70.64%。<sup>[5](https://unsloth.ai/docs/basics/dynamic-3.0-ggufs)</sup> 它还批评了常见的重要性矩阵方法，警告说大多数在维基百科相关数据上校准和基准测试的 imatrix GGUF 会过拟合，在使用相同数据的基准上获得人为偏低的困惑度和 KL 散度分数。<sup>[5](https://unsloth.ai/docs/basics/dynamic-3.0-ggufs)</sup> 本文所查来源中未找到将 Unsloth 量化与 llama.cpp 标准量化进行独立困惑度或质量对比的资料。

## 与 Axolotl、LLaMA-Factory 和 llama.cpp 的比较

在微调生态中，Unsloth 的定位是单 GPU 吞吐量。第三方的一条经验法则是：在支持的模型家族上做单 GPU SFT/DPO，Unsloth 胜出；其他情况 Axolotl 胜出，Axolotl 提供多 GPU 灵活性，[LLaMA-Factory](https://www.edgepedia.org/zh/llama-factory) 提供图形界面。<sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup> Unsloth 的开源版限于单 GPU；多 GPU DDP/FSDP 支持和专有内核优化需要商业版 Unsloth Pro/Enterprise。<sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup>

支持广度是一个实际约束。截至 2026 年中，Unsloth 覆盖约 10 个模型家族、50 多个模型，支持一个新家族需要约一周的内核开发工作；没有定制内核的架构会回退到 Hugging Face 基线性能，速度优势随之消失。<sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup> llama.cpp 不是竞争对手，而是运行时搭档：Unsloth 的 Dynamic GGUF 量化就是为在它里面运行而构建的。<sup>[5](https://unsloth.ai/docs/basics/dynamic-3.0-ggufs)</sup>

## 采用情况及在生态中的角色

Unsloth 服务于三类相互重叠的用户。Cognitive Computations 的 Dolphin 模型等社区微调家族在使用它，第三方来源称“使用 Unsloth 训练”的 README 页脚是 Hugging Face 微调模型卡上最常见的景象之一。<sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup> [托管服务](https://www.edgepedia.org/zh/managed-services)将其用作 30B 以下微调的默认后端。<sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup>

它的第二个角色是量化中介：当新的开放权重模型出现时，Unsloth 的量化 GGUF 往往是本地运行时用户最先下载的文件之一，Qwen3.8 五天内 510 万次下载即是例证。<sup>[5](https://unsloth.ai/docs/basics/dynamic-3.0-ggufs)</sup>

## 许可、商业模式与局限

Unsloth 核心包为 Apache 2.0，而 Unsloth Studio UI 等可选组件在双许可结构下采用 AGPL-3.0。<sup>[1](https://github.com/unslothai/unsloth?search=1)</sup> 开源版在单 GPU 使用上功能完整；商业版 Pro/Enterprise 增加多 GPU 封装和专有内核优化，单 GPU 的实际上限为 H100 80GB 上的 70B（H200 上约 141B）。<sup>[2](https://yobitel.com/knowledge-base/unsloth)</sup> 没有来源给出 Unsloth Pro、Dynamic 2.0 相关产品或 Enterprise 的定价，也没有来源涉及项目的融资历史，因此商业方面在此无法量化。

厂商列出的已知技术局限包括：不建议对 MoE 模型使用 4 比特 QLoRA，因为 BitsandBytes 不支持。<sup>[4](https://unsloth.ai/docs/basics/faster-moe)</sup> 除厂商的 8GB 上下文基准外，来源中没有 RTX 4090 或免费 Colab T4 硬件的具体显存和时间数据。<sup>[3](https://github.com/unslothai/unsloth/blob/37a4c826a0d6cbd97d7e741f069ab6dc012611c6/README.md)</sup>

## References

1. [unslothai/unsloth — GitHub repository](https://github.com/unslothai/unsloth?search=1)
2. [Unsloth — Knowledge Base (Yobitel)](https://yobitel.com/knowledge-base/unsloth)
3. [README.md · unslothai/unsloth (pinned commit)](https://github.com/unslothai/unsloth/blob/37a4c826a0d6cbd97d7e741f069ab6dc012611c6/README.md)
4. [Fine-tune MoE Models 12x Faster with Unsloth — official documentation](https://unsloth.ai/docs/basics/faster-moe)
5. [Unsloth Dynamic 3.0 GGUFs — official documentation](https://unsloth.ai/docs/basics/dynamic-3.0-ggufs)

---
*Initially written Sep 17, 2026 · Edited: Oct 11, 2026; Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 现代人工智能：基础模型、生成式人工智能与人工智能产业 › Model families and named models › Open-weight ecosystem, formats, and licensing

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/unsloth

English original: https://www.edgepedia.org/unsloth
