GitHub - woct0rdho/transformers5-qwen3.5-recipe: Qwen and DeepSeek low-VRAM LoRA training with GGUF base model, compatible with Transformers and PEFT

GitHub

2 min read Original article ↗

Open weight AI is like open source software. Users not only run the weights, but also modify the weights. It matters to develop training framework for local hardware.

GGUF is going to replace bitsandbytes as the base model format for low-VRAM LoRA training. I've tried to train, with no CPU offload:

  • Qwen3.6-35B-A3B in 16 GiB VRAM (implying it's more than enough to train Qwen3.5-122B-A10B in 64 GiB, and Qwen3.5-397B-A17B in 192 GiB)
  • DeepSeek-V4-Flash (284B-A13B) in 90 GiB VRAM
  • Qwen3.8-Flash-Next (125B-A6B + 51B engram) in 40 GiB VRAM

Currently all kernels and parameters in this repo are tuned for Strix Halo. More work is needed to support other GPUs.

Things involved in the training:

  • Usual training loop with transformers 5 and PEFT
  • Transformers with GGUF quantizer, see https://github.com/woct0rdho/transformers/tree/gguf . I'm tracking this in huggingface/transformers#40070 . If I could not merge it into transformers in the end, I'll reimplement it as some monkey patches in this repo
  • Tuned GEMM, see ROCm/rocm-libraries#9385
  • MMQ and grouped MMQ like llama.cpp, see https://github.com/woct0rdho/torch-ggml-ops
  • Fast LoRA bwd formula like Unsloth for linear layer and MoE layer
  • AITER gmm/ptgmm Triton kernels with tuned configs for non-quantized MoE LoRA
  • MoE routing like OpenAI triton-kernels
  • RMSNorm from Liger Kernel
  • Chunked cross entropy loss like Liger Kernel, which works with MMQ
  • Autoregressive decoding cache and load balancing loss disabled to save VRAM
  • Non-reentrant gradient checkpointing
  • bitsandbytes AdamW 8-bit optimizer

Qwen3.5-specific:

DeepSeek-specific:

Qwen4-Exp-specific:

Other notes:

  • Unsloth gradient checkpointing provides fast async CPU-GPU copy. You need it if you actually do CPU offload. But on Strix Halo with unified memory you should just use the usual gradient checkpointing
  • When loading large models on Strix Halo, you need pread, see safetensors/safetensors#728
  • When using transformers with GGUF quantizer, you need torch.compile on the GGUF dequant function to save VRAM
  • When inferencing the model with LoRA in llama.cpp, currently llama.cpp does not have fast LoRA kernels. I've made some, see the commit log in https://github.com/woct0rdho/llama.cpp