fix(recipes): derive pretraining vocab from tokenizer - #4996
Conversation
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
Review — feat: tokenizer-driven vocab size for pretraining Solid, well-scoped change. The new Correctness checks (all passed):
Minor (non-blocking): the inline comment at setup.py:652 now only describes one of the two branch conditions; the branch also fires on Nit: consider a unit test for the Suggested test cases
|
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Summary
TokenizerConfig.use_tokenizer_vocab_sizepolicy for from-scratch pretrainingNullTokenizerin the Qwen-VL performance layer, sized to the model vocabulary so it cannot change the benchmark model shapeRoot cause
AutoBridge maps the Hugging Face
vocab_sizeinto the Megatron provider even when recipes useload_weights=False. Training setup treated that value as authoritative when it was larger than the runtime tokenizer. A launcher replacing the recipe tokenizer could therefore keep the source model vocabulary instead of sizing the from-scratch model to the dataset tokenizer.This caused Nemotron 3 Nano to use 131072 entries with the RP2 32K tokenizer instead of its previous 32000-entry behavior. Qwen3.5 text similarly retained 248320 entries with the RP2 32K tokenizer.
Qwen-VL initially needed an exception because its mock dataset gets token IDs from the Hugging Face processor while the recipe exposed a 32000-entry
NullTokenizer. Enabling tokenizer-derived vocabulary with that placeholder would have incorrectly resized the language model to 32000 entries. Canonical Qwen-VL pretraining now uses the real tokenizer at the processor path; only performance recipes replace it with a model-sized null tokenizer.Scope
All language-model recipes that stem from the shared pretraining template select the runtime tokenizer vocabulary. Standalone vanilla GPT needs no explicit flag override because its model vocabulary is unset, so setup already derives it from its synthetic tokenizer.
Canonical Qwen3-VL and Qwen3.5-VL mock-pretraining recipes now follow the same tokenizer-derived policy. Their performance wrappers preserve the source model shape with a model-sized
NullTokenizer. Diffusion vocabularies remain unrelated to language-token embeddings.SFT, PEFT, conversion, and checkpoint-compatible flows retain the existing explicit-model-vocabulary default.
Checkpoint compatibility
Pretraining recipes enable
use_tokenizer_vocab_sizefor new from-scratch runs. The policy is unconditional, including during checkpoint loading, and must not be changed partway through a run.To resume a checkpoint created before a recipe enabled this policy, set
tokenizer.use_tokenizer_vocab_size=Falseand retain the explicitmodel.vocab_sizeused to create that checkpoint. This preserves its embedding/output shape without guessing across persistent, non-persistent, resharded, or custom-managed checkpoint formats.Validation
This is independent of #4854. Once combined, its Qwen3.5 text recipes inherit the tokenizer-derived vocabulary policy without recipe-specific overrides.