Repository navigation
Write the aligned token ids to the text config - #7315
Merged
Merged
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Member
Author
|
CI error with minimum versions is unrelated; see: |
albertvillanova
force-pushed
the
align-token-ids-on-text-config
branch
from
September 22, 2026 04:50
0507bef to
c3c2597
Compare
albertvillanova
force-pushed
the
align-token-ids-on-text-config
branch
from
September 23, 2026 06:25
c3c2597 to
29c44c3
Compare
albertvillanova
removed this pull request from stack #7317
September 23, 2026 06:33
albertvillanova
added this pull request to stack #7349
September 23, 2026 06:34
Member
Author
|
Merging this PR as analog to the already approved and merged #7318. |
17 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR writes the aligned special token ids to the text config instead of the top-level config.
Part of #7093. For a composite model the id the trainer wrote was not the one
Trainerreads, soalign_special_tokensrealigned it at train time and logged it; writing throughget_text_config()leaves nothing to realign.Motivation
The trainers set the tokenizer's pad and eos ids on the model configs before training, so that the alignment
Trainerperforms at train time finds nothing to change. huggingface/transformers#48847 moved that alignment to read and writemodel.config.get_text_config(), because a composite model keeps its special token ids on the text sub-config and the top-level config does not forward attribute lookups.Our writes still land on the top-level config, so for a composite model they are no longer what gets compared, and the realignment message comes back. Measured on
tiny-Qwen2_5_VLForConditionalGenerationagainst transformersmain:Solution
Write to
model.config.get_text_config()at each site that mirrors a token id for that purpose.get_text_config()returnsselffor a non-composite config, so this is a no-op for text models and needs no version guard: the method predates ourtransformers>=4.56.2floor.The generation config is untouched, since it is not composite.
Changes
CC: @qgallouedec and @lewtun for visibility.
Note
Low Risk
Mechanical API alignment with Transformers token sync; behavior is unchanged for non-composite models and fixes VLM/composite misalignment rather than altering training logic.
Overview
Mirrors tokenizer pad and eos token IDs onto
model.config.get_text_config()instead of the top-levelmodel.configeverywhere TRL sets them at trainer init (and inclone_chat_templatefor eos).This matches Hugging Face Transformers’ token alignment after transformers#48847: composite / VLM configs keep special token IDs on the text sub-config, so writing only to the root config no longer satisfies what
Trainercompares and VLMs could log spurious “Updated tokens” realignment.generation_configis unchanged;get_text_config()is a no-op for plain causal LMs (returns self).Touches core trainers (SFT, DPO, KTO, GRPO, RLOO, Distillation, Reward) and experimental trainers (async distillation/GRPO, CPO, online DPO, SDPO, SDFT, SSD, TPO, IW-OPD).
Reviewed by Cursor Bugbot for commit 29c44c3. Bugbot is set up for automated code reviews on this repo. Configure here.