Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 15 min read Release mediumAdept

TRL v1.0: Post-Training Library Built to Move with the Field

TRL v1.0 turns Hugging Face's post-training codebase, now covering 75+ methods and downloaded 3M times a month, into a library with an explicit stability contract. A semver-governed stable core (SFT, DPO, reward modeling, RLOO, GRPO trainers) sits alongside a fast-moving trl.experimental namespace. Methods are promoted based on the ratio of usage to maintenance cost. Because post-training paradigms keep shifting (PPO to DPO to RLVR/GRPO), the design deliberately avoids shared base classes and generic abstractions and accepts near line-for-line duplication between trainers like RLOO and GRPO, illustrated by the failed Judge abstraction. A comparison against OpenRLHF, veRL, PRIME-RL, Tinker, LLaMA-Factory and others positions TRL as broad, low-infrastructure and stable but lacking native tensor parallelism, with asynchronous GRPO planned next.

Related posts

  • Putting RL back in RLHF

    Hugging Face hardMaster

    RLOO (REINFORCE Leave-One-Out) is now available as a trainer in Hugging Face TRL. It is an online RLHF algorithm that drops PPO's value model. It treats the whole completion as a single action, uses the REINFORCE loss, and computes each sample's baseline as the mean reward of the other k−1 completions for the same prompt. That cuts vRAM by roughly 50-70% and makes training 2-3x faster than PPO on Pythia 1B and 6.9B, while matching PPO's GPT-4-judged win rate (78.7% for 6.9B on TL;DR) and beating DPO. Code walkthroughs show the advantage computation and that REINFORCE is a special case of the PPO loss. There is a caveat: bf16 numerical mismatches between generation and training logprobs hurt RLOO more than PPO.

  • Toward RL on mixed-precision, mixed-accelerator samplers

    Modal hardMaster

    RL training of Qwen3.6-35B-A3B on agentic coding stays stable when samplers run on six accelerator types (A100 through B300, RTX PRO 6000) in NVFP4, FP8 and BF16 with their own kernels, feeding a BF16 trainer on B200. Uncorrected GRPO collapses on both mixed and homogeneous samplers. Only score centering plus masked importance sampling (optionally with top-p mask replay) trains to the end, matching homogeneous-sampler SWE-bench Pro V2 pass@4 despite 4.7× larger sampler–trainer KL, at about 15% lower sampling cost per update. The central claim is that stability depends on whether mismatch keeps growing, not on its size, so off-policy correction can stand in for bitwise-identical on-policy matching. Collapse shows up as falling reward, KL growing 3× or more, and episodes ending when the model stops calling its tool.

  • StackLLaMA: A hands-on guide to train LLaMA with RLHF

    Hugging Face hardMaster

    A 7B LLaMA model is trained to answer Stack Exchange questions with the full RLHF pipeline: supervised fine-tuning on packed Stack Exchange text, a pairwise reward model trained on upvote-derived preference scores, and PPO with a KL penalty against a frozen reference model. Memory is kept manageable by loading the model in 8-bit and training only LoRA adapters via peft, which needs roughly 1.2-1.4GB per billion parameters. The same frozen base serves as both policy and reference model, and data parallelism through accelerate or torchrun speeds up training. The reward model reaches 67% accuracy, and the RL run takes about 20 hours on 24 A100s. The post closes with practical notes on reward hacking and training instabilities.

  • 🐯 Liger GRPO meets TRL

    Hugging Face hardMaster

    Liger's chunked loss, extended to GRPO and integrated into TRL's GRPOTrainer, cuts peak training memory by up to 40% with no change in reward curves. It chunks the lm_head input along the batch and computes each chunk's gradients during the forward pass, so full logits never need to be held for backward. Benchmarks on Qwen3-0.6B with gsm8k show savings growing with batch size. FSDP and PEFT support allow 1.5–1.8x larger batch sizes across Qwen3 sizes, and LoRA removes the need for a separate reference model. Setup is a `use_liger_loss=True` flag, with optional vLLM-server generation for faster rollouts.

  • Make LLM Fine-tuning 2x faster with Unsloth and 🤗 TRL

    Hugging Face mediumAdept

    Unsloth 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.

The quest for software engineering knowledge.

Look:
Layout: