Fix: stabilize MTP logits validation - #890
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughDeepSeek-V4 Flash now uses shared LM-head validation helpers. The validation checks tensor-parallel projections, finite values, ratio limits, and maximum end-to-end differences. Prefill execution also supports deterministic seeds. ChangesDeepSeek-V4 LM-head validation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant PrefillMTP
participant GoldenLMHead
participant LMHeadValidation
participant TPWeights
PrefillMTP->>GoldenLMHead: generate reference logits
GoldenLMHead->>LMHeadValidation: compute_lm_head_logits(hidden states, row indices, TP size)
LMHeadValidation->>TPWeights: read vocabulary shards
TPWeights-->>LMHeadValidation: sharded projection weights
LMHeadValidation-->>GoldenLMHead: reference logits
PrefillMTP->>LMHeadValidation: compare device logits and hidden outputs
LMHeadValidation-->>PrefillMTP: validation result
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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@models/deepseek/v4-flash/lm_head_validation.py`:
- Around line 64-79: Validate the LM-head reference produced by
compute_lm_head_logits before calling base_cmp, rejecting it when it contains
any NaN or infinite values; preserve the existing comparison flow for finite
references. Add a regression test using a selected NaN hidden_out value with
matching finite actual and _expected logits to ensure the comparison fails.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3acde632-8d7e-490c-9112-e75b234a33bb
📒 Files selected for processing (4)
models/deepseek/v4-flash/lm_head.pymodels/deepseek/v4-flash/lm_head_validation.pymodels/deepseek/v4-flash/prefill_mtp.pytests/golden/test_lm_head_validation.py
|
CI retry triage for empty commit
The first attempt also passed the hardware |
Problem
MTP compared device logits (projected from device hidden_out) with CPU logits (projected from the independent CPU hidden_out). The permitted hidden-state error can be amplified by the LM-head projection, producing intermittent logits-only failures even when hidden_out, pre_hc_hidden_out, and kv_cache pass. Input generation was also unseeded.
Fix
Validation