Hugging Face updated its TRL model training tool to help developers transfer knowledge from multiple teacher models and reduce the overhead of packing training examples. An analog clock-reading example also shows how to train a new model for a practical task.
1. Learning from a different teacher for each example
TRL v1.19.0 expands distillation, which uses teacher model evaluations to train another model. Pass multiple teachers in a dictionary, and the teacher assigned to each training example scores the generated answer. Math and coding tasks can have different teachers.
With environment_factory, agents can also be distilled in environments that retain previous state. Beyond selecting a teacher to score individual answers, this supports training agents that interact with an environment.
The following example from the original source registers multiple teachers and selects one through a dataset column.
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"
)2. Keeping packed examples separate reduces computation
Processing also changed in supervised fine-tuning (SFT), which further trains models on reference answers. BFD packing previously flattened the entire batch into one row. SDPA therefore computed token relationships across the whole batch. The release notes say this greatly increased computation and caused out-of-memory errors on Trainium.
Packed examples now remain in separate rows, with position numbers restarting for each example. Processing individual rows instead of one long combined row reduces unnecessary computation.
The company reports the following BFD SFT step times using H100 and Qwen3-1.7B. The comparison covers each attention implementation before and after the change on the same hardware and model.
Table: BFD SFT step time by attention implementation
Conditions: H100, Qwen3-1.7B, packing_strategy="bfd"
Unit: seconds/step
| Attention implementation | v1.18 | v1.19 |
|---|---|---|
| SDPA | 2.06 | 1.02 |
| flash attention 2 | 0.828 | 0.832 |
SDPA step time roughly halved, while flash attention 2 was virtually unchanged. This packing improvement is therefore especially relevant to SDPA users. It does not justify expecting a similar speedup with flash attention 2.
Separately, under compilation conditions using Trainium2 and Qwen3-0.6B, the previous version crashed, while the new version recorded 3.2 seconds per step.
3. Preparing batches before training is faster too
AsyncGRPO, a training feature that uses model-generated answers, now uses array operations to plan and pack small training batches. Computing multiple values at once reduces the bottleneck in preparing data for model training.
With Qwen3-1.7B generating answers to math tasks on 4 B300 GPUs, the company reports planning and packing time fell from 18 seconds to 1 second per iteration. Overall training throughput, measured in training tokens per second, rose 28%. Batch preparation time and overall training throughput measure different scopes. The release notes state that the resulting batches are bitwise identical.
4. A clock-reading example supports a new vision model
Inkling 2 Mini was added to vision-language model tests and an analog clock-reading SFT example. Beyond expanding model support, the release provides an example for training a specific visual task.
The company reports that after 53 minutes of SFT using LoRA, which trains only a small number of additional parameters, on one H100, accuracy in reading unseen clocks to the second rose from 0% to 87.0%. The key point is that results were checked on clocks not used in training.
5. More training options require different preparation
Multi-teacher distillation lets users assign a suitable teacher to each example. Users must therefore add teacher selection information to their data, while stateful agent training requires an environment. Designing training data and environments matters independently of processing efficiency gains.
In packed SFT, setting padding_free=True flattens the batch into one row as before.
Using Inkling 2 Mini requires transformers>=5.24.0.
The practical changes in this release are more efficient SDPA-based packed SFT and support for distillation using teacher selection and stateful environments.
