TP=1 embedding path assumes in-range token IDs while MockGPTDataset ignores config
Describe the bug
Running run_simple_mcore_train_loop.py with tensor_model_parallel_size = 1 triggers a CUDA device-side assert during embedding lookup.
This appears to be caused by two combined behaviors:
-
MockGPTLowLevelDatasetuses a hard-codedmax_sequence_length = 4096and generates token IDs up to that range, regardless of thevocab_sizepassed throughGPTDatasetConfig. -
The
TP=1code path in the embedding layer does not mask or validate out-of-range token IDs, unlike theTP>1path.
Setting vocab_size=4096 makes TP=1 run without errors.
Steps/Code to reproduce bug
- Modify the example script to use:
initialize_distributed(tensor_model_parallel_size=1, pipeline_model_parallel_size=1)
- Run:
torchrun --nproc_per_node=1 examples/run_simple_mcore_train_loop.py
- Observe:
RuntimeError: CUDA error: device-side assert triggered
Expected behavior
-
TP=1 should apply the same masking logic as TP>1,
-
the mock dataset/tokenizer stack should respect the model’s vocab_size and/or configured sequence_length, so token IDs never exceed the embedding vocabulary.
Additional context
This may be related to issue #881.
From #2945 we are enforcing the mock generated tokens to respect the tokenizers vocab_size. Thanks for raising the issue!