Skip to content

Releases

v1.19.0

Choose a tag to compare

@qgallouedec qgallouedec released this 25 Nov 17:28
39c749e
image

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"
)

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

⚡ 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:

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_of with 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_ID and add the hardware flavor to the model card by @davanstrien in #8576
  • Load the processing class in OnlineDPOTrainer when 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. Documented vllm serve commands 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 prefix a required argument of parse_response by @qgallouedec in #8458
  • Require peft>=0.18.0 and drop the peft 0.17 compatibility code by @albertvillanova in #8426
  • Require accelerate>=1.12.0 and drop the older accelerate fallbacks by @albertvillanova in #8542
  • Default ModelConfig.model_revision to None like 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 with top_k or top_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>\n out of the DeepSeek-V3 (#8313) and DeepSeek-R1-Distill (#8314) assistant-only loss, and its \n out of Qwen2.5's (#8279), by @albertvillanova
  • Fix BEMACallback when some parameters are frozen by @qgallouedec in #8455
  • Keep the environment column in GRPO when remove_unused_columns=True by @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.array before making tensors in GRPO, RLOO and Distillation by @albertvillanova in #8394
  • Render None content 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-count from 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) and max_tool_calling_iterations (#8464) with tools, the sessions environment_factory opens 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 ...
Read more

v1.18.2

Choose a tag to compare

@albertvillanova albertvillanova released this 19 Nov 17:05
c7caa02

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

Choose a tag to compare

@albertvillanova albertvillanova released this 17 Nov 12:21
d54cd97

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

Choose a tag to compare

@AmineDiro AmineDiro released this 13 Nov 15:37
480dde9
TRL v1 18 motorcycle release

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, AsyncGRPOTrainer

The 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 4096

Then 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_factory and multi-turn rollouts.
  • Score centering with masked importance sampling as the default objective (score_centering=True). score_centering=False gives 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_p or min_p, set top_k > 0 and the trainer normalizes its log-probs over the candidate set vLLM sampled from.
  • LoRA adapter sync: start vLLM with --enable-lora and each weight sync sends only the adapter (about 160 MB at r=32) instead of merged weights.
  • Custom rollout loops: subclass AsyncRolloutLoop, override filter_prompt, generate_one, generate_one_turn, compute_advantages, setup or close, and set it as loop_cls on 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 plain vllm serve.
  • rollout_worker= is removed. To change how rollouts are produced, subclass AsyncRolloutLoop and set loop_cls (see above).
  • For OpenEnv / Harbor, HarnessAsyncGRPOTrainer replaces building a HarnessRolloutWorker yourself and passing it as rollout_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_rollouts no longer derives from per_device_train_batch_size. With OpenEnv / Harbor, the environment server's MAX_CONCURRENT_ENVS must be at least max_concurrent_rollouts + 1: raise it, or lower max_concurrent_rollouts. The Harbor example's --max-inflight flag is now --max-concurrent-rollouts.
  • rollout/backpressure_s used 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...
Read more

v1.17.1

Choose a tag to compare

@albertvillanova albertvillanova released this 30 Oct 14:15
44809ba

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

Choose a tag to compare

@albertvillanova albertvillanova released this 29 Oct 15:51
e257382
TRL v1 17 meets Le Chonk

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.

🎯 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_k with min_p in 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.pack goes 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.

🧩 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

Removals and requirement bumps

  • Remove the experimental TPO trainer by @qgallouedec in #7807
  • **Require top_k with top_p < 1.0 or `min...
Read more

v1.16.0

Choose a tag to compare

@qgallouedec qgallouedec released this 15 Oct 18:00
1b5c75e

Features

🛠️ TRL now trains on AWS Trainium

Neon Warehouse_ AWS and Trainium Support

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.

🌳 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

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

Removals and requirement bumps

Fixes

  • Fix silently wrong torch.compile results in the Triton loss kernels on torch < 2.11. torch_compile=True trained with loss=0.0 and grad_norm=nan at every step. Inductor passes scalar kernel args as constexpr before 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) of selective_log_softmax_and_entropy on torch 2.6 by @albertvillanova in #7719
  • Keep the Triton loss kernels in fp32 under torch.compile by @qgallouedec in #7600
  • Read is_triton_available once 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_kernels with 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

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

Read more

v1.15.0

Choose a tag to compare

@qgallouedec qgallouedec released this 08 Oct 19:26
dae7b6a
Neon-Gripped Industrial Valve

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_head now raises. Use modules_to_save=["lm_head"] instead.
  • use_liger_kernel=True is deprecated in these four trainers and will be removed in v2.0.0. Liger's layer kernels still apply, but fused_linear_cross_entropy is forced to False (it would replace the fused head) and setting it explicitly raises. Use model_init_kwargs={"use_kernels": True}.
  • In DPO and KTO, compute_metrics and compute_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.

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.

by @kashif in #7194

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 dataset

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

Completions table rendered turn by turn

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 AsyncDistillationTrainer by @kashif in #7476
  • Fix duplicate completions in AsyncGRPO groups with data-parallel vLLM by @lewtun in #7549

Other

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_kernel is deprecated in DPOTrainer, KTOTrainer, GRPOTrainer and RLOOTrainer and will be removed in v2.0.0. These trainers now use the fused LM head, so only Liger's layer kernels apply; use model_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_vllm by @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 SFTTrainer not appending EOS when `data...
Read more

v1.14.2

Choose a tag to compare

@qgallouedec qgallouedec released this 06 Oct 20:30

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_probs under 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

Choose a tag to compare

@AmineDiro AmineDiro released this 29 Sep 13:41

What's Changed

Full Changelog: v1.14.0...v1.14.1