20x Faster TRL Fine-tuning with RapidFire AI
Hugging Face TRL now integrates RapidFire AI, which runs multiple SFT, DPO or GRPO fine-tuning configurations concurrently, even on a single GPU. It shards the dataset into chunks and cycles configs through GPUs at chunk boundaries, using shared-memory adapter spilling and loading for checkpointing. That gives early apples-to-apples metric comparisons and lets you stop, resume or clone-and-modify runs mid-flight with warm starts. Reported benchmarks on A100s with ~1B models show 15–20× faster time to a comparable best training loss than sequential config sweeps. Setup is a drop-in swap of TRL configs for RFSFTConfig, RFDPOConfig or RFGRPOConfig, with an MLflow-based dashboard.
Related posts
- No GPU left behind: Unlocking Efficiency with Co-located vLLM in TRL
Hugging Face hardMasterTRL v0.18.0 can run vLLM co-located with the training job on the same GPUs. vLLM's external_launcher executor puts it inside the torch.distributed process group, replacing the separate HTTP server that left training and inference GPUs idle in turn during GRPO's frequent generation steps. Benchmarks show up to 1.43× throughput for a 1.5B model with larger batches and up to 1.73× for a 7B model with higher tensor parallelism, though extra TP hurts small models. Qwen2.5-Math-72B trained ~1.26× faster on fewer GPUs with matching rewards and Math500 scores, using vLLM level-2 sleep to free memory and DeepSpeed ZeRO-3 with CPU optimizer offload. The write-up also covers debugging a TP seed-determinism regression, a buffer-restore bug after sleep and a remaining shutdown segfault.
- Make LLM Fine-tuning 2x faster with Unsloth and 🤗 TRL
Hugging Face mediumAdeptUnsloth speeds up QLoRA fine-tuning of Llama and Mistral-family models by rewriting PyTorch modules as Triton kernels with manually derived backpropagation. Because no approximations are made, it claims 0% accuracy loss relative to standard QLoRA. Across 59 benchmark runs on A100 and T4 GPUs, it ran 1.5–3.9x faster than Hugging Face transformers and used up to 74% less VRAM. Code examples show loading pre-quantized 4-bit models with FastLanguageModel, attaching LoRA adapters, and training with TRL's SFTTrainer or DPOTrainer.
- Async GRPO with LoRA across HF Jobs: a bucket, a proxy, and no NCCL
Hugging Face hardMasterTRL v1.14's AsyncGRPOTrainer can train a LoRA adapter and sync only that adapter to vLLM, which lets the trainer and inference replicas run as separate Hugging Face Jobs on separate machines without NCCL. A rank-1 adapter for a 1.5B model is a few megabytes, so it travels through a Storage Bucket mounted at the same path in every Job, and vLLM loads it via /v1/load_lora_adapter. Versioned adapter names and max_staleness+2 adapter slots keep in-flight rollouts on their original policy and stop prefix-cache reuse across weight versions. A small proxy adds the auth header, broadcasts adapter loads, pause and resume to every replica, and routes the G=8 rollouts of each prompt to the replica holding their KV prefix using adapter-seeded chained block hashes. Using the AsyncGRPO metrics to find bottlenecks, five runs cut the same 500-step recipe from 3 h 27 min to 53 min.
- Fine-tuning Llama 2 70B using PyTorch FSDP
Hugging Face hardMasterFull fine-tuning of Llama 2 70B across two nodes of 8×A100 80GB GPUs with PyTorch FSDP, Hugging Face Accelerate, Transformers and TRL, addressing three obstacles. CPU RAM exhaustion (~2TB if every rank loads the model) is avoided by loading weights only on rank 0 via the meta device and broadcasting with sync_module_states. Slow, NCCL-timeout-prone checkpointing is fixed by saving intermediate checkpoints as SHARDED_STATE_DICT and switching to FULL_STATE_DICT only for the final save. Flash Attention V2 (kernel fusion, tiling, online softmax) plus gradient checkpointing cut VRAM and time; the run finished in ~13.5 hours, with a paged AdamW optimizer needed on a single node.
- Preference Optimization for Vision Language Models
Hugging Face hardMasterTRL now supports direct preference optimization (DPO) for vision language models, trained on chosen/rejected answer pairs rather than fixed labels. A walkthrough fine-tunes Idefics2-8b on the RLAIF-V dataset, formatting image-plus-question prompts with the processor's chat template. Full float32 DPO training would need about 160 GB (policy, reference model, gradients, AdamW states), but bfloat16 plus LoRA cuts trainable parameters to 55M and memory to roughly 32 GB. Batch size 2 with 32 gradient accumulation steps and gradient checkpointing fits activations, and training is judged by rising accuracy and reward margin.