[None][bugfix] Guard e_score_correction_bias load for DeepSeek-V2-Lite#15154
[None][bugfix] Guard e_score_correction_bias load for DeepSeek-V2-Lite#15154waynehacking8 wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthroughThe pull request adds a defensive check to ChangesDeepseekV3Gate Conditional Bias Loading
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 `@tensorrt_llm/_torch/models/modeling_deepseekv3.py`:
- Around line 899-902: The e_score_correction_bias parameter is currently
created with torch.empty (uninitialized) and left as garbage when the checkpoint
lacks the "e_score_correction_bias" key; update initialization so
e_score_correction_bias is created zero-initialized (use torch.zeros with the
same shape and dtype) in the model __init__ (the same place where torch.empty is
used) so that runtime access in the routing method (where
e_score_correction_bias is read) gets valid zeros if the checkpoint omits the
key; alternatively, if you prefer not to change __init__, ensure the load path
that checks weights[0] sets self.e_score_correction_bias.zero_() when the key is
missing—prefer the __init__ zero-init approach to match LagunaGate.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 194db519-88d0-4c16-b0bf-066c6b503360
📒 Files selected for processing (1)
tensorrt_llm/_torch/models/modeling_deepseekv3.py
|
Status check: this PR has been mergeable and review-ready since 06-09 (coderabbit pass addressed at open time). Could a maintainer trigger CI ( |
DeepseekV3Gate.load_weights accesses `e_score_correction_bias` unconditionally, but DeepSeek-V2-Lite models (scoring_func=softmax, q_lora_rank=None) do not have this tensor — it is specific to V3's sigmoid routing with auxiliary-loss-free load balancing. This causes a KeyError when loading any V2-Lite variant through the DeepseekV3 weight loader path (e.g. NVFP4-quantized V2-Lite). The fix adds a simple key-existence check, matching the pattern used elsewhere in the loader for optional V3-specific weights. Tested on RTX PRO 6000 (SM120) with DeepSeek-V2-Lite NVFP4 (modelopt 0.37, kv_b_proj BF16) — warmup + generate clean. Signed-off-by: WEI CHENG CHIU <waynehacking8@gmail.com>
Address CodeRabbit review: use torch.zeros instead of torch.empty for e_score_correction_bias initialization. When the checkpoint omits this key (V2-Lite models), the parameter now holds valid zeros instead of uninitialized garbage. Signed-off-by: WEI CHENG CHIU <waynehacking8@gmail.com>
98e526b to
76c407d
Compare
|
Rebased onto current main ( |
Summary
DeepseekV3Gate.load_weightsaccessese_score_correction_biasunconditionally, but lite DeepSeek checkpoints (scoring_func=softmax,q_lora_rank=None, e.g. DeepSeek-V2-Lite) do not have this tensor — it is V3-specific (sigmoid routing with auxiliary-loss-free load balancing).DeepseekV3model class already supports these lite checkpoints (theis_lite = q_lora_rank is Nonebranches throughoutmodeling_deepseekv3.py), so a lite checkpoint served under a registered V3-family architecture reaches this gate and hits aKeyErroron load (e.g. an NVFP4-quantized DeepSeek-V2-Lite)..copy_()with a key-existence check, and zero-initialize the parameter (torch.empty→torch.zeros) so the missing-key path is a safe no-op —e_score_correction_biasis added to the routing scores (scores + e_score_correction_biasinnoaux_tc), so zero means "no correction". The same optional-bias guard is used by sibling gates (modeling_laguna.py,modeling_minimaxm2.py).Reproduction
Test plan
kv_b_projkept BF16) — warmup + generate produce coherent output after the fixpytest tests/unittest/)PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
Summary by CodeRabbit
Release Notes