Repository navigation
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 checkpointing names in the docs (#8114) and examples (#8117), and the stable
DistillationTrainerAPI everywhere (#8293), by @qgallouedec - Add Albert Villanova del Moral and Sergio Paniego Blanco to the TRL citation by @qgallouedec in #8335
- Document that assigned issues belong to their assignee by @albertvillanova in #8534
CI
Flash Attention compatible tiny models, all by @albertvillanova: Gemma3, Mistral Large 4, GLM-5.3-Flash, Remote, Phi-3, Phi-3.5, LFM2, LFM2.5, LFM2.5-MoE, LFM2.5-VL, Qwen2-VL, Qwen3-VL, LLaVA-NeXT, Idefics2, Idefics3, InternVL, Granite 4.0 hybrid, GPT-2, OPT, GPT-NeoX, Bart and Muse Glimmer (#8319, #8320, #8321, #8380, #8381, #8382, #8409, #8410, #8411, #8435, #8436, #8437, #8446, #8478, #8479, #8480, #8481, #8482, #8487, #8488, #8489, #8536, #8537), the Qwen3 models at head_dim=16, the smallest vLLM allows (#8415, #8416, #8417), and fallbacks for the models that refuse it (#8399, #8401, #8402, #8403, #8404)
Tiny models, all by @albertvillanova: pin every tiny model to a Hub commit (#8262, #8264, #8531, #8539), FP8 checkpoints laid out like their references for GLM-5.3-Flash and Mistral3 (#8227, #8298), and new tiny Qwen3-Coder and Qwen3-Coder-Next (#8449, #8544)
Tests that run what users run: AsyncGRPO tests on GRPO's layout (#8146), tools and environments tested through what the user sees (#8251), adapter sync on the stand-in server (#8368), prompt tuning settings (#8557) and consistent test ids (#8563) by @qgallouedec; tiny Qwen3 in the vLLM tests (#8297), tiny models in the async tests (#8470), an MoE teacher in the distillation tests (#8492), conversational data and reward functions in the router and packing tests (#8336, #8337, #8338), AsyncGRPO fp16 (#8421), RewardTrainer with prompt learning (#8485) and the Qwen3-Coder tool-call tests (#8515, #8545) by @albertvillanova
Other, all by @albertvillanova: run the OpenEnv harness tests in the experimental CI (#8036), skip experimental tests on draft PRs (#8301), post chat template checks to Slack only from main (#8408), time out test steps after 60 minutes (#8422), report tests that raise peak host memory by 2 GB or more (#8442), stand-in vLLM server fixes (#8379, #8430), chat template tests (#8312, #8570), test fixes (#8261, #8265, #8407, #8448), warning filters (#8392, #8395, #8396, #8397, #8543), plus dependency bumps by @dependabot[bot] (#8374, #8519)
New Contributors
- @erdogan-deniz made their first contribution in #8459
Full Changelog: v1.18.0...v1.19.0