3090 又能干活了:22GB 显存微调 26B MoE 模型
Unsloth 发布 Inkling 2 Mini 微调 notebook:26.4B MoE 模型的 QLoRA 训练被压到 22GB 显存,比 TRL 快 1.8-3.1 倍、省一半显存。一张 3090 或两张免费 T4 就能跑。
Unsloth 向 Inkling 2 Mini 开放了微调。这是 Thinking Machines Lab 的 26.4B MoE(混合专家)模型,循环 transformer 架构,每层 128 个路由专家(routed experts)。
QLoRA 微调只需要 22GB 显存。一张 24GB 的 3090,就能本地训练。
有网友评论:“22GB,意味着吃灰的 3090 又能干活了。”
快 1.8-3.1 倍,省一半显存
Unsloth 和 transformers + PEFT + TRL 做了同条件对比:同样的数据、同样的 token 数、同样的 QLoRA 设置。
| GPU | 上下文 | Unsloth 每步 | Unsloth 峰值显存 | TRL 每步 | TRL 峰值显存 | 加速 |
|---|---|---|---|---|---|---|
| A100 80GB | 2048 | 9.09s | 29.4 GiB | 16.49s | 58.3 GiB | 1.81x |
| RTX PRO 6000 | 1024 | 2.94s | 25.7 GiB | 9.09s | 55.4 GiB | 3.10x |

TRL 在 40GB 显存下跑不动。bitsandbytes 只量化 nn.Linear 层,Inkling 的专家层是 3D 参数,全部留在 BF16,光模型权重就 47.8 GiB。
专家层 4-bit,message gate 不动
Unsloth 的做法:加载时把路由专家量化到 4-bit,模型从 47.8 GiB 降到 14.5 GiB。
有个关键细节——循环层的 message gates(消息门控)不能量化。如果按普通 transformers 的 4-bit 方案,它们也会被量化,训练 loss 从正常的 0.4-1.2 变成 3.4-3.9。Unsloth 自动把 message_gate.down_proj 排除在 4-bit 外,loss 才正常。
其余优化:
- FlexAttention 处理滑动窗口和 attention sinks,L4 上每步快 15%
- 循环层梯度检查点:层 6-17 每轮前向跑三次,反向时重算 message residual,A100 上省约 1GB
- Fused cross entropy 配合 logit softcap,去掉第二张卡上 2.29GB 的 fp32 logits
- 专家反量化临时空间从 1.27GB 压到 0.18GB

两张 T4,免费跑
Kaggle 免费层是两张 T4。notebook 用层拆分跑,每步约 27 秒。一个更短的 benchmark 里,层拆分 9.0 秒/步、峰值 10.8GB,DDP + offload 16.4 秒/步、峰值 13.2GB。层拆分反而更快,因为每张卡只跑一半层。

上手
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name = "unsloth/Inkling-2-Mini",
max_seq_length = 1024,
load_in_4bit = True,
)
训练完能导出 GGUF。Colab A100 上 q4_k_m 导出 21 分钟,产出 17.48GB GGUF,llama.cpp 可跑。注意导出会先写 53GB 合并权重和 53GB 的 16-bit GGUF,总共要约 150GB 磁盘,Kaggle 会爆盘。
边界在哪
- 一张 T4 不够,4-bit 权重就 14.4GB
- 22GB 是 QLoRA 的数字,不是全量微调。96GB GPU 上的测试:16-bit LoRA 峰值 59GB,冻结专家的全量微调(1.6B 可训练参数)峰值 62GB,全部 26B 只有 lomo 优化器能塞进 96GB
- 有网友问 5070 Ti(16GB)有没有戏。4-bit 权重 14.4GB,剩下不到 2GB 给激活值和优化器,基本没戏
- 有网友问 CPU + 16GB 内存、无 GPU 能不能跑。4-bit 权重就顶到内存上限,训练没有讨论意义
- vLLM 的 Inkling 训练支持还没做
有网友正在 DGX Spark 上试。还有人试了 reasoning_effort 参数:bug 修复任务里,minimal 比默认的 0.9 表现好,5 次里赢 4 次,还更省。这个参数可以在 apply_chat_template 里传,控制模型思考强度。
Notebook:
- Colab(A100):https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Inkling_2_Mini_%2826B%29-Conversational.ipynb
- Kaggle(2x T4):https://www.kaggle.com/notebooks/welcome?src=https://github.com/unslothai/notebooks/blob/main/nb/Kaggle-Inkling_2_Mini_%2826B%29-Conversational.ipynb&accelerator=nvidiaTeslaT4
- 文档:https://unsloth.ai/docs/models/inkling-2-mini/fine-tuning
- GitHub:https://github.com/unslothai/unsloth
发布时间: 2026-11-25 07:20