#7137·trl

Align tiny test model configs with their reference models

Author: albertvillanovaCreated Sep 9, 2026Updated Sep 17, 2026

What

The tiny models under trl-internal-testing are built by the scripts in scripts/generate_tiny_models/ from architecture arguments only:

python
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.

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.1max_position_embeddings, rms_norm_eps, pin vocab_size
  • #7204 tiny-MistralForCausalLM-0.2sliding_window (the tiny model enables SWA where the reference disabled it), rope_theta, max_position_embeddings, rms_norm_eps, pin vocab_size
  • #7216 + #7217 tiny-GemmaForCausalLM: head_dim scale-down, then hidden_act and pinned vocab_size
  • #7227 + #7228 tiny-Gemma2ForCausalLM: head_dim and query_pre_attn_scalar scale-down, then eos_token_id [1, 107] and pinned vocab_size
  • #7257 tiny-Phi3ForCausalLM-3: pinned vocab_size, sliding_window
  • tiny-Phi3ForCausalLM-3.5vocab_size, longrope, sliding_window, attention_bias, max_position_embeddings
  • tiny-DeepseekV3ForCausalLMvocab_size, yarn, scoring_func, topk_method, max_position_embeddings
  • tiny-DeepseekV3ForCausalLM-0528 — same as above
  • tiny-NemotronHForCausalLM-nanorouted_scaling_factor, max_position_embeddings
  • tiny-NemotronHForCausalLM-3.5-lightningrouted_scaling_factor, max_position_embeddings
  • tiny-NemotronHForCausalLM-superrouted_scaling_factor, moe_shared_expert_overlap, max_position_embeddings
  • tiny-NemotronHForCausalLM-ultrarouted_scaling_factor, moe_shared_expert_overlap, max_position_embeddings
  • tiny-Lfm2ForCausalLMuse_cache
  • tiny-Lfm2ForCausalLM-2.5use_cache
  • tiny-Lfm2VlForConditionalGeneration-2.5 — regenerate only; text_config.max_position_embeddings is a stale transformers 5.0.0 artifact
  • tiny-GptOssForCausalLMswiglu_limit, initial_context_length
  • tiny-Qwen2VLForConditionalGenerationmrope_section [1, 1] → [1, 1, 0], restoring the 3-section t/h/w shape
  • tiny-Qwen2_5_VLForConditionalGeneration — same
  • #7232 + #7233 tiny-OPTForCausalLM: ffn_dim scale-down (the script passed intermediate_size, which OPTConfig does not model, so the FFN stayed 3072 wide), then pinned vocab_size and dropping the unmodelled num_key_value_heads

The field lists come from the sweep, which ran at transformers==5.16.1 so that every architecture in the org could be parsed. Each PR re-measures print_config_diff at the version its own script pins, and a few rows shift between versions — tiny-GemmaForCausalLM shows rope_scaling at 4.56.2 but not at 5.16.1, for instance. The per-PR Before/After is the authoritative one.

Not alignment work, but surfaced by the sweep:

  • Make print_config_diff fail 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.