fix(dsv4): zero inactive prefill MoE tails#744
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughDeepSeek V4 prefill now explicitly zeros inactive token tail blocks along the hidden-channel dimension after every attention stage and before the corresponding MoE stage. Exported JIT entrypoint signatures and attention/MoE arguments remain unchanged. ChangesDeepSeek V4 prefill tail handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a _zero_hc_tail helper function in models/deepseek/v4/prefill_fwd.py to zero out the tail of the hidden states tensor for inactive tokens during prefill forward passes, applying it after various attention layers. The review feedback recommends adding an explanatory comment to a self-assignment statement within this function, which appears to be a compiler workaround to ensure the tensor is materialized.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| for block in pl.spmd(T * HC_MULT, name_hint="prefill_zero_hc_tail"): | ||
| if block == 0: | ||
| x_hc[0:1, 0:1, 0:16] = x_hc[0:1, 0:1, 0:16] |
There was a problem hiding this comment.
This no-op assignment appears to be a compiler workaround, likely to act as a keep-alive for x_hc and ensure it's materialized before the loop. For improved maintainability, please add a comment explaining its purpose.
| x_hc[0:1, 0:1, 0:16] = x_hc[0:1, 0:1, 0:16] | |
| # Keep-alive for x_hc to ensure it's materialized before use in the loop. | |
| x_hc[0:1, 0:1, 0:16] = x_hc[0:1, 0:1, 0:16] |
Summary
prefill_fwd.py; no MoE, HC head, RoPE, or metadata changesnum_tokens < TValidation
python -m py_compile models/deepseek/v4/prefill_fwd.pygit diff --check -- models/deepseek/v4/prefill_fwd.pypython models/deepseek/v4/prefill_fwd.py -p a2a3 --ep 2 -d 0,1 --num-tokens 4 --compile-onlytask_20260709_183916_13296387544, devices6,7,runtime done (78.38s),PASStask_20260709_185059_17335683456, devices8,9,10,11,12,13,14,15,runtime done (266.87s),PASS