Skip to content

[None][fix] Fix fused mHC RMS normalization - #13587

Merged
lfr-0531 merged 2 commits into
NVIDIA:feat/deepseek_v4from
mingyangHao:mhc-fused-rms-denominator-fix
Apr 29, 2026
Merged

[None][fix] Fix fused mHC RMS normalization#13587
lfr-0531 merged 2 commits into
NVIDIA:feat/deepseek_v4from
mingyangHao:mhc-fused-rms-denominator-fix

Conversation

@mingyangHao

@mingyangHao mingyangHao commented Apr 29, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai summary

Description

Fused mHC computes RMS statistics over the flattened hyper-connection residual whose logical K is hc_mult * hidden_size. The fused_hc half-MMA/FMA paths passed only hidden_size into the big-fuse RMS postlogue, and the all-MMA path used hidden_size in its inline RMS
normalization. For DeepSeek-V4 Flash this scaled rstd incorrectly and caused the GSM8K accuracy drop when TRTLLM_MHC_ENABLE_FUSED_HC=1.

This PR changes fused_hc RMS normalization to use the full mHC K in both big-fuse and all-MMA inline paths. It also adds a real-scale regression test covering fused_half_mma, fused_half_fma, fused_all_mma, and fused_all_fma.

No API changes, new dependencies, ownership changes, or documentation updates are required.

Test Coverage

  • pre-commit run --show-diff-on-failure --files cpp/tensorrt_llm/kernels/mhcKernels/mhcFusedHcKernel.cu cpp/tensorrt_llm/kernels/mhcKernels/fused_tf32_pmap_gemm.cuh tests/unittest/_torch/modules/test_mhc.py
  • Docker pytest: tests/unittest/_torch/modules/test_mhc.py::test_mhc_fused_hc_realistic_scale_regression (4 passed)
  • Docker DeepSeek-V4-Flash GSM8K fused_hc enabled: 96.29
  • Docker DeepSeek-V4-Flash GSM8K fused_hc disabled: 96.06
  • Previous bad fused_hc enabled baseline: 78.66

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths.

  • 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.

Fused mHC computes RMS statistics over the flattened hyper-connection residual whose logical K is hc_mult * hidden_size. The fused half-MMA/FMA paths passed hidden_size into the big-fuse RMS postlogue, and the all-MMA path used hidden_size in its inline RMS normalization. That scaled rstd incorrectly for DeepSeek-V4 Flash and caused the GSM8K accuracy drop when fused_hc was enabled.

Use the full mHC K for RMS normalization in the fused_hc big-fuse calls and the all-MMA inline path. Add a real-scale regression test that covers fused_half_mma, fused_half_fma, fused_all_mma, and fused_all_fma.

Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
@mingyangHao
mingyangHao force-pushed the mhc-fused-rms-denominator-fix branch from 3df8bc8 to 1df26e1 Compare April 29, 2026 01:52
@mingyangHao mingyangHao changed the title Fix fused mHC RMS normalization [None][fix] Fix fused mHC RMS normalization Apr 29, 2026
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
@mingyangHao
mingyangHao requested a review from a team as a code owner April 29, 2026 07:56
@mingyangHao
mingyangHao requested review from brb-nv and removed request for a team April 29, 2026 07:56
@lfr-0531
lfr-0531 merged commit 87a6026 into NVIDIA:feat/deepseek_v4 Apr 29, 2026
3 of 4 checks passed
lfr-0531 pushed a commit that referenced this pull request May 7, 2026
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
lfr-0531 pushed a commit that referenced this pull request May 14, 2026
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request May 29, 2026
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
(cherry picked from commit 3303f1c)
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 1, 2026
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
(cherry picked from commit 3303f1c)
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 3, 2026
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
(cherry picked from commit 3303f1c)
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 7, 2026
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
(cherry picked from commit 3303f1c)
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 10, 2026
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 11, 2026
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 12, 2026
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 12, 2026
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
(cherry picked from commit 3303f1c)
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 13, 2026
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
(cherry picked from commit 3303f1c)
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 16, 2026
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
(cherry picked from commit 3303f1c)
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 17, 2026
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
(cherry picked from commit 3303f1c)
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants