fix(deepseek-v4): initialize random training state - #2991
Conversation
Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
147a2e5 to
9357554
Compare
|
/ok to test 9357554 |
|
/ok to test 9357554 |
|
Approving — well-diagnosed fix. The all-zeros-route → duplicate-top-k → DeepEP NaN chain is precisely identified, and the route formula One suggestion worth acting on, plus a minor note: 1. (robustness) Future-proof MTP hash-route init. 2. (minor) Signature-change note. |
Summary
Root cause
With
load_base_model=false, HyperConnection parameters allocated withtorch.emptywere never initialized. The HashGate route table also remained all zeros, so every token sent every top-k route to expert 0. DeepEP requires distinct expert IDs within a token's top-k routes; duplicate routes poisoned the active routed-expert backward pass and produced a NaN gradient norm at step 0.User impact
DeepSeek-V4 random-init training with pipeline parallelism, expert parallelism, and DeepEP now starts with finite gradients instead of failing on the first backward pass. Checkpoint-loaded routes are unchanged because checkpoint loading still overwrites the initialized fallback table.
Validation
uv run --no-sync pytest -q tests/unit_tests/models/deepseek_v4: 174 passed, 17 skippedruff format --checkon all five changed filesruff checkon the three changed production filesgit diff --checkcw-dfw, 2 nodes x 8 H100, PP2/EP8, DeepEP, bf16, random init:13633831: step-0 loss12.1582,grad_norm=nan, validation lossnan13634773: non-finite gradients localized to rank 0, layer 1 routed-expertgate_and_up_projsanddown_projs13634923: all 16 ranks reported zero non-finite gradients; step-0 loss12.1606,grad_norm=2.4152, validation loss12.1979; exit code 0Fixes NVBug 6317402.