Skip to content

Commit 80d8c4b

Browse files
committed
fix(recipes): defer Nano vocabulary to tokenizer
Signed-off-by: Chen Cui <chcui@nvidia.com>
1 parent 0c2c568 commit 80d8c4b

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/megatron/bridge/recipes/nemotronh/gb200/nemotron_3_nano.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def nemotron_3_nano_pretrain_8gpu_gb200_bf16_config() -> ConfigContainer:
4141
cfg = _pretrain_common()
4242

4343
cfg.model = AutoBridge.from_hf_pretrained(_NEMOTRON_3_NANO_MODEL_ID).to_megatron_provider(load_weights=False)
44+
# Pretraining may use a tokenizer other than the HF checkpoint tokenizer.
45+
# Defer the model vocabulary size to the runtime tokenizer, matching the
46+
# pre-migration MambaModelProvider recipe behavior.
47+
cfg.model.vocab_size = None
4448
cfg.tokenizer.tokenizer_model = _NEMOTRON_3_NANO_MODEL_ID
4549

4650
cfg.model.seq_length = 4096

tests/unit_tests/recipes/test_nemotronh_recipes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ def test_nemotronh_recipe_rejects_unknown_cli_override():
139139
assert not hasattr(cfg.model, "not_a_real_field")
140140

141141

142+
def test_nemotron_3_nano_gb200_defers_vocab_size_to_training_tokenizer():
143+
"""The GB200 pretraining model vocabulary must follow its runtime tokenizer."""
144+
cfg = _nemotronh_module.nemotron_3_nano_pretrain_8gpu_gb200_bf16_config()
145+
146+
assert cfg.model.vocab_size is None
147+
148+
142149
def test_nemotron_nano_9b_v2_lora_defaults():
143150
"""Test that Nemotron Nano 9B v2 LoRA has correct default parallelism."""
144151
from megatron.bridge.recipes.nemotronh import nemotron_nano_9b_v2_peft_config

0 commit comments

Comments
 (0)