Skip to content

[https://nvbugs/5836830][fix] Fix DeepSeekV3 W4A8 mixed precision quantization for MoE experts - #12149

Open
Barry-Delaney wants to merge 3 commits into
NVIDIA:mainfrom
Barry-Delaney:fix_w4a8
Open

[https://nvbugs/5836830][fix] Fix DeepSeekV3 W4A8 mixed precision quantization for MoE experts#12149
Barry-Delaney wants to merge 3 commits into
NVIDIA:mainfrom
Barry-Delaney:fix_w4a8

Conversation

@Barry-Delaney

@Barry-Delaney Barry-Delaney commented Mar 12, 2026

Copy link
Copy Markdown
Collaborator

Resolve per-expert quant config (e.g. W4A8_AWQ) from the global MIXED_PRECISION config so that MoE backends receive the correct quantization strategy. Previously the ambiguous MIXED_PRECISION config was passed through, causing assertion failures and incorrect weight loading.

Summary by CodeRabbit

  • Bug Fixes

    • Improved quantization configuration handling for mixture of expert layers, enabling more precise per-module quantization strategies instead of global settings.
  • Refactor

    • Centralized quantization configuration resolution to provide better flexibility in applying different precision modes across model components.

@Barry-Delaney Barry-Delaney self-assigned this Mar 12, 2026
@Barry-Delaney
Barry-Delaney requested review from a team as code owners March 12, 2026 08:13
@coderabbitai

coderabbitai Bot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The changes implement per-expert and per-module quantization override propagation in DeepSeek-v3 model construction and configurable MoE layers. Quantization configuration resolution is centralized at per-layer and per-expert initialization stages, replacing previous per-call recomputation with dedicated override configuration storage and application logic.

Changes

Cohort / File(s) Summary
MoE Quantization Configuration
tensorrt_llm/_torch/models/modeling_deepseekv3.py
Introduces per-expert quantization resolution for MIXED_PRECISION via expert_quant_config override. Defers weight loading mode decision to use expert_quant_config.layer_quant_mode.has_nvfp4(). Replaces hard assertion on MIXED_PRECISION with conservative per-module quant configuration approach for nvfp4 support determination.
Configurable MoE Backend
tensorrt_llm/_torch/modules/fused_moe/configurable_moe.py
Stores and applies per-module override_quant_config in init. Updates _get_quant_config_dict to prefer _override_quant_config fallback to model_config.quant_config. Expands quant mode extraction with additional boolean flags (has_nvfp4, has_w4afp8, has_fp8_block_scales) for precise quantization capability reporting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the issue (ambiguous MIXED_PRECISION config causing failures) and solution (per-expert quant config resolution), but lacks Test Coverage section and PR Checklist required by the template. Add the Test Coverage section listing relevant tests, and complete the PR Checklist with checkboxes to demonstrate review of NVIDIA coding guidelines and test coverage requirements.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main change: fixing W4A8 mixed precision quantization for MoE experts in DeepSeekV3, which aligns with the changeset's focus on resolving per-expert quantization configuration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.

Add a .trivyignore file to your project to customize which findings Trivy reports.

@Barry-Delaney

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38699 [ run ] triggered by Bot. Commit: 4e029cf Link to invocation

@litaotju litaotju left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean fix, good comments. One question: are there any test cases in CI or post-merge that exercise the MIXED_PRECISION path through MoE init (e.g. the W4AFP8 quickstart test from the bug)? Want to make sure this gets regression-covered going forward.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38699 [ run ] completed with state SUCCESS. Commit: 4e029cf
/LLM/main/L0_MergeRequest_PR pipeline #30018 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@Barry-Delaney Barry-Delaney changed the title [https://nvbugs/5955173][fix] Fix DeepSeekV3 W4A8 mixed precision quantization for MoE experts [https://nvbugs/5836830][fix] Fix DeepSeekV3 W4A8 mixed precision quantization for MoE experts Mar 13, 2026
@Barry-Delaney

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38831 [ run ] triggered by Bot. Commit: 474ec37 Link to invocation

@Barry-Delaney

Barry-Delaney commented Mar 13, 2026

Copy link
Copy Markdown
Collaborator Author

Are there any test cases in CI or post-merge that exercise the MIXED_PRECISION path through MoE init (e.g. the W4AFP8 quickstart test from the bug)? Want to make sure this gets regression-covered going forward.

Thanks on the review @litaotju! It seems the test is only covered in QA, I added one into post-merge in the latest commit.

@Barry-Delaney

Copy link
Copy Markdown
Collaborator Author

/bot kill

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38832 [ kill ] triggered by Bot. Commit: 801cb77 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38832 [ kill ] completed with state SUCCESS. Commit: 801cb77
Successfully killed previous jobs for commit 801cb77

Link to invocation

@Barry-Delaney

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38834 [ run ] triggered by Bot. Commit: f21ad31 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38834 [ run ] completed with state SUCCESS. Commit: f21ad31
/LLM/main/L0_MergeRequest_PR pipeline #30144 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@Barry-Delaney
Barry-Delaney force-pushed the fix_w4a8 branch 2 times, most recently from c1f1080 to b30bd67 Compare March 20, 2026 03:27
@Barry-Delaney

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #39677 [ run ] triggered by Bot. Commit: b30bd67 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #42317 [ run ] completed with state SUCCESS. Commit: ca8c7c5
/LLM/main/L0_MergeRequest_PR pipeline #33108 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@Barry-Delaney

Copy link
Copy Markdown
Collaborator Author

/bot run

@Barry-Delaney
Barry-Delaney force-pushed the fix_w4a8 branch 2 times, most recently from c0d799b to 8343239 Compare April 9, 2026 07:22
@Barry-Delaney

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #42498 [ run ] triggered by Bot. Commit: 8343239 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #42498 [ run ] completed with state SUCCESS. Commit: 8343239
/LLM/main/L0_MergeRequest_PR pipeline #33245 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@Barry-Delaney

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #43196 [ run ] triggered by Bot. Commit: 7cacaf2 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #43196 [ run ] completed with state DISABLED
Freeze main and open the PR merge only after CI is back to healthy https://nvidia.slack.com/archives/C059LSY62BT/p1776141760843319?thread_ts=1775985925.442509&cid=C059LSY62BT

Link to invocation

@Barry-Delaney

Copy link
Copy Markdown
Collaborator Author

/bot kill

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #43201 [ kill ] triggered by Bot. Commit: 7cacaf2 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #43201 [ kill ] completed with state SUCCESS. Commit: 7cacaf2
Successfully killed previous jobs for commit 7cacaf2

Link to invocation

@Barry-Delaney

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #43612 [ run ] triggered by Bot. Commit: 4041fe3 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #43612 [ run ] completed with state FAILURE. Commit: 4041fe3
/LLM/main/L0_MergeRequest_PR pipeline #34104 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@Barry-Delaney

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #43713 [ run ] triggered by Bot. Commit: a55f022 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #43713 [ run ] completed with state FAILURE. Commit: a55f022
/LLM/main/L0_MergeRequest_PR pipeline #34196 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

Barry-Delaney and others added 3 commits April 22, 2026 16:57
Resolve per-expert quant config (e.g. W4A8_AWQ) from the global
MIXED_PRECISION config so that MoE backends receive the correct
quantization strategy. Previously the ambiguous MIXED_PRECISION
config was passed through, causing assertion failures and incorrect
weight loading.

For non-MIXED_PRECISION cases (e.g. nvfp4, unquantized MTP layers),
pass override_quant_config through as-is since it already encodes
the correct exclusions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Barry Kang <43644113+Barry-Delaney@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Barry Kang <43644113+Barry-Delaney@users.noreply.github.com>
Signed-off-by: Barry Kang <43644113+Barry-Delaney@users.noreply.github.com>
@Barry-Delaney

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #44944 [ run ] triggered by Bot. Commit: 88a2e8d Link to invocation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants