cd /news/machine-learning/one-more-measured-note-for-trl-a-cal… · home › topics › machine-learning › article
[ARTICLE · art-178398] src=discuss.huggingface.co ↗ pub= topic=machine-learning verified=true sentiment=↓ negative

One more measured note for trl — a callback's rebuilt running model loses its dtype

A reproduction on TRL 1.19.0 found that a rebuilt running model can carry a different dtype from its averaging state, so a float32 running_model does not imply a float32 EMA, according to measurements posted in Hugging Face TRL issue #8549. In a small CPU fixture with a BF16 or FP16 dense model, the source parameters totaled 19,776 bytes against 39,552 bytes of FP32 running-model parameters, and a BF16 averaging state with an FP32 running model produced a maximum EMA error of about 0.01191 against an FP64 reference over a controlled 32-step trajectory, versus about 1.34e-7 when the averaging state was FP32 and the running model BF16. The tester also reported that stock PEFT LoRA initialization raised a constructor TypeError, that reusing the callback across a second model let a stale reference alter a frozen parameter, and recommended starting from the installed TRL version and actual parameter dtypes and using a fresh callback for independent training sessions.

recommendation

Check the installed TRL version and actual parameter dtypes before trusting an EMA, and use a fresh callback per training session so stale references cannot alter frozen parameters.

more in playbook: Fine-tuning and data
read2 min views1 publishedNov 30, 2026

I also ran some additional measurements using the actual callback:

I reproduced the reconstruction issue with TRL 1.19.0. The saved model and the actual averaging state can have different dtypes.

This is relevant to the question about FP32 and numerical stability in #8549: a float32 running_model does not imply a float32 EMA. The running copy is the destination, while the initial snapshots and EMA tensors are separate objects.

My additional observations:

Check Result in my small CPU fixture
BF16 or FP16 dense model 19,776 bytes of source parameters; 39,552 bytes of FP32 running-model parameters
BF16 averaging state, FP32 running model Maximum EMA error of about 0.01191 against an FP64 reference on a controlled 32-step trajectory
FP32 averaging state, BF16 running model, same input trajectory Maximum EMA error of about 1.34e-7; the running model still has the final BF16 rounding error
Real PEFT LoRA model The stock initialization raises a constructor TypeError ; an experimental copy-based initialization preserves the mixed BF16/FP32 parameter layout and reaches adapter export and reload
Reusing the callback with a second model and freezing one parameter A stale reference from the first model changes the frozen parameter in the second running copy; a fresh callback does not

The byte counts are parameter payload, not total CUDA memory. The numerical tests measure a recurrence, not trained-model accuracy.

I would start with the installed TRL version and actual parameter dtypes. Use a fresh callback for independent training sessions. If stock PEFT initialization fails and BEMA is optional, ordinary adapter training/export is an alternative, not an equivalent averaged checkpoint. If BEMA is required, test topology and export on a tiny model before trying a larger run.

The tests below used Python 3.13.18, PyTorch 2.14.1+cpu, TRL 1.19.0, Transformers 5.24.0, PEFT 0.22.0, Accelerate 1.16.0 and Datasets 4.7.0. The fixture is a tiny, randomly initialized Qwen2 model, not a downloaded full-size checkpoint. I used the actual callback hooks and controlled parameter changes instead of training an optimizer. The installed callback source matched the Git blob of the release (51cade794f29fde1edc91bc262f690ef354afc7f). There were five initial BEMA cases and seven follow-up cases, including the deliberately observed initialization failure. The environment’s pip check was not entirely clean (IPython’s missing jedi dependency), although the relevant imports and probe stages completed.

The tests are direct hooks, not a full Trainer or GPU/distributed/quantized benchmark.

A. What the reconstruction preserves, and what the byte counts actually mean

── more in #machine-learning 4 stories · sorted by recency
── more on @hugging face 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/one-more-measured-no…] indexed:0 read:2min 2026-11-30 · —