[None][fix] Fix fused MHC for DeepSeek-V4-Pro hidden size#13771
Merged
pcastonguay merged 3 commits intoNVIDIA:feat/deepseek_v4from May 5, 2026
Merged
Conversation
Signed-off-by: Oseltamivir <bryansg2013@gmail.com>
Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com>
Signed-off-by: Patrice Castonguay <55748270+pcastonguay@users.noreply.github.com>
Collaborator
Author
|
/bot skip --comment "Just fixing pre-commit check" |
schetlur-nv
reviewed
May 5, 2026
Collaborator
|
PR_Github #46845 [ skip ] triggered by Bot. Commit: |
Collaborator
|
PR_Github #46845 [ skip ] completed with state |
lfr-0531
pushed a commit
that referenced
this pull request
May 7, 2026
Signed-off-by: Oseltamivir <bryansg2013@gmail.com> Signed-off-by: Mingyang Hao <mingyangHao@users.noreply.github.com> Signed-off-by: Patrice Castonguay <55748270+pcastonguay@users.noreply.github.com> Co-authored-by: Oseltamivir <bryansg2013@gmail.com> Co-authored-by: Mingyang Hao <mingyangHao@users.noreply.github.com> (cherry picked from commit 9aa3715) Signed-off-by: yuhangh <58161490+heyuhhh@users.noreply.github.com>
mingyangHao
added a commit
to mingyangHao/TensorRT-LLM
that referenced
this pull request
May 8, 2026
Pipelined micro-optimizations on top of the existing tcgen05 fused_hc infrastructure (NVIDIA#13771 added hidden=7168 support; this PR builds on that). Each change is isolated and gated by config / template constexpr. P0 — Path D KS=112 enable (Phase 4 scalar-vec tail) - fused_tf32_pmap_gemm.cuh: replace the `HIDDEN % (WARPS_PER_TOK * 32 * BF16_VEC_LI) == 0` static_assert with a scalar-vec tail loop that handles the residue past `H_VEC_END = (HIDDEN/H_STRIDE)*H_STRIDE`. Tail uses the same uint4 LDG/STG path so per-thread BW is unchanged; only some lanes/warps in the team idle on the last chunk. - mhcFusedHcKernel.cu: relax `isSupportedFhcMmaKS<H, KS>` to drop the team-stride alignment check (only `Hidden % BF16_VEC_LI == 0` and `h_tiles % KS == 0` remain). Add KS ∈ {7, 14, 28, 56, 112} cases to pickFhc and pickFhcAllInOne outer switches. - mhc_cuda.py: mirror the same trait change in `_fused_hc_mma_ks_supported`. Extend `_FUSED_HC_HALF_MMA_KS` / `_FUSED_HC_ALL_MMA_KS` to include the new factors. P1 — TMA descriptor cache - cuTensorMapEncodeTiled is a host-side ~1-2 µs call; each launch builds 4 descriptors, costing 4-8 µs (25-50% of total wall time at small M). - Add a thread-local `unordered_map<TmaDescKey, CUtensorMap>` keyed on (base ptr, gmem dims, strides, swizzle, dtype, device_id). Both launchers call `getCachedTma2D` instead of `makeTma2D`. - CUDA-graph compatible: cuTensorMapEncodeTiled records nothing into the stream, so cache miss inside capture is safe. Pointer stability across calls is already guaranteed by `_FusedHcWorkspaceCache` in mhc_cuda.py. - Return-by-value (CUtensorMap is 128 B POD); no rehash invalidation. P2 — KS=1 direct store + skip workspace zero - At KS=1 each (m_block, n) is owned by exactly one CTA, so the GEMM epilogue can write D / sqr_sum directly instead of via atomicAdd. Guarded by `if constexpr (kNumSplits == 1)` in both Path B mainloop and Path D Phase 2. - Launchers skip the `fhcZeroWorkspaces` kernel at KS=1 (y_acc / r_acc / done_counter all unused under the direct-store path; Phase 3 at KS=1 is just `__threadfence_block + __syncthreads`). - Effect: -1 kernel launch + -25 atomic ops per token at KS=1. P3 — Sinkhorn reciprocal multiply - Replace per-element `cm[k] / rs` with `cm[k] * inv_rs` (`inv_rs = 1.0f / rs`) in row-normalize. fp32 fdiv is multi-cycle on B200 vs fmul peak rate; row-normalize runs HC_MULT × sinkhorn_repeat times per token (160 fdivs at sinkhorn=20). Math equivalent under fp32 round-off; sinkhorn iteration absorbs last-bit drift. - Applied in: mhcKernels.cu BigFuse (Path B/E/F shared), Path D Phase 4 inline bigfuse, Path F Phase 4 inline bigfuse. Numerical: residual_cur identical, post_mix_cur within 1.2e-7, comb_mix_cur within 6e-8 (fp32 epsilon), layer_input within 1.5e-5 (bf16 round-off) vs upstream Path D KS=56 reference. Measured on idle B300 (sm_103) at V4-Pro shape (n=4, hidden=7168, sinkhorn=20): - half_mma KS=2 M=4096: 171.10 µs → 165.75 µs (-3%) - half_mma KS=1 M=2048: 216.20 µs → 212.19 µs (-2%) - half_mma KS=1 M=512: 188.35 µs → 185.90 µs (-1.3%) - half_mma KS=56 M=64 (P1): 24.52 µs → 23.87 µs (-2.7%) - all_mma KS=112 M=64 (P0): FAIL → 21.92 µs (newly possible) Autotuner-driven winners are unchanged in M ≤ 384 (still half_mma KS=112); the visible production gain is on M ≥ 1024 where KS=2/4 wins are touched by P1+P3. Signed-off-by: Mingyang Hao <mingyangh@nvidia.com> Signed-off-by: mingyangh <mingyangh@nvidia.com>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@coderabbitai summary
Description
Same as #13710 but fixes pre-commit check. Original author: @Oseltamivir
Test Coverage
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)
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.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.