Megatron-LM icon indicating copy to clipboard operation
Megatron-LM copied to clipboard

TP=1 embedding path assumes in-range token IDs while MockGPTDataset ignores config

Open vineash opened this issue 1 year ago • 1 comments

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:

  1. MockGPTLowLevelDataset uses a hard-coded max_sequence_length = 4096 and generates token IDs up to that range, regardless of the vocab_size passed through GPTDatasetConfig.

  2. The TP=1 code path in the embedding layer does not mask or validate out-of-range token IDs, unlike the TP>1 path.

Setting vocab_size=4096 makes TP=1 run without errors.

Steps/Code to reproduce bug

  1. Modify the example script to use:
initialize_distributed(tensor_model_parallel_size=1, pipeline_model_parallel_size=1)
  1. Run:
torchrun --nproc_per_node=1 examples/run_simple_mcore_train_loop.py
  1. 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.

vineash avatar Dec 02 '25 17:12 vineash

From #2945 we are enforcing the mock generated tokens to respect the tokenizers vocab_size. Thanks for raising the issue!

asolergi-nv avatar Jan 29 '26 23:01 asolergi-nv