[None][feat] Support DeepSeek-V4 in layer_wise_benchmarks#16774
Conversation
DeepSeek-V4's multi-head hyper-connection (mHC) decoder layers do not fit the generic single-layer harness in tools/layer_wise_benchmarks/runner.py: - create_kv_cache_manager: the is_mla branch omitted vocab_size, which DeepseekV4CacheManager.__init__ requires (keyword-only, no default). - create_run_pack: V4 layers take the initial residual as hc_state shaped [num_tokens, hc_mult, hidden_size] and their MoE routing needs input_ids; both are now synthesized when the config exposes hc_mult. - run_pack(check=True): guarded the NaN/Inf/zero check with isinstance since mHC layers return an HCState, not a Tensor. Non-V4 models are unaffected (all V4 paths gate on hc_mult / MLA class). Usage for V4: --moe-backend DEEPGEMM and a --layer-indices slice that starts at layer 0 and covers both compress ratios (e.g. 0,1,2,3). Signed-off-by: Ruodi Lu <ruodil@users.noreply.github.com>
WalkthroughThe layer-wise benchmark runner now prepares DeepSeek-V4 hyper-connection inputs, conditionally validates tensor outputs, and passes vocabulary size when constructing MLA KV-cache managers. ChangesBenchmark runner behavior
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tensorrt_llm/tools/layer_wise_benchmarks/runner.py (1)
664-678: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a regression test for the V4 input contract.
Cover
hc_mult=4and a non-V4 configuration, asserting the expanded hidden-state shape and generatedinput_idsdtype/range. DeepSeek-V4 relies on expanded mHC residual streams and token-ID-based hash routing. (nvidia.github.io)🤖 Prompt for 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. In `@tensorrt_llm/tools/layer_wise_benchmarks/runner.py` around lines 664 - 678, Add a regression test covering the input-preparation logic around the hc_mult handling, using hc_mult=4 and a non-V4 configuration. Assert that V4 hidden states expand to [num_tokens, 4, hidden_size], generated input_ids use torch.int32 and remain within [0, vocab_size), while the non-V4 path preserves the original hidden-state shape and does not add input_ids.
🤖 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.
Nitpick comments:
In `@tensorrt_llm/tools/layer_wise_benchmarks/runner.py`:
- Around line 664-678: Add a regression test covering the input-preparation
logic around the hc_mult handling, using hc_mult=4 and a non-V4 configuration.
Assert that V4 hidden states expand to [num_tokens, 4, hidden_size], generated
input_ids use torch.int32 and remain within [0, vocab_size), while the non-V4
path preserves the original hidden-state shape and does not add input_ids.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: a39b3908-7632-403f-a51a-3f1331349703
📒 Files selected for processing (1)
tensorrt_llm/tools/layer_wise_benchmarks/runner.py
|
/bot run |
|
PR_Github #61203 [ run ] triggered by Bot. Commit: |
|
PR_Github #61203 [ run ] completed with state
|
DeepSeek-V4's multi-head hyper-connection (mHC) decoder layers do not fit the generic single-layer harness in tools/layer_wise_benchmarks/runner.py:
Non-V4 models are unaffected (all V4 paths gate on hc_mult / MLA class).
Usage for V4: --moe-backend DEEPGEMM and a --layer-indices slice that starts at layer 0 and covers both compress ratios (e.g. 0,1,2,3).
Dev Engineer Review
runner.pyby:vocab_sizeto the MLA KV-cache manager.hc_stateandinput_idsfor mHC layers.--moe-backend DEEPGEMMand layer indices beginning at 0 and covering both compression ratios, e.g.0,1,2,3.QA Engineer Review
No test changes.
Description
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)
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.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.