Repository navigation
Releases
v1.19.0
Features
👥 Multi-teacher and agent distillation
DistillationTrainer takes a dict of teachers, and each example's teacher_id column picks the one that scores its completion: the fusion stage of MOPD. It also takes environment_factory, with the same contract as GRPOTrainer, so agents can be distilled against stateful environments.
trainer = DistillationTrainer(
model="Qwen/Qwen2.5-0.5B-Instruct",
teacher_model={"math": "Qwen/Qwen2.5-Math-1.5B-Instruct", "code": "Qwen/Qwen2.5-Coder-1.5B-Instruct"},
train_dataset=dataset, # with a "teacher_id" column: "math" or "code"
)- Implement MOPD for the
DistillationTrainerby @cmpatino in #7215 - Add
environment_factorysupport toDistillationTrainerby @sergiopaniego in #8453
🕐 Inkling 2 Mini
Support for thinkingmachines/Inkling-2-Mini: coverage in the VLM tests and an example that teaches it to read analog clocks. LoRA SFT on one H100 in 53 min takes it from 0% to 87.0% of held-out clocks read to the second. Needs transformers>=5.24.0.
- Add Inkling 2 Mini: tiny model, tests and clock-reading SFT example by @qgallouedec in #8517
- Add a tiny Inkling 2 model and run it in the VLM tests by @qgallouedec in #8498
- Add a tiny Inkling model by @albertvillanova in #8512
⚡ AsyncGRPO: faster packing, more architectures
- Plan and pack micro-batches with array operations: on Qwen3-1.7B math rollouts (4×B300), planning + packing goes from 18 s to 1 s per pass, +28% trained tokens/s, with bit-identical batches. By @qgallouedec in #8533
- Nemotron-H tree packing: Mamba2 layers (Nemotron-H, Granite-4.0-H, Bamba) now follow the tree, with new Triton tree scan, conv and fused mixer kernels. By @AmineDiro in #8457
- LFM in tree attention by @younesbelkada in #7966
✂️ 2x faster packed SFT with SDPA
BFD packing (the default with packing=True) flattened the batch into one row, so SDPA attended across the whole batch: quadratic, and out of memory on Trainium. Packed examples now stay as rows, with position_ids restarting at each sequence. padding_free=True still flattens.
s/step with packing_strategy="bfd":
| v1.18 | v1.19 | |
|---|---|---|
| H100, Qwen3-1.7B, SDPA | 2.06 | 1.02 |
| H100, Qwen3-1.7B, flash attention 2 | 0.828 | 0.832 |
| Trainium2, Qwen3-0.6B, compiled | crashes | 3.2 |
by @qgallouedec in #7804
🛑 Fine-tuned models stop at the end of their turn
Qwen base, Gemma 1/2 instruct, Qwen3.5 and a few others don't list their chat template's end-of-turn token as a stop token, so a model fine-tuned on them generated until max_new_tokens. SFTTrainer now adds that token to generation_config.eos_token_id when it's missing, and changes nothing elsewhere (checked on the 348 matching checkpoints among the 3000 most-downloaded Hub repos).
by @albertvillanova in #8565
💬 More chat templates
assistant_only_loss=True and tool calling work on more checkpoints, all by @albertvillanova:
- Assistant-only loss: DeepSeek-V3.1 (#8431), DeepSeek-V3.2-Exp (#8471), DeepSeek-R1-Distill (#8529), SmolLM2 (#8444), Phi-4 (#8445), Gemma 4 (#8493), GLM-4.7 and GLM-5 (#8494), Qwen3-Coder (#8496), Llama 3.1 and 3.2 (#8495), OLMo 3 Think (#8475), LFM2-24B-A2B (#8526), Inkling (#8513)
- Tool calling: DeepSeek-R1-0528 and V3-0324 (#8443), DeepSeek-V3.1 and V3.2-Exp (#8508)
- More template revisions recognized (#8272, #8275, #8317, #8467, #8468, #8503, #8509, #8510, #8527, #8528, #8561, #8562, #8575)
Other
- Grade accuracy rewards in a separate process so a pathological answer can't hang training: an answer like
5^{5^{5^{5^5}}}blocked math-verify forever and killed AsyncGRPO runs. By @sergiopaniego in #8330 - Support
pad_to_multiple_ofwith vision-language models in SFT, DPO and KTO, which fixes VLM training on Trainium, by @albertvillanova in #8553 - Raise in AsyncGRPO when a whole pass over the prompts drops every group, instead of hanging, by @albertvillanova in #8425
- Add an s3 multi-agent aggregation example (held-out team success 4.7% → 60.9%) by @kashif in #8424
- Detect HF Jobs via
HF_JOB_IDand add the hardware flavor to the model card by @davanstrien in #8576 - Load the processing class in
OnlineDPOTrainerwhen it is omitted by @behroozazarkhalili in #7519 - Add Python 3.15 to the test matrix and the classifiers by @qgallouedec in #7498
Removals and requirement bumps
- Add support for vLLM 0.34.x, so the range is
vllm>=0.23.0,<0.35.0. Documentedvllm servecommands now pass--gpu-memory-utilization 0.9: 0.34's new default of 1.0 OOMs the first weight sync. By @qgallouedec in #8418 and #8438 - Make
prefixa required argument ofparse_responseby @qgallouedec in #8458 - Require
peft>=0.18.0and drop the peft 0.17 compatibility code by @albertvillanova in #8426 - Require
accelerate>=1.12.0and drop the older accelerate fallbacks by @albertvillanova in #8542 - Default
ModelConfig.model_revisiontoNonelike the other revision arguments by @albertvillanova in #8530 - Follow the transformers 5.23 rename of gradient checkpointing to activation checkpointing by @qgallouedec in #8113
Fixes
- Merge LoRA adapters out of place for the vLLM weight sync. Frozen weights moved at every sync and a 4-bit base was sent packed. QLoRA in server mode now works, and the server-mode log-prob gap on Qwen2.5-0.5B drops from 0.19–0.24 to 0.02–0.04. By @qgallouedec in #8269
- Stop pasting a fake tool call before every tool result when the eos is
<turn|>, as in Unsloth's Gemma 4 tokenizers (#8521), and repeating GLM's<|observation|>(#8522), by @qgallouedec - Read vLLM >= 0.32 generate log-probs in AsyncGRPO, which raised
KeyError: 'token'on the first rollout withtop_kortop_p, by @rycerzes in #8573 - Fix AsyncGRPO score-centering tail ratios and sampler validation by @kashif in #8373 and #8414
- Keep the generation prompt's
<think>\nout of the DeepSeek-V3 (#8313) and DeepSeek-R1-Distill (#8314) assistant-only loss, and its\nout of Qwen2.5's (#8279), by @albertvillanova - Fix
BEMACallbackwhen some parameters are frozen by @qgallouedec in #8455 - Keep the
environmentcolumn in GRPO whenremove_unused_columns=Trueby @qgallouedec in #8520 - Load a reward model given by name without the policy's revision by @albertvillanova in #8538
- Skip the InternVL tile count for models that split their images by
image_grid_thw, so GRPO and RLOO no longer crash on Inkling 2, by @qgallouedec in #8484 - Convert nested image arrays with
np.arraybefore making tensors in GRPO, RLOO and Distillation by @albertvillanova in #8394 - Render
Nonecontent as empty text in the GLM-4-MoE training template by @albertvillanova in #8454 - Skip torch's sparse invariant checks for GOLD's X-Token projection matrix by @albertvillanova in #8393
- AsyncDistillation: freeze the vision tower of VLM students (#8412), load students with the architecture their config declares (#8413), and fix VLM students on transformers < 5.0 (#8462), by @albertvillanova
- Fix the CLI parser on Python 3.15 by @qgallouedec in #8271
- Compare version checks against plain release versions, not .dev0, by @qgallouedec in #8256
- Drop
--api-server-countfrom the AsyncGRPO adapter-sync command, which vLLM rejects, by @sergiopaniego in #8383 - Gate the MoE dense and shared layer LoRA warning on peft 0.22.0 (#8328, #8483) and only check models whose targets peft remaps (#8428), by @albertvillanova
Documentation
- Fix dead links in the docs by @erdogan-deniz in #8459
- Clarify
max_completion_length(#8450) andmax_tool_calling_iterations(#8464) with tools, the sessionsenvironment_factoryopens on OpenEnv servers (#8452), and why the rollout worker can't start child processes (#8463), by @sergiopaniego - Add the results to the Wordle example README (#8099), open one OpenEnv client per game (#8129), update the blog posts on the landing page (#8579) and point to the new OpenEnv docs site (#8586), by @sergiopaniego
- Use the activation ...
v1.18.2
What's Changed
- Fix BEMACallback when some parameters are frozen by @qgallouedec in #8455
- Recognize the Muse Glimmer chat template revision that states the JSON response format by @albertvillanova in #8467
Full Changelog: v1.18.1...v1.18.2
v1.18.1
What's Changed
- Fix the CLI parser on Python 3.15 by @qgallouedec in #8271
- Recognize the SmolVLM2 chat template revision that renders string content by @albertvillanova in #8272
- Grade accuracy rewards in a separate process so a pathological answer can't hang training by @sergiopaniego in #8330
- Follow the transformers 5.23 rename of gradient checkpointing to activation checkpointing by @qgallouedec in #8113
Full Changelog: v1.18.0...v1.18.1
v1.18.0
Features
Warning
The submodules of trl.experimental.async_grpo are gone. from trl.experimental.async_grpo.async_grpo_config import AsyncGRPOConfig, and imports from async_rollout_worker, packing, vllm_client or weight_transfer in that package, no longer work. Import the trainer from trl, the rollout loop from trl.trainer.async_grpo_trainer, and the vLLM client from trl.generation.async_vllm_client (renamed AsyncVLLMClient). from trl.experimental.async_grpo import AsyncGRPOConfig, AsyncGRPOTrainer still works, with a FutureWarning, until v2.0.0.
🎓 AsyncGRPOTrainer is now a stable trainer
AsyncGRPOTrainer runs GRPO with generation decoupled from training. A rollout worker in a background process streams completions from a vLLM server, scores them and queues them, while the training loop pulls from the queue and updates the model. Generation and gradient updates overlap instead of alternating, and the trainer sends its new weights to the server over NCCL every weight_sync_steps steps.
In v1.17 it lived in trl.experimental.async_grpo: seven files, three ways to batch and bound generation, two constructor arguments for swapping out internals, and metric names that didn't match GRPO's. This cycle cleaned that up in about 40 PRs, tracked in #7841: config renames, one timeout instead of three, one batching mode, generation held to max_staleness, GRPO's metric names and init checks, a public rollout loop, and the two-file layout every stable trainer has. Then #8288 moved it to the top-level package.
# Before
from trl.experimental.async_grpo import AsyncGRPOConfig, AsyncGRPOTrainer
# Now
from trl import AsyncGRPOConfig, AsyncGRPOTrainerThe old path still works and emits a FutureWarning (removal in v2.0.0). The rollout loop extension point lives next to the trainer, from trl.trainer.async_grpo_trainer import AsyncRolloutLoop, Rollout, and isn't exported from trl. The OpenEnv / Harbor harness stays experimental, as HarnessAsyncGRPOTrainer in trl.experimental.async_grpo.openenv_harness. Logged metric names can still change between releases.
Quick start, from the docs. Install with pip install trl[vllm,kernels,math_verify], then start the vLLM server on GPU 0:
CUDA_VISIBLE_DEVICES=0 VLLM_SERVER_DEV_MODE=1 vllm serve Qwen/Qwen3.5-2B \
--weight-transfer-config '{"backend": "nccl"}' \
--logprobs-mode processed_logprobs \
--api-server-count 8 \
--max-model-len 4096Then train on GPU 1 with CUDA_VISIBLE_DEVICES=1 python train_async_grpo.py:
# train_async_grpo.py
from datasets import load_dataset
from trl import AsyncGRPOTrainer
from trl.rewards import accuracy_reward
if __name__ == "__main__": # the rollout worker is a spawned process that re-imports this script
dataset = load_dataset("trl-lib/DeepMath-103K", split="train")
trainer = AsyncGRPOTrainer(
model="Qwen/Qwen3.5-2B",
reward_funcs=accuracy_reward,
train_dataset=dataset,
)
trainer.train()This exact example runs end to end. It's a sanity check, not a speedup comparison:
| Model / data / reward | Qwen/Qwen3.5-2B, trl-lib/DeepMath-103K, accuracy_reward |
| Hardware | 2x B200: vLLM on one GPU, the trainer on the other |
| Config | default AsyncGRPOConfig: fp32 weights with bf16 autocast, 8 generations per prompt, up to 2048 completion tokens, token_budget read from --max-model-len 4096 |
| Step time | ~7 s/step, after ~5 min of warmup |
| Throughput | ~7k trained tokens/s |
| Trainer vs vLLM log-prob gap | 0.007 to 0.02 |
What the trainer covers, all documented on the trainer page:
- Tree packing: each micro-batch row is a prefix trie, so a prompt shared by a group's rollouts, or the history repeated by every turn of a multi-turn rollout, is forwarded once. Gated DeltaNet hybrids (Qwen3.5, Qwen3.6, Qwen3-Next) are supported.
- Agent training:
tools,environment_factoryand multi-turn rollouts. - Score centering with masked importance sampling as the default objective (
score_centering=True).score_centering=Falsegives GRPO's clipped objective with the same masked ratio. - Zero-advantage group filtering: groups whose rewards are all equal are dropped before they cost a forward and backward, and their share is logged as
frac_zero_std_groups. - Top-k / top-p renormalization: with
top_pormin_p, settop_k > 0and the trainer normalizes its log-probs over the candidate set vLLM sampled from. - LoRA adapter sync: start vLLM with
--enable-loraand each weight sync sends only the adapter (about 160 MB atr=32) instead of merged weights. - Custom rollout loops: subclass
AsyncRolloutLoop, overridefilter_prompt,generate_one,generate_one_turn,compute_advantages,setuporclose, and set it asloop_clson a trainer subclass. The trainer's constructor doesn't change. - Metrics with reading guides: every logged metric has a one-line definition, plus guides for whether a run is generation-bound or trainer-bound and whether it is saturating or sampling duplicates.
- Text-only training of VLM checkpoints (Qwen3.5, Qwen3.6, Qwen3-VL), with the vision tower frozen.
💥 What this changes for you. If you used the experimental AsyncGRPOTrainer in v1.17, the breaking changes all landed before the promotion, so they don't have to happen after it. AsyncDistillationTrainer (still experimental) got the same constructor removals, config renames, timeout merge, batching and staleness changes and metric conventions in the same PRs.
Constructor arguments:
weight_transfer=is removed. Weight sync is built from the config: NCCL through vLLM's weight-transfer API, or adapter sync for LoRA. The server is a plainvllm serve.rollout_worker=is removed. To change how rollouts are produced, subclassAsyncRolloutLoopand setloop_cls(see above).- For OpenEnv / Harbor,
HarnessAsyncGRPOTrainerreplaces building aHarnessRolloutWorkeryourself and passing it asrollout_worker=.
Config:
| v1.17 (experimental) | v1.18 |
|---|---|
max_inflight_tasks (-1 = automatic) |
max_concurrent_rollouts, a fixed ceiling, 512 by default |
heartbeat_stale_after_s |
rollout_worker_timeout (same meaning, same 300 s default) |
request_timeout, weight_sync_timeout |
removed: vllm_server_timeout (default 1800 s, was 240 s) now covers server readiness, every request and every weight-sync call |
queue_maxsize |
removed: generation is held to max_staleness, counted in tokens |
fork_threshold_tokens |
removed: a multi-turn rollout always forks on re-tokenization drift, so no generated token loses its training signal |
token_budget <= 0 (fixed-count batching) |
removed: the token-budget batcher is the only mode. Use None (read max_model_len from the server) or a positive int |
repetition_penalty |
removed: the sampler's log-probs include it and the trainer's don't, which biases the importance ratio |
remove_unused_columns=True (ignored) |
defaults to False, and True raises: every dataset column goes to the reward functions |
Behavior to check after upgrading:
- Readiness used to wait 240 s and a request 600 s. Both now wait up to
vllm_server_timeout(1800 s). max_concurrent_rolloutsno longer derives fromper_device_train_batch_size. With OpenEnv / Harbor, the environment server'sMAX_CONCURRENT_ENVSmust be at leastmax_concurrent_rollouts + 1: raise it, or lowermax_concurrent_rollouts. The Harbor example's--max-inflightflag is now--max-concurrent-rollouts.rollout/backpressure_sused to measure time waiting on a full queue. It now measures time waiting on the staleness limit.
Metrics: where AsyncGRPO and GRPO log the same quantity, AsyncGRPO now mostly uses the GRPO name. The async-only metrics keep their namespaces (rollout/, sample/, batch/, perf/, tools/, env/), with one meaning per suffix: _count is a count over the logging window, _s a duration, _per_s a rate, _frac a fraction. Dashboards and scripts that read the old names need the new ones.
| v1.17 (experimental) | v1.18 |
|---|---|
rewards/<func> |
rewards/<func>/mean, plus rewards/<func>/group_std |
reward_std |
reward_group_std (within-group, unlike GRPO's batch-wide reward_std) |
ratio |
sampling/importance_sampling_ratio/{mean,min,max} |
kl (k3 estimate against the sampler) |
removed. sampling/sampling_logp_difference/{mean,max} is GRPO's measure of the same gap, and kl stays free for a reference-model KL |
frac_reward_zero_std |
frac_zero_std_groups (GRPO and RLOO keep frac_reward_zero_std) |
reward_kept |
reward_trained |
rollout/inflight, rollout/inflight_cap |
rollout/concurrency, rollout/concurrency_cap |
rollout/kv_cache_usage |
rollout/vllm_kv_cache_usage_frac |
sample/rollout_queue_size |
rollout/queue_size |
rollout/generated_tok_s |
rollout/generated_tokens_per_s |
perf/forwarded_tok_s_fwd_bwd, perf/forwarded_tok_s_wall_clock, perf/trained_tok_s_wall_clock |
perf/fwd_bwd_forwarded_tokens_per_s, perf/wall_clock_forwarded_tokens_per_s, perf/wall_clock_trained_tokens_per_s |
perf/mfu_fwd_bwd, perf/mfu_wall_clock |
perf/fwd_bwd_mfu, perf/wall_clock_mfu |
sample/dropped_stale_total, batch/dropped_oversize_total, rollout/vllm_retry_total, tools/<name>/call_total, `tools/<na... |
v1.17.1
What's Changed
- Keep a parenthesis inside an LFM2.5 tool-call argument from closing the call by @albertvillanova in #7942
Full Changelog: v1.17.0...v1.17.1
v1.17.0
Features
🔥 Mistral Large 4: fine-tune a 1T-parameter model on one node
TRL now supports mistralai/Mistral-Large-4-1T-A52B: 1T parameters, 52B active. The new LoRA example fine-tunes it with SFTTrainer on a single 8×B300 node, on top of its FP8 weights: the experts are split 8 ways with token dispatch, everything else is sharded across the 8 GPUs at load time by transformers' DistributedConfig, and LoRA trains attention and the dense and shared-expert MLPs.
Measured: 32.7k tokens per step in ~8 s, 142 GiB per GPU, with packing and assistant-only loss on reasoning conversations.
mistral-large4-trl_v7_hq.mp4 |
training_args = SFTConfig(
model_init_kwargs={
"dtype": "auto", # keep the FP8 weights
"distributed_config": DistributedConfig(fsdp_size=8, ep_size=8),
},
packing=True,
assistant_only_loss=True,
...
)
trainer = SFTTrainer(model="mistralai/Mistral-Large-4-1T-A52B", args=training_args, peft_config=LoraConfig(...), ...)assistant_only_loss=True works out of the box: TRL ships a training chat template that matches the released checkpoint's, including its reasoning_effort levels (low, medium, high). Needs transformers>=5.22.0, peft>=0.21.0 and accelerate>=1.15.0.
- Add Mistral Large 4 by @qgallouedec in #8017
- Sync the Mistral Large 4 chat template with the released checkpoint by @albertvillanova in #8018
🎯 Unbiased importance sampling under top-k, top-p and min-p
vLLM normalizes its log-probabilities over the tokens left after top_k, top_p and min_p filtering, while the trainer normalized over the whole vocabulary. Every sampled token's log-ratio was off by the log of the probability mass the filter kept, so the vLLM importance sampling ratio was biased towards 0 (around 1e-4 instead of 1 with top_p=0.9). The trainers now normalize over the candidate set each token was sampled from, following Keep Sampling Mask from DeepSeek-V3.2.
- AsyncGRPO: renormalize log-probs over the top-k/top-p candidate set by @AmineDiro in #7627
- GRPO: renormalize log-probs over the top-k/top-p candidate set (vLLM colocate mode, vLLM >= 0.28; server mode will follow) by @albertvillanova in #7866
- Require
top_kwithmin_pin AsyncGRPO so the importance sampling ratio stays unbiased by @albertvillanova in #7937 - Track the support maximum in the chunked log-prob kernel, so a far-below-max candidate set no longer gives a log-probability of 0 and non-finite gradients, by @kashif in #7983
💥 What this changes for you. vLLM bounds the candidate set it returns with top_k, so with vLLM and the importance sampling correction on (the default), GRPOConfig now raises when top_p < 1.0 or min_p > 0.0 is set without top_k > 0. Set top_k (e.g. top_k=512), or vllm_importance_sampling_correction=False.
⚖️ Score centering is the default AsyncGRPO objective
AsyncGRPO's old log-probs are the vLLM sampler's, so its ratio mixes staleness with the numerical mismatch between the server and the trainer. With an FP8 sampler and a bf16 trainer, the clipped objective collapses: reward goes from 0.60 to 0.34 (FP8 weights) or 0.10 (FP8 weights + KV cache) by step 300, against 0.71 with a bf16 sampler.
Score centering with masked importance sampling is now the default (score_centering=True, importance_sampling_min=0.5, importance_sampling_max=5.0). With it, the FP8 sampler trains exactly like the bf16 one (0.72). It costs 15–20% of generation throughput.
💥 What this changes for you. AsyncGRPO runs now train with a different objective by default, and tokens whose ratio to the sampler falls outside [0.5, 5.0] are dropped. Set score_centering=False to keep the clipped objective.
by @AmineDiro in #7760
🚀 Faster AsyncGRPO rollouts and packing
- Adaptive in-flight cap from the vLLM load: the rollout worker follows the server's KV cache usage instead of admitting a fixed
max_inflight_tasks, so requests stop queueing and being preempted on the server. No new config: everything is read from the server. By @AmineDiro in #7610 - Filter zero-advantage groups (DAPO's dynamic sampling): groups whose rollouts all got the same reward, or none of which could be scored, no longer cost a forward and backward. By @AmineDiro in #7609
- Pack the sampling mask ragged and pad it on the device:
TreeRow.packgoes from 250 s to 31 s on rank 0 over a 15-step run, and from 1040 ms to 66 ms on a 28k-token multi-turn row. By @AmineDiro in #7798 - Keep filling a micro-batch when another row has free room by @clementtisseau in #7793
- Use FlashAttention-4 on Blackwell GPUs in async GRPO and async distillation by @lewtun in #7792
🌳 Tree attention for linear-attention hybrids
Tree packing (v1.16) now supports the Gated DeltaNet hybrids: Qwen3.5, Qwen3.6, Qwen3-Next and OLMo-Hybrid. Since v1.16 the trainer refused them at init; before it, sequence packing accepted them but was silently wrong on them. The causal convolution and the delta-rule recurrence now follow the tree instead of the row, through FLA's chunked kernels.
by @AmineDiro in #7686
🎚️ Precise chunked log-probabilities
The chunked log-probability and KL/JSD heads get the two precision fixes from A Fix for Softmax and Cross-Entropy: confident targets keep their small gradients, and matching teachers produce zero gradients. Entropy-preserving reinforcement learning (Appendix B.4) reports the same high-confidence policy-gradient issue.
- Fix chunked loss precision by @kashif in #7882
- Fix the fused log-prob/entropy backward on strided inputs (shifted views from SFT/DPO) by @winglian in #7890
🔀 X-Token cross-tokenizer distillation in GOLD
GOLDTrainer gets off-policy cross-tokenizer distillation based on X-Token: set lmbda=0.0 and xtoken_loss_type="p_kl" or "h_kl" with a precomputed projection matrix.
- Add X-Token cross-tokenizer KD to GOLD trainer by @kashif in #6126
- Support byte-fallback tokenizers (Gemma) in GOLD byte-offset alignment by @kashif in #8010
🟥 Training on AMD GPUs
TRL's trainers now run on AMD Instinct GPUs through PyTorch's ROCm build, with a guide and an AMD CI job that runs the test suite on every PR.
- Document training on AMD GPUs by @qgallouedec in #7844
- Add AMD/ROCm CI by @kashif in #5918
🧩 More models
- Beam: tiny model, SFT/DPO/GRPO/RLOO tests, GRPO tool calling, and a LoRA SFT example on one 8×B300 node. Needs
transformers>=5.20.1. By @qgallouedec in #7629 - Mistral Medium 3.5: training chat template for assistant-only loss by @qgallouedec in #7940
- LFM2.5-24B-A2B (and LFM2.5-2.6B's current template) for tool calling by @qgallouedec in #7753
- LFM2.5-1.2B-Instruct and LFM2.5-VL-450M for tool calling by @albertvillanova in #7909, #7910 and #7911
- TRL's own Qwen3 training template for response parsing, so a tokenizer saved by assistant-only SFT works in GRPO, by @edbeeching in #8007
Other
- Accept instantiated models in
AsyncGRPOTrainerby @kashif in #6676, and port instantiated models, MoE aux loss and the injected-worker LoRA name toAsyncDistillationTrainerby @kashif in #7984 - Save AsyncGRPO and AsyncDistillation checkpoints in the mixed-precision dtype instead of fp32 by @AmineDiro in #7939
- Back off between unscorable harness sessions and stop the worker when they persist by @albertvillanova in #7992
- Async Harbor GRPO: PEFT support and fixes by @younesbelkada in #7849 and #7948
- Write the logged completions to parquet as JSON by @qgallouedec in #7696
- Add support for vLLM 0.32.0 by @qgallouedec in #7799, and allow its patch releases by @albertvillanova in #7850
Removals and requirement bumps
- Remove the experimental TPO trainer by @qgallouedec in #7807
- **Require
top_kwithtop_p < 1.0or `min...
v1.16.0
Features
🛠️ TRL now trains on AWS Trainium
The fused LM head from v1.15 is what made Neuron tractable; the remaining gaps are closed here. There is a guide to go with it.
Neuron recompiles once per input shape, so an unpadded run stalls about a minute on every new sequence length. pad_to_multiple_of now defaults to "auto": 128 on Neuron, None elsewhere, so nothing changes on GPU. Trainium2, Qwen3-0.6B SFT, 20 steps: 130 s with the default against 260 s without.
- Add a guide for training on AWS Trainium by @qgallouedec in #7729
- Default
pad_to_multiple_ofto"auto"by @qgallouedec in #7724 - Run the fused LM head and distillation kernels on devices without Triton by @qgallouedec in #7669
- Report the Neuron device in
trl envand telemetry by @qgallouedec in #7672 - Support any accelerator in activation offloading by @qgallouedec in #7670
🌳 Tree attention for AsyncGRPO
AsyncGRPO now packs every micro-batch row as a prefix tree instead of a flat sequence. Multi-turn and multi-generation rollouts repeat a lot of prefix: on a shared prompt, those tokens used to be forwarded once per row. Tree packing forwards them once.
rollout 0: [ prompt ] [ completion A ] prompt ──┬── completion A ── later turn
rollout 1: [ prompt ] [ completion B ] => └── completion B
rollout 2: [ prompt ] [ completion A ] [ … ]
Chains without a fork collapse into segments, and each segment's queries attend to the K/V gathered along its root-to-segment path in a single FA3 varlen call. No mask tensor: every layer except attention runs once per unique token, and only K/V is duplicated along shared prefixes.
Qwen3-1.7B, 32K tokens per rollout, forward + backward:
| layout | packing ratio | sequence packing | tree packing | peak GiB |
|---|---|---|---|---|
| shared prompt | 1.00 | 8677 ms | 8737 ms (0.99×) | 35.2 → 35.2 |
| shared prompt | 2.29 | 8266 ms | 4341 ms (1.90×) | 35.2 → 18.0 |
| shared prompt | 3.37 | 8179 ms | 2755 ms (2.97×) | 35.2 → 13.6 |
| nested fork | 1.60 | 8557 ms | 6217 ms (1.38×) | 35.2 → 23.8 |
| nested fork | 3.56 | 8172 ms | 2635 ms (3.10×) | 35.2 → 13.5 |
There is no packing option to choose: with nothing shared a tree row is exactly the old sequence packing, at a ~1% cost.
by @AmineDiro in #7328
Muse Spark Open
Support for meta-models/Muse-Spark-Open-816B-A42B: the tiny-model script, coverage in the VLM tests (SFT, DPO, KTO, chat-template utils, fused LM head), and a LoRA SFT example on 8 nodes of 8×H100 with DistributedConfig(fsdp_size=64, ep_size=8), token dispatch and packing. Measured at 14.2 s/step, 131k tokens/step, 40.2 GB per GPU.
Needs transformers>=5.20.0; the adapter save additionally needs transformers#49500 with peft 0.21.2.
by @qgallouedec in #7536
AMD GPUs in the async trainers
- Support AMD GPUs in the async GRPO and async distillation trainers by @Abdennacer-Badaoui in #7689
- Hide the GPU from the async rollout worker on ROCm by @Abdennacer-Badaoui in #7685
Tool-call arguments typed by the tool's JSON schema
parse_response now receives the tools, so tool-call arguments come back typed from the tool's own schema instead of whatever the raw parse produced.
by @qgallouedec in #7650
Other
- Async GRPO tool metrics by @AmineDiro in #7624
- Store async GRPO and distillation rollout sample tokens as numpy arrays by @AmineDiro in #7626
- Save the final step when async trainers stop at
num_train_epochsby @lewtun in #7628 - Pass sequence boundaries from the padding-free collator by @qgallouedec in #7599
- Build the reference model with the policy's dtype and attention implementation by @qgallouedec in #7597, and the SDFT/SDPO teacher with the student's by @qgallouedec in #7616
- Find unused parameters under DDP for vision-language models by @qgallouedec in #7598
- Pad the generation prompts to
pad_to_multiple_ofby @qgallouedec in #7671 - Drop the client-side observe loop from the CARLA examples by @sergiopaniego in #7721
- Use
Nonefor unscoredenv.rewardin OpenReward by @albertvillanova in #7541
Removals and requirement bumps
- Remove the experimental SSD trainer by @qgallouedec in #7706
- Refuse
nn.DataParallelinRewardTrainerby @albertvillanova in #7571 - Drop vLLM 0.21.0 support by @qgallouedec in #7700
- Require
accelerate>=1.10.1and drop theParallelismConfigshim by @albertvillanova in #7643 - Declare a minimum bitsandbytes version by @albertvillanova in #7641
- Declare the direct dependencies TRL gets transitively by @albertvillanova in #7713
Fixes
- Fix silently wrong
torch.compileresults in the Triton loss kernels on torch < 2.11.torch_compile=Truetrained withloss=0.0andgrad_norm=nanat every step. Inductor passes scalar kernel args asconstexprbefore torch 2.11, the.to(tl.float32)casts raised on those, and Inductor then assumed every input was mutated and miscompiled. By @albertvillanova in #7688 - Fix FSDP2 vLLM colocate weight sync for tied-embedding models by @Abdennacer-Badaoui in #7647
- Prevent VLM policies from generating the image placeholder token in GRPO, RLOO and Distillation by @albertvillanova in #7695
- Fix Online DPO VLM training when the prompt exceeds
max_length(#7703) and for processors with 5D pixel values (#7704), both by @albertvillanova - Fix activation offloading on torch < 2.4 by @albertvillanova in #7748
- Fix
torch.compile(fullgraph=True)ofselective_log_softmax_and_entropyon torch 2.6 by @albertvillanova in #7719 - Keep the Triton loss kernels in fp32 under
torch.compileby @qgallouedec in #7600 - Read
is_triton_availableonce in the fused LM head kernels so Dynamo does not warn by @qgallouedec in #7731 - Fix Distillation for models split across devices by @albertvillanova in #7573
- Restore the gradient checkpointing kwargs after generation by @qgallouedec in #7668
- Drop the FlashAttention warnings for padding-free and packing in SFT by @qgallouedec in #7620
- Restore the distributed env vars that vLLM colocate tests leave behind by @Abdennacer-Badaoui in #7723
Clearer errors
A sweep making failure modes explicit instead of crashing deep in the stack, all by @albertvillanova:
- Raise a clear error when the fused LM head is used without Triton (#7639)
- Raise a clear error for prefix tuning on peft versions that cannot support it (#7646)
- Raise a clear error when the Distillation student and teacher heads are on different devices (#7605)
- Reject a text-only teacher in GOLD VLM distillation instead of crashing (#7581)
- Name the missing vLLM server setting when the server cannot serve TRL (#7611)
- Raise early for
use_kernelswith transformers 5.2.0 and 5.3.0 (#7577), and if kernels is installed with transformers 5.3.0 in the tiny NemotronH scripts (#7575)
Documentation
- Add a guide for training on AWS Trainium by @qgallouedec in #7729
- Add guidance on testing through the public API to the contributing guide and agent instructions by @albertvillanova in #7606
- Document the criterion for raising a dependency version floor by @albertvillanova in #7638
CI
Real objects, not mocks. The bulk of this cycle, applying the repo's testing rule across the suite, all by @albertvillanova: run the GRPO entropy mask tests on a real trainer instead of a Mock (#7566), the teacher logprob tests on a real trainer instead of a MagicMock (#7579), build real GOLD trainers in the init (#7582), input preparation (#7614), on-policy generation (#7613, #7615), output decoding (#7633), ULD helper (#7634) and no-backend tokenizer (#7635) tests, check GOLD dataset preparation through the trainer (#7632), and build real async trainers in the rollout state checkpoint tests (#7583)
Coverage, all by @albertvillanova: test SFT (#7552) and DPO/KTO/Reward/GRPO/RLOO (#7601) on a model ...
v1.15.0
Features
⚡ Fused LM head: up to 6.9× longer sequences on the same GPU
SFT, DPO, KTO, GRPO, RLOO and Distillation now score tokens with a fused LM head: a Triton kernel projects the hidden states through the LM head in tiles and reduces to per-token log-probs and entropy directly, so the [batch, seq, vocab] logits tensor is never built. It is on by default, there is nothing to turn on.
Max trainable sequence length (gemma-3-1b, 262k vocabulary, 79 GiB of GPU memory, bf16, batch size 1, gradient checkpointing, sdpa):
| Trainer | v1.14.2 | v1.15.0 | |
|---|---|---|---|
| DPO | 10,240 | 59,392 | 5.80× |
| KTO (batch size 2) | 9,216 | 63,488 | 6.89× |
| GRPO (scoring only) | 28,672 | 114,688 | 4.00× |
| RLOO (scoring only) | 23,552 | 100,352 | 4.26× |
SFT (loss_type="nll") |
20,480 | 107,520 | 5.25× |
SFT (default chunked_nll) |
107,520 | 107,520 | 1.00× |
At 8,192 tokens, peak memory drops 52% to 82% and steps are 2.3% to 10.9% faster:
| Trainer | Peak GiB v1.14.2 → v1.15.0 | Tokens/s |
|---|---|---|
| DPO | 48.97 → 12.00 (-75.5%) | 1.035× |
| KTO | 64.91 → 11.98 (-81.5%) | 1.045× |
| GRPO | 24.15 → 10.30 (-57.4%) | 1.023× |
| RLOO | 29.28 → 14.02 (-52.1%) | 1.029× |
SFT (nll) |
30.33 → 8.87 (-70.7%) | 1.029× |
The gain is largest for small models with large vocabularies. SFT's previous default (chunked_nll) already avoided full logits, so it is unchanged. Scoring needs Triton on a GPU (Linux with CUDA, ROCm or XPU).
💥 What this changes for you. The full-logits scoring path, the use_liger_kernel chunked path and _forward_redirection are gone from GRPO, RLOO, DPO and KTO:
- A PEFT adapter on
lm_headnow raises. Usemodules_to_save=["lm_head"]instead. use_liger_kernel=Trueis deprecated in these four trainers and will be removed in v2.0.0. Liger's layer kernels still apply, butfused_linear_cross_entropyis forced toFalse(it would replace the fused head) and setting it explicitly raises. Usemodel_init_kwargs={"use_kernels": True}.- In DPO and KTO,
compute_metricsandcompute_loss(..., return_outputs=True)still receive the full logits, from an extra forward pass taken only when they are used. Both warn that this is deprecated and will be removed in v2.0.0.
Nothing else the trainers logged is lost: the kernel gained log_sum_sq_probs (WPO weighting), mean_logits (logits/chosen, logits/rejected) and is_top1 (DPO's mean_token_accuracy) as opt-in outputs, each checked against the full logits in tests.
Benchmark details
1× B300 with the PyTorch allocator capped at 79 GiB (about an H100 80GB's usable memory), google/gemma-3-1b-pt built from its config with random bf16 weights, lr 1e-6, AdamW, synthetic token ids at exact length. Max length: one fresh process per attempt, 2 training steps, doubling from 8k then bisection to 1024 tokens, arms interleaved round-robin in the same job. Throughput: 12 steps, first 2 discarded, median of 3 A/B/A/B repeats in the same job. Noise floor (A vs A) is 0.1% to 0.8%, below every gap reported. GRPO/RLOO replace generation with fixed random completions, so only scoring is measured.
Not measured: H100 hardware itself, flash-attention (sdpa only), real generation, multi-GPU.
- Compute the chunked log-probabilities with a Triton kernel by @qgallouedec in #7386
- Add an opt-in fused LM head to the patched forward by @qgallouedec in #7387
- 💥 Score GRPO and RLOO tokens with the fused LM head by @qgallouedec in #7389
- 💥 Score DPO and KTO tokens with the fused LM head by @qgallouedec in #7390
- Score SFT tokens with the fused LM head by @qgallouedec in #7466
- Compute the distillation divergence with a Triton kernel by @qgallouedec in #7465
- Compute only the requested fused LM head outputs by @qgallouedec in #7406
- Rename
patch_fused_lm_headtoadd_fused_lm_headby @qgallouedec in #7415 - Honor
logits_scalingandlm_head_multiplierin the fused LM head by @YaseenBashaT in #7439 - Fix the fused LM head for models split across devices by @albertvillanova in #7479
Selective activation checkpointing in SFT
With gradient checkpointing on, the attention output is now saved during the forward instead of being recomputed in the backward, recovering most of the checkpointing slowdown at long context for one extra hidden-state-sized tensor per layer. Same eager SAC approach torchtitan uses under FSDP2, no torch.compile needed.
SFTConfig(
gradient_checkpointing=True,
gradient_checkpointing_kwargs={"selective": True},
)PEFT + DeepSpeed ZeRO-3 is rejected: that combination needs reentrant checkpointing, which SAC cannot use.
Assistant-only loss on vision datasets in SFT
assistant_only_loss=True now works on vision datasets. SFTTrainer used to refuse it because processors did not return usable assistant masks once image placeholders were expanded; transformers#48793 fixed that, and it ships in transformers 5.18.
SFTConfig(assistant_only_loss=True) # now fine with an image datasetThe vision collator tokenizes conversational examples through the processor's apply_chat_template and requests the assistant masks to mask non-assistant tokens in the labels. Older transformers still raises, now with the required version in the message.
by @albertvillanova in #7377
Conversations in the completions table
Prompts and completions are logged as raw conversation lists instead of batch_decode'd flat strings, so the table renders turn by turn. Much more readable for multi-turn and tool-calling setups, and for VLMs.
The rendered system prompt (including tool definitions injected by the chat template) is no longer visible, since the original messages are shown rather than the fully-templated string.
by @qgallouedec in #5309
AsyncGRPO and AsyncDistillation
- AsyncGRPO: train OpenEnv harnesses from validated token captures by @adithya-s-k in #6947
- Add PEFT support to
AsyncDistillationTrainerby @kashif in #7476 - Fix duplicate completions in AsyncGRPO groups with data-parallel vLLM by @lewtun in #7549
Other
- Add SmolVLM original and training chat template with generation markers by @aazizyan in #5868
- Declare gradient accumulation loss scaling with
loss_is_scaled_for_gaby @qgallouedec in #7508 - Keep SFT's MoE aux loss independent of world size and gradient accumulation by @qgallouedec in #7570
- Discover environment tools on the class, not the instance by @Rome-1 in #7360
- Accept an IPv6
base_urlinVLLMClientby @qgallouedec in #7462 - Pass processor kwargs via
processor_kwargsin the VLM SFT collator by @qgallouedec in #7547 - Call
trainer.end()at the end of the scripts and examples by @qgallouedec in #7384 - Install vLLM in the TRL Docker images by @qgallouedec in #7464
- Train harnesses through Harbor: drop the standalone opencode example by @sergiopaniego in #7457
- Add support for vLLM 0.31.0 by @qgallouedec in #7567
Breaking changes and removals
- Drop Python 3.10 support by @qgallouedec in #7497
- Refuse
nn.DataParallel(and drop the multi-GPU slow test job) by @qgallouedec in #7407 - Remove the experimental MiniLLM trainer by @qgallouedec in #7500
use_liger_kernelis deprecated inDPOTrainer,KTOTrainer,GRPOTrainerandRLOOTrainerand will be removed in v2.0.0. These trainers now use the fused LM head, so only Liger's layer kernels apply; usemodel_init_kwargs={"use_kernels": True}instead. Docs updated by @qgallouedec in #7535- Drop vLLM 0.20.0 / 0.20.1 / 0.20.2 support by @qgallouedec in #7435, #7499 and #7568
- Remove the unreachable
prepare_multimodal_messages_vllmby @behroozazarkhalili in #6946
Fixes
- Fix chat template drift: recognize the current LFM2 (#7494) and LFM2.5 (#7493) chat templates, the other Gemma 4 revisions (#7495), parse the current LFM2 tool calls (#7522), and read templates shipped as named variants by their default variant (#7530), all by @albertvillanova
- **Fix
SFTTrainernot appending EOS when `data...
v1.14.2
Patch release fixing two cases of silently wrong training and three crashes.
Worth calling out: #7505 affects GRPO, RLOO and Distillation on the default generation path (use_vllm=False). Models that end a turn with an id only their generation config declares (Gemma 3/4, Phi-3.5, ...) did not stop at the end of the turn, and everything generated after it was trained on, up to max_completion_length. The only visible sign was completions/clipped_ratio close to 1. With vLLM, generation stopped correctly but the metrics were still wrong, and mask_truncated_completions=True dropped every finished completion. Runs on models whose tokenizer eos is their only end-of-turn id are unchanged.
What's Changed
- Keep the DFT loss finite on a batch with no trainable tokens by @albertvillanova in #7471
- Fix
precompute_ref_log_probsunder FSDP with no reference model by @qgallouedec in #7507 - Fix: Start the completion where the tokenized prompt and prompt+completion diverge by @qgallouedec in #7463
- End completions on every eos id the model declares in GRPO, RLOO and Distillation by @albertvillanova in #7505
- Guard the requests and urllib3 imports in the vLLM client by @qgallouedec in #7545
Full Changelog: v1.14.1...v1.14.2
v1.14.1
What's Changed
- Fix the server-mode crash at the first weight sync on vLLM 0.20 to 0.25 by @albertvillanova in #7410
- [Fix] Generate one completion per sample after tool calls in vLLM server mode by @qgallouedec in #7418
- Preserve explicit model_init_kwargs in CLI scripts by @DaoyuanLi2816 in #7394
- Honor resume_from_checkpoint in CLI scripts by @DaoyuanLi2816 in #7391
Full Changelog: v1.14.0...v1.14.1