Align tiny test model configs with their reference models
What
The tiny models under trl-internal-testing are built by the scripts in scripts/generate_tiny_models/ from architecture arguments only:
config = Qwen3Config(
vocab_size=len(tokenizer.vocab),
hidden_size=8,
num_attention_heads=4,
num_key_value_heads=2,
num_hidden_layers=2,
intermediate_size=32,
)Everything not passed falls back to the config class defaults, while the tokenizer and generation config are copied from the real model. So a tiny model can carry eos_token_id=None where the model it stands in for uses 151645, a scalar eos_token_id=2 where the real one ships a list of three ids, generic RoPE where the real one uses rope_type: llama3 frequency scaling, or an untied lm_head where the real one ties.
The consequence is that CI exercises configurations that do not exist in the wild, and code paths every user hits have no coverage at all.
print_config_diff already prints these differences on every generation run, and _DIFF_IGNORE never filtered them. They were simply never acted on, apart from four one-off PRs: #5638, #5706, #5707 and #5716.
Goal
For each tiny model, the only differences against its reference should be the deliberate size reduction (hidden_size, num_hidden_layers, intermediate_size, num_attention_heads, num_key_value_heads, head_dim) plus fields derived from them, such as layer_types, whose length tracks num_hidden_layers. Also excluded are quantization_config and auto_map, which describe the reference checkpoint's weights and remote code rather than the model. Everything else the reference carries is mirrored, with no per-key judgement, as settled in https://github.com/huggingface/trl/issues/7137#issuecomment-5739136626.
vocab_size is mirrored despite affecting size: it is a matrix dimension rather than a token count, and reproducing the reference's padding is part of the fidelity.
Open
Aligned earlier, tracked on #7093 (they also reduced the warning noise there):
- #7130
tie_word_embeddings, for the four tiny models where it diverges - #7134 Qwen2.5-Coder
- #7135 DeepSeek-R1-Distill
- #7138 FalconMamba, correcting the reference
- #7139 FalconMamba config, on top of #7138 — confirmed aligned against
tiiuae/falcon-mamba-7b-instruct
The full sweep, with the method and the per-model rows, is in this comment. One PR per tiny model repo, so each regenerated artifact lands in its own Hub PR and a CI break bisects to a single model.
Ordered easiest first. 59 scripted models on current main: 33 aligned, 19 need alignment.
One PR per tiny model, matching how the earlier ones shipped.
- #7203
tiny-MistralForCausalLM-0.1—max_position_embeddings,rms_norm_eps, pinvocab_size - #7204
tiny-MistralForCausalLM-0.2—sliding_window(the tiny model enables SWA where the reference disabled it),rope_theta,max_position_embeddings,rms_norm_eps, pinvocab_size - #7216 + #7217
tiny-GemmaForCausalLM:head_dimscale-down, thenhidden_actand pinnedvocab_size - #7227 + #7228
tiny-Gemma2ForCausalLM:head_dimandquery_pre_attn_scalarscale-down, theneos_token_id[1, 107]and pinnedvocab_size - #7257
tiny-Phi3ForCausalLM-3: pinnedvocab_size,sliding_window - #7276
tiny-Phi3ForCausalLM-3.5: pinnedvocab_size,longrope,sliding_window,max_position_embeddings - #7398
tiny-DeepseekV3ForCausalLM - #7399
tiny-DeepseekV3ForCausalLM-0528 - #7443
tiny-NemotronHForCausalLM-nano - #7444
tiny-NemotronHForCausalLM-3.5-lightning - #7447
tiny-NemotronHForCausalLM-super - #7448
tiny-NemotronHForCausalLM-ultra - #7400
tiny-Lfm2ForCausalLM -
tiny-Lfm2ForCausalLM-2.5 -
tiny-Lfm2VlForConditionalGeneration-2.5: regenerate only, the divergence is a stale transformers 5.0.0 artifact - #7424
tiny-GptOssForCausalLM - #7425
tiny-Qwen2VLForConditionalGeneration:mrope_section[1, 1] to [1, 1, 0], restoring the 3-section t/h/w shape - #7426
tiny-Qwen2_5_VLForConditionalGeneration: same - #7232 + #7233
tiny-OPTForCausalLM:ffn_dimscale-down (the script passedintermediate_size, whichOPTConfigdoes not model, so the FFN stayed 3072 wide), then pinnedvocab_sizeand dropping the unmodellednum_key_value_heads
Each PR measures print_config_diff at the version its own script pins.
Follow-ups from review
- Align
quantization_config(https://github.com/huggingface/trl/pull/7424#pullrequestreview-5347670644). It is currently one of the two rule exclusions, so no tiny model carries one and the quantized loading path that realgpt-ossand DeepSeek-V3 users hit has no coverage. Mirroring the config alone would leave it claiming fp8 or mxfp4 over bf16 weights, so this means actually quantizing the tiny models, and as noted it would need test changes. Worth checking first whether mxfp4 and fp8 tiny models can even load on the CPU runners. - Give the Qwen-VL width axis rotary dims (https://github.com/huggingface/trl/pull/7425#pullrequestreview-5347680726). With
mrope_sectionsumming tohead_dim // 2 = 2, the width axis gets no dims on any transformers version, so it is never exercised.hidden_size=24giveshead_dim=6and allows[1, 1, 1], one dim per axis. Applies to bothtiny-Qwen2VLForConditionalGenerationandtiny-Qwen2_5_VLForConditionalGeneration.
Second pass
The models below landed before the rule above was settled, and skipped keys the reference carries. Each needs the remaining keys mirrored: one kwarg plus a regeneration, nothing to revert.
- #7332
tiny-Qwen2ForCausalLM-R1-Distill(#7135):use_mrope - #7333
tiny-FalconMambaForCausalLM(#7139):use_mambapy - #7334
tiny-GemmaForCausalLM(#7217):rope_scaling - #7335
tiny-Gemma2ForCausalLM(#7228):cache_implementation,hidden_act - #7336
tiny-OPTForCausalLM(#7233):activation_dropout,prefix - #7337
tiny-Phi3ForCausalLM-3(#7257):attention_bias - #7338
tiny-Phi3ForCausalLM-3.5(#7276):attention_bias
Not alignment work, but surfaced by the sweep:
- Make
print_config_difffail instead of print, so a new script cannot regress this
Repo lifecycle — missing generation scripts, orphans and deletions — is tracked in #7202, not here. tiny-PaliGemmaForConditionalGeneration was on the list above until #7186 retired its generator; it is a deletion candidate in #7202 now, so it is out of scope for alignment.
Notes
Cohere2 needs no tiny model change: its config already matches its reference, and the residual difference comes from the reference disagreeing with its own tokenizer. Nemotron and DeepSeek-V3 are in the same position for their token ids, but the sweep found other divergences in both — they are listed above.
use_mamba_kernels is False on all four Nemotron tiny models against True on the references. This looks deliberate (no mamba-ssm in CI) and is left alone.
Source: huggingface/trl