Problem
With Megatron Bridge's GPT-OSS 20B model and Megatron-Core's DeepEP MoE token dispatcher in dropless mode, rank 0's raw logits for a fixed token sequence X depend on the unrelated sequences processed by the other expert-parallel ranks.
The comparison is:
- homogeneous EP batch: every EP rank processes
X
- heterogeneous EP batch: rank 0 processes the byte-identical
X; every other EP rank processes a distinct Y
No labels, loss, backward pass, optimizer, or dataset pipeline are involved. The test uses a real GPT-OSS 20B Megatron checkpoint and directly compares the model's raw logits.
Observed result:
effective_config dispatcher=flex backend=deepep capacity_factor=None pad_to_capacity=False ep=8
logits_shape=(1, 128, 201088) logits_dtype=torch.float32
repeat=0 target_max_abs_delta=0.25
repeat=1 target_max_abs_delta=0.25
repeat=2 target_max_abs_delta=0.25
status=INVARIANT_VIOLATED mode=dropless max_abs_delta=0.25 homogeneous_repeat_delta=0 atol=0 module_global_buffer_reused=True
The difference is deterministic and bit-reproducible. Repeating the homogeneous forward gives an exact delta of zero, while changing only the other EP ranks' sequences gives an exact max logit delta of 0.25.
This is a correctness issue for gradient accumulation and any two-pass method that assumes a sample's forward is a function only of its own tokens and the model weights.
A smaller module-level harness that exercised one _DeepepManager -> fused_dispatch -> expert-local permute -> token-wise expert op -> reverse permute -> fused_combine round did not reproduce the difference. The full 24-layer GPT-OSS model does, suggesting the trigger requires repeated full-model MoE execution, actual grouped experts, or another model-level interaction. Therefore the exact low-level root cause is not yet confirmed.
Minimal repro
Complete standalone reproducer:
https://gist.github.com/yaoyu-33/c8847fa364d3bb2406b608c863cd465b
Prepare a GPT-OSS 20B Megatron checkpoint using the existing example under examples/models/gpt_oss, then run:
export NVTE_ALLOW_NONDETERMINISTIC_ALGO=0
export CUBLAS_WORKSPACE_CONFIG=:4096:8
export HF_HUB_OFFLINE=1
export TRANSFORMERS_OFFLINE=1
uv run python -m torch.distributed.run \
--nproc_per_node=8 \
scripts/training/gpt_oss_deepep_batch_invariance_reproducer.py \
--hf-model-path /path/to/openai-gpt-oss-20b-snapshot \
--checkpoint-path /path/to/megatron-gpt-oss-20b \
--seq-length 128 \
--repeats 3
Relevant effective configuration:
tensor_model_parallel_size = 1
pipeline_model_parallel_size = 1
expert_model_parallel_size = 8
expert_tensor_parallel_size = 1
micro_batch_size = 1
moe_token_dispatcher_type = "flex"
moe_flex_dispatcher_backend = "deepep"
moe_expert_capacity_factor = None
moe_pad_expert_input_to_capacity = False
moe_router_dtype = "fp32"
moe_grouped_gemm = True
The script loads real weights, runs primer -> homogeneous -> primer -> heterogeneous, and compares rank 0's complete raw-logit tensor.
Expected behavior
Rank 0 receives byte-identical input_ids and position IDs in both measured forwards. Its raw logits should therefore be byte-identical regardless of the unrelated sequences processed by other EP ranks:
Affected area
area:training
The failure is observed through Megatron Bridge's GPT-OSS provider and checkpoint loader, while the likely implementation boundary is the Megatron-Core/DeepEP MoE dispatcher.
Regression?
Not sure.
Environment
Megatron Bridge: b4fc0887eb6ef76a808f6c5f830d6fada9b9c96a
Megatron-Core: 8b3d8a5d9719c201efa7add2a8a112b0d095e846
Container: mbridge-260522.sqsh
Hardware: 1 node, 8 GPUs
Precision: BF16 model parameters; FP32 router probabilities
Model: GPT-OSS 20B, real Megatron checkpoint
Parallelism: TP=1, PP=1, CP=1, EP=8
Sequence length: 128
The run was offline against a pre-populated Hugging Face cache and a real 39 GB Megatron checkpoint.
Control and current limitation
The original suspected workaround is finite expert capacity plus padding. On current ToT, the same-backend control cannot be run because Megatron-Core explicitly rejects it during config finalization:
ValueError: Flex token dispatcher with deepep backend does not support
moe_pad_expert_input_to_capacity
Therefore this report confirms the dropless failure across a second model family, but does not claim that the capacity+pad workaround has been validated on current ToT.
Additional context
- A one-dispatch module-level DeepEP harness was invariant on 2 and 8 GPUs.
- The real 24-layer GPT-OSS model is not invariant.
- The module-global
deep_ep.Buffer object was reused throughout the failing run.
- No issue matching “DeepEP dropless logits/batch invariance” was found in either Megatron-Bridge or Megatron-LM at filing time.
Problem
With Megatron Bridge's GPT-OSS 20B model and Megatron-Core's DeepEP MoE token dispatcher in dropless mode, rank 0's raw logits for a fixed token sequence
Xdepend on the unrelated sequences processed by the other expert-parallel ranks.The comparison is:
XX; every other EP rank processes a distinctYNo labels, loss, backward pass, optimizer, or dataset pipeline are involved. The test uses a real GPT-OSS 20B Megatron checkpoint and directly compares the model's raw logits.
Observed result:
The difference is deterministic and bit-reproducible. Repeating the homogeneous forward gives an exact delta of zero, while changing only the other EP ranks' sequences gives an exact max logit delta of
0.25.This is a correctness issue for gradient accumulation and any two-pass method that assumes a sample's forward is a function only of its own tokens and the model weights.
A smaller module-level harness that exercised one
_DeepepManager -> fused_dispatch -> expert-local permute -> token-wise expert op -> reverse permute -> fused_combineround did not reproduce the difference. The full 24-layer GPT-OSS model does, suggesting the trigger requires repeated full-model MoE execution, actual grouped experts, or another model-level interaction. Therefore the exact low-level root cause is not yet confirmed.Minimal repro
Complete standalone reproducer:
https://gist.github.com/yaoyu-33/c8847fa364d3bb2406b608c863cd465b
Prepare a GPT-OSS 20B Megatron checkpoint using the existing example under
examples/models/gpt_oss, then run:Relevant effective configuration:
The script loads real weights, runs
primer -> homogeneous -> primer -> heterogeneous, and compares rank 0's complete raw-logit tensor.Expected behavior
Rank 0 receives byte-identical
input_idsand position IDs in both measured forwards. Its raw logits should therefore be byte-identical regardless of the unrelated sequences processed by other EP ranks:Affected area
area:trainingThe failure is observed through Megatron Bridge's GPT-OSS provider and checkpoint loader, while the likely implementation boundary is the Megatron-Core/DeepEP MoE dispatcher.
Regression?
Not sure.
Environment
The run was offline against a pre-populated Hugging Face cache and a real 39 GB Megatron checkpoint.
Control and current limitation
The original suspected workaround is finite expert capacity plus padding. On current ToT, the same-backend control cannot be run because Megatron-Core explicitly rejects it during config finalization:
Therefore this report confirms the dropless failure across a second model family, but does not claim that the capacity+pad workaround has been validated on current ToT.
Additional context
deep_ep.Bufferobject was reused throughout the failing run.