展开/收起原文英文摘要对照(用于核验原始措辞与数字)
## 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](https://huggingface.co/papers/2606.30406). It also takes `environment_factory`, with the same contract as `GRPOTrainer`, so agents can be distilled against stateful environments.
```python
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 `DistillationTrainer` by @cmpatino in https://github.com/huggingface/trl/pull/7215
* Add `environment_factory` support to `DistillationTrainer` by @sergiopaniego in https://github.com/huggingface/trl/pull/8453
### 🕐 Inkling 2 Mini
Support for [`thinkingmachines/Inkling-2-Mini`](https://huggingface.co/thinkingmachines/Inkling-2-Mini): coverage in the VLM tests and an [example](https://github.com/huggingface/trl/tree/main/examples/sft_inkling_2_mini_clocks) 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 https://github.com/huggingface/trl/pull/8517
* Add a tiny Inkling 2 model and run it in the VLM tests by @qgallouedec in https://github.com/huggingface/trl/pull/8498
* Add a tiny Inkling model by @albertvillanova in https://github.com/huggingface/trl/pull/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 https://github.com/huggingface/trl/pull/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 https://github.com/huggingface/trl/pull/8457
* **LFM in tree attention** by @younesbelkada in https://github.com/huggingface/trl/pull/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 https://github.com/huggingface/trl/pull/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 https://github.com/huggingface/trl/pull/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 https://github.com/huggingface/trl/pull/8330
* Support `pad_to_multiple_of` with vision-language models in SFT, DPO and KTO, which fixes VLM training on Trainium, by @albertvillanova in https://github.com/huggingface/trl/pull/8553
* Raise in AsyncGRPO when a whole pass over the prompts drops every group, instead of hanging, by @albertvillanova in https://github.com/huggingface/trl/pull/8425
* Add an s3 multi-agent aggregation example (held-out team success 4.7% → 60.9%) by @kashif in https://github.com/huggingface/trl/pull/8424
* Detect HF Jobs via `HF_JOB_ID` and add the hardware flavor to the model card by @davanstrien in https://github.com/huggingface/trl/pull/8576
* Load the processing class in `OnlineDPOTrainer` when it is omitted by @behroozazarkhalili in https://github.com/huggingface/trl/pull/7519
* Add Python 3.15 to the test matrix and the classifiers by @qgallouedec in https://github.com/huggingface/trl/pull/7498
### Removals and requirement bumps
* **Add support for vLLM 0.34.x**, so the range is `vllm>=0.23.0, =0.18.0` and drop the peft 0.17 compatibility code by @albertvillanova in https://github.com/huggingface/trl/pull/8426
* Require `accelerate>=1.12.0` and drop the older accelerate fallbacks by @albertvillanova in https://github.com/huggingface/trl/pull/8542
* Default `ModelConfig.model_revision` to `None` like the other revision arguments by @albertvillanova in https://github.com/huggingface/trl/pull/8530
* Follow the transformers 5.23 rename of gradient checkpointing to activation checkpointing by @qgallouedec in https://github.com/huggingface/trl/pull/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 https://github.com/huggingface/trl/pull/8269
* **Stop pasting a fake tool call before every tool result** when the eos is ` `, as in Unsloth's Gemma 4 tokenizers (#8521), **and repeating GLM's ` `** (#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 https://github.com/huggingface/trl/pull/8573
* **Fix AsyncGRPO score-centering tail ratios and sampler validation** by @kashif in https://github.com/huggingface/trl/pull/8373 and https://github.com/huggingface/trl/pull/8414
* Keep the generation prompt's ` \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 https://github.com/huggingface/trl/pull/8455
* Keep the `environment` column in GRPO when `remove_unused_columns=True` by @qgallouedec in https://github.com/huggingface/trl/pull/8520
* Load a reward model given by name without the policy's revision by @albertvillanova in https://github.com/huggingface/trl/pull/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 https://github.com/huggingface/trl/pull/8484
* Convert nested image arrays with `np.array` before making tensors in GRPO, RLOO and Distillation by @albertvillanova in https://github.com/huggingface/trl/pull/8394
* Render `None` content as empty text in the GLM-4-MoE training template by @albertvillanova in https://github.com/huggingface/trl/pull/8454
* Skip torch's sparse invariant checks for GOLD's X-Token projection matrix by @albertvillanova in https://github.com/huggingface/trl/pull/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 https://github.com/huggingface/trl/pull/8271
* Compare version checks against plain release versions, not .dev0, by @qgallouedec in https://github.com/huggingface/trl/pull/8256
* Drop `--api-server-count` from the AsyncGRPO adapter-sync command, which vLLM rejects, by @sergiopaniego in https://github.com/huggingface/trl/pull/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 https://github.com/huggingface/trl/pull/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 checkpointing names in the docs (#8114) and examples (#8117), and the stable `DistillationTrainer` API everywhere (#8293), by @qgallouedec
* Add Albert Villanova del Moral and Sergio Paniego Blanco to the TRL citation by @qgallouedec in https://github.com/huggingface/trl/pull/8335
* Document that assigned issues belong to their assignee by @albertvillanova in https://github.com/huggingface/trl/pull/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 https://github.com/huggingface/trl/pull/8459
**Full Changelog**: https://github.com/huggingface/trl/compare/v1.18.0...v1.19.0