Features
Training beyond 1M tokens
A new long-context guide plus a runnable example that trains a book-length sequence per step on a single 8×H100 node.
Measured: Qwen3-8B at 1,048,576 tokens, 380 s/step, 56.2 GB per GPU (bf16, per_device_train_batch_size=1, loss_type="chunked_nll"). Runs end to end and saves. The guide documents the levers in the order you hit them (chunked_nll, gradient-checkpointing offload, YaRN RoPE) and the constraints (full attention only, no packing). Needs transformers >= 5.16 for checkpointing offload.
- Document 1M-token training and add a context-parallelism example by @qgallouedec in #6846
- Rewrite the long context guide by @qgallouedec in #7003
Chunked-CE lm_head projection now runs on tensor cores
The inner loop of the default loss_type="chunked_nll" was doing h.float() @ w.float().t(). Both operands are already bf16, so the upcast bought no information: it moved the GEMM off the tensor cores onto the fp32 SIMT path and materialized an fp32 copy of the whole lm_head weight (2.03 GB for a 248k vocabulary), rebuilt for every chunk and again on every gradient-checkpoint recompute. In an 8×H100 profile of trl sft on Qwen3.6-35B-A3B those two fp32 SIMT GEMMs were 21.6% of all GPU kernel time.
One chunk, 256 tokens × vocab 248,320 × hidden 2048, 1×H100, bf16, fwd+bwd:
| fwd+bwd | peak mem | |
|---|---|---|
| before | 23.37 ms | 5.99 GB |
| after | 3.86 ms (6.0×) | 3.03 GB |
End to end, 16,384 tokens per step, tokens/s/GPU:
| model | mode | before | after | |
|---|---|---|---|---|
| gemma-3-270m (vocab 262k) | full FT, 1×H100 | 24036 | 31609 | 1.32× |
| Qwen3-0.6B (vocab 152k) | full FT, 1×H100 | 21276 | 26641 | 1.25× |
| Qwen3-8B | full FT, 2×H100 FSDP2 | 3554 | 6009 | 1.69× |
| Qwen3-8B | LoRA r16, 2×H100 FSDP2 | 4531 | 7125 | 1.57× |
| Qwen3-30B-A3B (MoE) | LoRA attn, 2×H100 FSDP2 | 4251 | 5101 | 1.20× |
Same fix applied to the distillation trainers (which paid it twice per chunk, student and teacher). Under accelerate mixed precision the numerics are bit-identical (autocast was already casting the operands back down); without autocast over the projection the GEMM moves to bf16 tensor cores, which is exactly what loss_type="nll" already does.
by @qgallouedec in #6863
Fused linear losses vendored into trl.losses
TRL's only import from liger-kernel was liger_kernel.chunked_loss (the fused linear DPO / KTO / GRPO / JSD losses). That module is pure PyTorch, and most of the GRPO and DPO variants in it were written for TRL. Upstream reviews had stalled, so the code comes home as trl.losses: FusedLinearDPOLoss, FusedLinearKTOLoss, FusedLinearGRPOLoss, FusedLinearJSDLoss (copied from Liger-Kernel v0.8.2, BSD-2 notice kept, bitwise identical to the installed Liger on random inputs).
No new config flag: use_liger_kernel=True keeps selecting the fused loss exactly as before, and still needs liger-kernel installed because transformers' Trainer patches the model kernels with it.
- Vendor the fused linear losses from Liger-Kernel into
trl.lossesby @qgallouedec in #7059 - Fix DPO and KTO Liger loss gaps by @kashif in #7062
- Harden chunked log probabilities by @kashif in #7065
- Drop fused JSD from
DistillationTrainerby @kashif in #7064 - Test liger vs non-liger GRPO loss parity by @kashif in #6814
- Run the vendored loss parity suites as slow tests only by @qgallouedec in #7067
Contributor skills at .agents/skills
Agent skills for contributing to TRL now ship in the repo at .agents/skills.
by @qgallouedec in #6901
Docs: stable vs experimental taxonomy, and how to change the objective
- Split the docs taxonomy into stable and experimental trainers by @qgallouedec in #7022
- Document how to change the training objective by subclassing a trainer by @sergiopaniego in #6918
- Document how to choose and pin a Hub kernel version by @albertvillanova in #6998
- Add missing TRL blog posts to the docs landing page by @qgallouedec in #7023
QLoRA on the quantization_config argument
The QLoRA test suites move onto the quantization_config trainer argument added in v1.8, and gain coverage on the VLM paths.
- Add a QLoRA test to the GRPO and RLOO VLM test suites by @albertvillanova in #6909
- Add a QLoRA test to the trainers that support
quantization_configby @albertvillanova in #6910 - Convert the QLoRA tests to the
quantization_configtrainer argument by @albertvillanova in #6927
Dependency floors raised
- Require
peft>=0.13.0and drop the 0.12 version guards by @qgallouedec in #7102 - Require
deepspeed>=0.18.6and drop the 0.16.4 guard by @albertvillanova in #7118 - Guard
target_parametersuse forpeft<0.17.0by @albertvillanova in #7119 - Add support for vLLM 0.28.0 by @qgallouedec in #7001
- Drop vLLM 0.19.0 support by @qgallouedec in #7002
Other
- Count each token once in
num_tokensunder tensor parallelism by @qgallouedec in #7101 - XPO / NashMD perf: avoid
output_hidden_stateswhen onlylast_hidden_stateis used by @ciaoyizhen in #4755 - Sync the model config pad token id with the tokenizer in the trainers by @albertvillanova in #7097 and (experimental) #7128
- Forward model revision to the auto-loaded
processing_classby @kashif in #6978 - Inject the model revision into concrete config loads too by @albertvillanova in #7099
- Match hub kernels by repo id when checking the attention implementation by @albertvillanova in #6985
- Catch
AsyncDistillationTrainerup with recent AsyncGRPO changes by @kashif in #6823 and #6987 - Remove the leftover
dataset_formattingmodule by @albertvillanova in #7117 - Remove the unused
FLASH_ATTENTION_VARIANTSconstant from the DPO trainer by @albertvillanova in #7013 - Document that padding-free is temporarily unavailable in DPO by @albertvillanova in #7014
- Realign duplicated comments across the trainers by @qgallouedec in #7145
Breaking
⚠️ PPO is removed
PPOTrainer, PPOConfig, and modeling_value_head.py (PreTrainedModelWrapper, AutoModelForCausalLMWithValueHead, AutoModelForSeq2SeqLMWithValueHead) are gone, along with their tests, doc page, and examples.
Bit of a moment for TRL: PPOTrainer predates every PR in this repo. It landed in dfb6a580 on 2020-03-28, the commit that first added the library, back when the package was called lm_ppo. It was the oldest thing in TRL and the last piece of the original codebase.
Why now: unmaintained (no feature work in over a year, every PPO commit since #4482 a drive-by fix), the only trainer never aligned on the input format (it still took tokenized input_ids), near-zero recorded usage, and a magnet for automated bug hunters filing real reports against code nobody runs. Nobody loses anything: from trl import PPOTrainer already stopped working in v1.10, so anyone actually running PPO is pinned to an older TRL and those installs keep resolving exactly as they do today.
create_reference_model stays (BCO, A2PO and Online DPO use it).
by @qgallouedec in #7020
Fixes
- Fix missing entropy gradient in
_ChunkedLogProbFunctionbackward —backwardacceptedgrad_entropybut never used it, so any loss backpropagating through theentropyoutput silently got zero gradient from that term, with no error or warning. OnlyAsyncGRPOTrainerreadentropy(underno_grad, for logging), so no user-facing regression today, but this is exported non-experimental code and an entropy-bonus loss term would have hit it silently. By @verma8076 in #6625 - vLLM weight sync now fails instead of hanging by @AmineDiro in #6913
- Fail fast on incompatible vLLM for default Async GRPO weight transfer by @DimensionSTP in #6830
- Fix VLM support in AsyncGRPO by @AmineDiro in #6839
- Fix variable reference in BCO docs by @albertvillanova in #7046
- Fix the IW-OPD self-distillation loss assertion in tests by @albertvillanova in #7123
- Fix typos in help strings and error messages by @qgallouedec in #7146
- Fix two messages that describe the wrong behaviour by @qgallouedec in #7147
- Fix three broken doc links by @qgallouedec in #7155
- Fix the example commands in the script docstrings by @qgallouedec in #7156
- Correct what the TRL Docker image provides in the Jobs guide by @albertvillanova in #7054
- Fix
paper_indexpaths and add GOLD, IW-OPD, and AsyncDistillation telemetry by @YeonwooSung in #7051 - Qualify doc references to experimental classes by @qgallouedec in #7158
Documentation
A docstring and docs consistency pass across the repo, all by @qgallouedec:
- Fix docstring type specs (#7148), reformat five docstrings to the repo style (#7149), fix docstring content drift (#7150), match config field order to the docstring order (#7151), reflow two docstrings to the doc-builder width (#7153), fix the
DistillationTrainersignature annotations (#7152), docs formatting pass (#7154), tidy pyproject / Makefile / .gitignore (#7157) - Document the TRL Docker image tags by @albertvillanova in #7055
CI
Docker images — released and dev builds are now separate workflows, the image version comes from the release tag, and the installed TRL version is pinned:
- Split the released and dev Docker image builds into separate workflows by @albertvillanova in #6990
- Read the Docker image version from the release tag by @albertvillanova in #6991
- Pin the TRL version installed in the Docker image by @albertvillanova in #6992
- Add the missing trailing newline to the dev Dockerfile by @albertvillanova in #7030
- chore: update
docker-build.ymlby @hf-security-analysis[bot] in #6997
Tiny-model config alignment — a sweep bringing every tiny test model's config in line with its reference model, all by @albertvillanova:
- Qwen2.5 (#7098), Qwen3 tiny+small (#7106), Qwen3 Instruct-2507 (#7107), GptOss (#7108), GPTNeoX / pythia-14m (#7109), Llama 3.2 + Remote (#7110), Llama 3 (#7112), Llama 3.1 (#7113)
- Pin
layer_typesso tiny Gemma3 / Olmo3 cover both attention types (#6962) and tiny Cohere2 (#6963) - Show list lengths and mark truncation in the tiny-model config diff (#7105)
Other CI, mostly by @albertvillanova:
- Use the doc-builder pre-commit hook (#6799), bump its revision (#6969, #7078)
- Retry tests failing on cuBLAS allocation errors the rerun filter missed (#6916)
- Use ruff
selectinstead ofextend-selectto keep the rule set explicit (#6964), stop dependabot from opening ruff pre-commit bumps (#6965), reformat lambda functions for code clarity (#7092) - Remove the flash-attn2 xfail markers now that the padding-free tests pass (#7057), fix the invariant suite recording instructions (#7058)
- Pin the invariant suite's FA2 hub kernel to the v2 branch by @qgallouedec in #6979
- Filter the benign torch DataParallel scalar-gather warning (#7019)
- Fix the input metadata of the post-slack composite action (#7029)
- Group Dependabot GitHub Actions and pre-commit updates in a single PR (#7088), merge the two Dependabot github-actions entries into one (#7091)
- Dependabot bumps in #6958, #7000, #7079, #7089
New Contributors
- @ciaoyizhen made their first contribution in #4755
- @DimensionSTP made their first contribution in #6830
- @YeonwooSung made their first contribution in #7051
What's Changed
- ⬆️ Fix dev version by @qgallouedec in #6939
- ⬆️ Bump dev version by @qgallouedec in #6940
- Add a QLoRA test to the GRPO and RLOO VLM test suites by @albertvillanova in #6909
- Add a QLoRA test to the trainers that support quantization_config by @albertvillanova in #6910
- Convert the QLoRA tests to the quantization_config trainer argument by @albertvillanova in #6927
- Fix missing entropy gradient in _ChunkedLogProbFunction backward by @verma8076 in #6625
- Document how to change the training objective by subclassing a trainer by @sergiopaniego in #6918
- Use the doc-builder pre-commit hook by @albertvillanova in #6799
- Retry tests failing on cuBLAS allocation errors the rerun filter missed by @albertvillanova in #6916
- Fix: vLLM weight sync fails instead of hanging by @AmineDiro in #6913
- Bump the actions group across 1 directory with 5 updates by @dependabot[bot] in #6958
- Bump https://github.com/huggingface/doc-builder from 0ab9ea03baf111ed8dd83e88233430b663127368 to 1b16dac5e33043af565fdf4c1b5b0fe81d0891c8 by @dependabot[bot] in #6969
- Pin layer_types so the tiny Gemma3 and Olmo3 models cover both attention types by @albertvillanova in #6962
- Pin layer_types so the tiny Cohere2 model covers both attention types by @albertvillanova in #6963
- Use ruff
selectinstead ofextend-selectto keep the rule set explicit by @albertvillanova in #6964 - fix vlm support asyncgrpo by @AmineDiro in #6839
- Split the released and dev Docker image builds into separate workflows by @albertvillanova in #6990
- chore: update docker-build.yml by @hf-security-analysis[bot] in #6997
- Stop dependabot from opening ruff pre-commit bumps by @albertvillanova in #6965
- Read the Docker image version from the release tag by @albertvillanova in #6991
- Pin the TRL version installed in the Docker image by @albertvillanova in #6992
- Bump trufflesecurity/trufflehog from 3.97.0 to 3.97.1 in the actions group by @dependabot[bot] in #7000
- Match hub kernels by repo id when checking the attention implementation by @albertvillanova in #6985
- Remove the unused FLASH_ATTENTION_VARIANTS constant from the DPO trainer by @albertvillanova in #7013
- Document that padding-free is temporarily unavailable in DPO by @albertvillanova in #7014
- Drop vLLM 0.19.0 support by @qgallouedec in #7002
- Pin the invariant suite's FA2 hub kernel to the v2 branch by @qgallouedec in #6979
- Filter the benign torch DataParallel scalar-gather warning in CI by @albertvillanova in #7019
- Test liger vs non-liger GRPO loss parity by @kashif in #6814
- Add the missing trailing newline to the dev Dockerfile by @albertvillanova in #7030
- Fix the input metadata of the post-slack composite action by @albertvillanova in #7029
- Catch AsyncDistillationTrainer up with recent AsyncGRPO changes by @kashif in #6823
- Document 1M-token training and add a context-parallelism example by @qgallouedec in #6846
- Rewrite the long context guide by @qgallouedec in #7003
- Document how to choose and pin a Hub kernel version by @albertvillanova in #6998
- Fix variable reference in BCO docs by @albertvillanova in #7046
- Remove PPOTrainer by @qgallouedec in #7020
- Correct what the TRL Docker image provides in the Jobs guide by @albertvillanova in #7054
- Document the TRL Docker image tags by @albertvillanova in #7055
- Do the chunked-CE
lm_headprojection on tensor cores instead of in fp32 by @qgallouedec in #6863 - Add contributor skills at
.agents/skillsby @qgallouedec in #6901 - Split the docs taxonomy into stable and experimental trainers by @qgallouedec in #7022
- Vendor the fused linear losses from Liger-Kernel into
trl.lossesby @qgallouedec in #7059 - Drop fused JSD from DistillationTrainer by @kashif in #7064
- Fix DPO and KTO Liger loss gaps by @kashif in #7062
- Harden chunked log probabilities by @kashif in #7065
- Run the vendored loss parity suites as slow tests only by @qgallouedec in #7067
- XPO/NashMD perf: avoid
output_hidden_stateswhen onlylast_hidden_stateis used by @ciaoyizhen in #4755 - Bump https://github.com/huggingface/doc-builder from 1b16dac5e33043af565fdf4c1b5b0fe81d0891c8 to c2d27f6f231df3d1b07f3a7ea54fe3d0f8bc3e27 by @dependabot[bot] in #7078
- Bump the actions group with 5 updates by @dependabot[bot] in #7079
- Group Dependabot GitHub Actions and pre-commit updates in a single PR by @albertvillanova in #7088
- Fix the invariant suite recording instructions by @albertvillanova in #7058
- Remove the flash-attn2 xfail markers now that the padding-free tests pass by @albertvillanova in #7057
- Bump the "github-actions-and-pre-commit" group with 2 updates across multiple ecosystems by @dependabot[bot] in #7089
- Merge the two Dependabot github-actions entries into one by @albertvillanova in #7091
- Reformat lambda functions for code clarity by @albertvillanova in #7092
- Fail fast on incompatible vLLM for default Async GRPO weight transfer by @DimensionSTP in #6830
- Inject the model revision into concrete config loads too by @albertvillanova in #7099
- Align tiny/small Qwen2.5 config with Qwen/Qwen2.5-32B-Instruct by @albertvillanova in #7098
- Sync the async dist. trainers with recent AsyncGRPO changes by @kashif in #6987
- Align tiny and small Qwen3 configs with their reference models by @albertvillanova in #7106
- Align tiny Qwen3 Instruct-2507 config with Qwen/Qwen3-4B-Instruct-2507 by @albertvillanova in #7107
- Require peft>=0.13.0 and drop the 0.12 version guards by @qgallouedec in #7102
- Align tiny GptOss config with openai/gpt-oss-20b by @albertvillanova in #7108
- Require deepspeed>=0.18.6 and drop the 0.16.4 guard by @albertvillanova in #7118
- Remove the leftover dataset_formatting module by @albertvillanova in #7117
- Align tiny GPTNeoX config with EleutherAI/pythia-14m by @albertvillanova in #7109
- Align tiny Llama 3.2 and Remote configs with meta-llama/Llama-3.2-1B-Instruct by @albertvillanova in #7110
- Align tiny Llama 3 config with meta-llama/Meta-Llama-3-8B-Instruct by @albertvillanova in #7112
- Align tiny Llama 3.1 config with meta-llama/Llama-3.1-8B-Instruct by @albertvillanova in #7113
- Show list lengths and mark truncation in the tiny-model config diff by @albertvillanova in #7105
- Fix the IW-OPD self-distillation loss assertion in tests by @albertvillanova in #7123
- Sync the model config pad token id with the tokenizer in the trainers by @albertvillanova in #7097
- Sync the model config pad token id with the tokenizer in the experimental trainers by @albertvillanova in #7128
- Guard target_parameters use for peft<0.17.0 by @albertvillanova in #7119
- Forward model revision to the auto-loaded processing_class by @kashif in #6978
- Add missing TRL blog posts to the docs landing page by @qgallouedec in #7023
- Add support for vLLM 0.28.0 by @qgallouedec in #7001
- Count each token once in num_tokens under tensor parallelism by @qgallouedec in #7101
- Realign duplicated comments across the trainers by @qgallouedec in #7145
- Fix typos in help strings and error messages by @qgallouedec in #7146
- Fix two messages that describe the wrong behaviour by @qgallouedec in #7147
- Fix docstring type specs by @qgallouedec in #7148
- Reformat five docstrings to the repo style by @qgallouedec in #7149
- Fix docstring content drift by @qgallouedec in #7150
- Match config field order to the docstring order by @qgallouedec in #7151
- Reflow two docstrings to the doc-builder width by @qgallouedec in #7153
- Fix the DistillationTrainer signature annotations by @qgallouedec in #7152
- Docs formatting pass by @qgallouedec in #7154
- Tidy pyproject, Makefile and .gitignore by @qgallouedec in #7157
- Fix the example commands in the script docstrings by @qgallouedec in #7156
- Fix three broken doc links by @qgallouedec in #7155
- Fix paper_index paths and add GOLD, IW-OPD, and AsyncDistillation telemetry by @YeonwooSung in #7051
- Qualify doc references to experimental classes by @qgallouedec in #7158
- Release: v1.13 by @qgallouedec in #7159
Full Changelog: v1.12.0...v1.13.0