Repository navigation
[None][fix] Update the default invalid value for deepseek mode of routing - #9222
Conversation
|
/bot run --disable-fail-fast |
|
PR_Github #24765 [ run ] triggered by Bot. Commit: |
📝 WalkthroughWalkthroughChanges replace the invalid score sentinel value from -1.F to negative infinity across kernel and test files. A cmath header include is added to support the INFINITY constant definition. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
cpp/tensorrt_llm/kernels/noAuxTcKernels.cu(2 hunks)cpp/tensorrt_llm/kernels/trtllmGenKernels/blockScaleMoe/RoutingDeepSeek.cu(1 hunks)cpp/tests/unit_tests/kernels/routing/routingDeepSeekTest.cpp(1 hunks)
🧰 Additional context used
🧠 Learnings (13)
📓 Common learnings
Learnt from: jhaotingc
Repo: NVIDIA/TensorRT-LLM PR: 7856
File: cpp/tensorrt_llm/thop/fp8BlockScaleMoe.cpp:159-166
Timestamp: 2025-09-19T21:28:13.751Z
Learning: In TensorRT-LLM blockScaleMoe routing (cpp/tensorrt_llm/kernels/trtllmGenKernels/blockScaleMoe/runner.cu), the DeepSeek routing method performs reinterpret_cast<float*>(routingLogits) at line 89, which could cause issues if routing_logits are BF16. However, Qwen3-FP8 models use RenormalizeNaive routing method and are not affected by this dtype casting issue.
📚 Learning: 2025-09-19T21:28:13.751Z
Learnt from: jhaotingc
Repo: NVIDIA/TensorRT-LLM PR: 7856
File: cpp/tensorrt_llm/thop/fp8BlockScaleMoe.cpp:159-166
Timestamp: 2025-09-19T21:28:13.751Z
Learning: In TensorRT-LLM blockScaleMoe routing (cpp/tensorrt_llm/kernels/trtllmGenKernels/blockScaleMoe/runner.cu), the DeepSeek routing method performs reinterpret_cast<float*>(routingLogits) at line 89, which could cause issues if routing_logits are BF16. However, Qwen3-FP8 models use RenormalizeNaive routing method and are not affected by this dtype casting issue.
Applied to files:
cpp/tensorrt_llm/kernels/trtllmGenKernels/blockScaleMoe/RoutingDeepSeek.cu
📚 Learning: 2025-08-08T22:03:40.707Z
Learnt from: sklevtsov-nvidia
Repo: NVIDIA/TensorRT-LLM PR: 3294
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:1198-1209
Timestamp: 2025-08-08T22:03:40.707Z
Learning: In the CUTLASS MoE kernels (cpp/tensorrt_llm/cutlass_extensions), when `layout_info.fusion` is set to `TmaWarpSpecializedGroupedGemmInput::EpilogueFusion::FINALIZE`, the `router_scales` parameter must be non-null by design. The fused finalize kernel epilogue does not perform nullptr checks and requires valid router scales to function correctly. This is an implicit contract that callers must satisfy when enabling the FINALIZE fusion mode.
Applied to files:
cpp/tensorrt_llm/kernels/trtllmGenKernels/blockScaleMoe/RoutingDeepSeek.cu
📚 Learning: 2025-09-23T15:01:00.070Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/kernels/nccl_device/config.cu:15-17
Timestamp: 2025-09-23T15:01:00.070Z
Learning: In TensorRT-LLM NCCL device kernels, the <sstream> header is not needed as an explicit include in config.cu because it's provided transitively through other headers. Local compilation testing confirms this works without the explicit include.
Applied to files:
cpp/tensorrt_llm/kernels/noAuxTcKernels.cu
📚 Learning: 2025-09-23T15:13:48.819Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/kernels/nccl_device/multimem.h:20-30
Timestamp: 2025-09-23T15:13:48.819Z
Learning: TRT-LLM targets modern CUDA toolkits that support FP8 datatypes, so cuda_fp8.h can be included unconditionally without version guards in TRT-LLM code.
Applied to files:
cpp/tensorrt_llm/kernels/noAuxTcKernels.cu
📚 Learning: 2025-09-23T15:01:00.070Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/kernels/nccl_device/config.cu:15-17
Timestamp: 2025-09-23T15:01:00.070Z
Learning: In TensorRT-LLM NCCL device kernels (cpp/tensorrt_llm/kernels/nccl_device/config.cu), std::ostringstream is used but <sstream> doesn't need to be explicitly included because it's provided transitively through other headers like tensorrt_llm/common/cudaUtils.h or config.h. Local compilation testing confirms this works without the explicit include.
Applied to files:
cpp/tensorrt_llm/kernels/noAuxTcKernels.cu
📚 Learning: 2025-09-23T14:58:05.372Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/kernels/nccl_device/config.cu:42-49
Timestamp: 2025-09-23T14:58:05.372Z
Learning: In TensorRT-LLM NCCL device kernels (cpp/tensorrt_llm/kernels/nccl_device/), the token partitioning intentionally uses ceil-like distribution (same token_per_rank for all ranks) to ensure all ranks launch the same number of blocks. This is required for optimal NCCL device API barrier performance, even though it may launch extra blocks for non-existent tokens on later ranks. Runtime bounds checking in the kernel (blockID validation) handles the overshoot cases.
Applied to files:
cpp/tensorrt_llm/kernels/noAuxTcKernels.cu
📚 Learning: 2025-09-23T15:12:38.312Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device implementation, NCCL version 2.28+ requirements are handled at runtime in the nccl_device/config layer rather than with compile-time guards. This allows the allreduceOp to remain version-agnostic and delegates version compatibility validation to the appropriate lower-level components that can gracefully handle unsupported configurations.
Applied to files:
cpp/tensorrt_llm/kernels/noAuxTcKernels.cu
📚 Learning: 2025-09-23T15:12:38.312Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device allreduce implementation (cpp/tensorrt_llm/thop/allreduceOp.cpp), the goto pattern in runNCCLAllReduceDeviceFusion is intentionally used for future extensibility, allowing multiple switch cases to fallback to the default handler. While not aesthetically ideal, this pattern supports adding more fusion cases later that can reuse the same fallback logic.
Applied to files:
cpp/tensorrt_llm/kernels/noAuxTcKernels.cu
📚 Learning: 2025-09-24T03:31:28.908Z
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 7520
File: tensorrt_llm/_torch/pyexecutor/resource_manager.py:605-613
Timestamp: 2025-09-24T03:31:28.908Z
Learning: In TensorRT-LLM Ray orchestrator mode, ProcessGroups are initialized with both Gloo and NCCL backends (e.g., "cuda:nccl,cpu:gloo"), allowing PyTorch distributed to automatically route CPU tensors through Gloo and GPU tensors through NCCL. This eliminates the need for manual device placement when performing allreduce operations on base types.
Applied to files:
cpp/tensorrt_llm/kernels/noAuxTcKernels.cu
📚 Learning: 2025-08-08T05:06:31.596Z
Learnt from: sklevtsov-nvidia
Repo: NVIDIA/TensorRT-LLM PR: 3294
File: cpp/tensorrt_llm/cutlass_extensions/include/cutlass_extensions/epilogue/fusion/sm90_visitor_scatter.hpp:36-36
Timestamp: 2025-08-08T05:06:31.596Z
Learning: CUTLASS extension files (under cpp/tensorrt_llm/cutlass_extensions/) follow CUTLASS coding style conventions, including using #pragma once instead of TRTLLM_ prefixed header guards, even though they are .hpp files.
Applied to files:
cpp/tensorrt_llm/kernels/noAuxTcKernels.cu
📚 Learning: 2025-08-21T21:48:35.135Z
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 7104
File: cpp/tensorrt_llm/cutlass_extensions/include/cutlass_extensions/epilogue/fusion/sm90_visitor_scatter.hpp:399-417
Timestamp: 2025-08-21T21:48:35.135Z
Learning: CUTLASS extensions in TensorRT-LLM (located under cpp/tensorrt_llm/cutlass_extensions/) are designed to integrate with and extend functionality in the external CUTLASS repository. When analyzing these extensions, their consumers and functionality wiring may exist in the CUTLASS codebase rather than within TensorRT-LLM itself.
Applied to files:
cpp/tensorrt_llm/kernels/noAuxTcKernels.cu
📚 Learning: 2025-09-16T09:30:09.716Z
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 7763
File: cpp/tensorrt_llm/CMakeLists.txt:297-301
Timestamp: 2025-09-16T09:30:09.716Z
Learning: In the TensorRT-LLM project, NCCL libraries are loaded earlier by PyTorch libraries or the bindings library, so the main shared library doesn't need NCCL paths in its RPATH - the libraries will already be available in the process address space when needed.
Applied to files:
cpp/tensorrt_llm/kernels/noAuxTcKernels.cu
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Pre-commit Check
🔇 Additional comments (3)
cpp/tensorrt_llm/kernels/noAuxTcKernels.cu (2)
22-22: LGTM: Correct include for INFINITY constant.The
<cmath>header is properly added to access theINFINITYmacro used on line 80.
80-81: Excellent improvement: Using -INFINITY as invalid score sentinel.The change from
-1.Fto-INFINITYis semantically clearer and more robust. Since sigmoid-activated scores are strictly positive (as noted in the comment), negative infinity provides a guaranteed minimum value that cannot conflict with any valid score, regardless of expert count.cpp/tensorrt_llm/kernels/trtllmGenKernels/blockScaleMoe/RoutingDeepSeek.cu (1)
66-67: INFINITY is available through transitive includes—code change verified and approved.RoutingKernel.cuh successfully uses
INFINITY(lines 140, 177) without an explicit#include <cmath>, confirming that the macro is available through its transitive includes (cooperative_groups.h,cub/cub.cuh, cutlass, cute). RoutingDeepSeek.cu inherits this transitive availability through its#include "RoutingKernel.cuh". This follows TRT-LLM's documented pattern of accepting transitive includes for standard headers. The sentinel value change from-1.Fto-INFINITYis robust and correct.
Signed-off-by: Christina Zhang <[email protected]>
bd7a87e to
7e2e493
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #24769 [ run ] triggered by Bot. Commit: |
|
PR_Github #24765 [ run ] completed with state |
|
/bot run --disable-fail-fast |
|
PR_Github #24814 [ run ] triggered by Bot. Commit: |
|
PR_Github #24769 [ run ] completed with state |
|
PR_Github #24814 [ run ] completed with state |
nvxuanyuc
left a comment
There was a problem hiding this comment.
LGTM. Have verified correctness on GLM 4.6 nvfp4 with cutlass and trtllmgen backends.
…ting (NVIDIA#9222) Signed-off-by: Christina Zhang <[email protected]> Signed-off-by: lkomali <[email protected]>
…o flashinfer 70076772 and take the grouped token range Pins flashinfer-prims-ts to the fork lineage branch harrisonzhy/trtllm-prims-ts-dev-20261107_vc-attn-fixes-911d6a9d: the canonical trtllm-prims-ts-dev-20261107 commit 911d6a9d, the pin of this branch, plus the VC-Attention fixes of flashinfer PRs 8549 (exact row max for E4M3 V, P scaled by 448) and 9549 (pre-pass V gather clamp past the sequence, k-means generator owned by the preprocessor with a cold start per generation, grouping restricted to a token range, masked tail padding of a V repair plan), cherry-picked. The vendored tree is a byte copy of the fork plus the compatibility patch, regenerated at the new revision; the patch content is unchanged. Against the previous pin 911d6a9d the sync also carries flashinfer 2ffd3f8b (NVIDIA#9222, runtime QToken sparse attention performance). The visual-gen TRTLLM attention backend takes ``grouped_tokens=(start, stop)``, the token range the value grouping covers, and passes it to the VC preprocessor. No caller sets it yet, so the grouping covers the whole sequence as before. Under the CUDA graph runner the V-Smooth phase now names the preprocessor path outright (cold at step 0, warm on a refresh step, keep inside the window, plain after it) instead of standing in a representative step, so the captured graphs record no step bookkeeping and the cold graph no random draw: a cold start takes its seed rows from a fixed host draw and replays the same grouping as eager. Signed-off-by: Harrison Zhang <[email protected]>
…o flashinfer 70076772 and take the grouped token range Pins flashinfer-prims-ts to the fork lineage branch harrisonzhy/trtllm-prims-ts-dev-20261107_vc-attn-fixes-911d6a9d: the canonical trtllm-prims-ts-dev-20261107 commit 911d6a9d, the pin of this branch, plus the VC-Attention fixes of flashinfer PRs 8549 (exact row max for E4M3 V, P scaled by 448) and 9549 (pre-pass V gather clamp past the sequence, k-means generator owned by the preprocessor with a cold start per generation, grouping restricted to a token range, masked tail padding of a V repair plan), cherry-picked. The vendored tree is a byte copy of the fork plus the compatibility patch, regenerated at the new revision; the patch content is unchanged. Against the previous pin 911d6a9d the sync also carries flashinfer 2ffd3f8b (NVIDIA#9222, runtime QToken sparse attention performance). The visual-gen TRTLLM attention backend takes ``grouped_tokens=(start, stop)``, the token range the value grouping covers, and passes it to the VC preprocessor. No caller sets it yet, so the grouping covers the whole sequence as before. Under the CUDA graph runner the V-Smooth phase now names the preprocessor path outright (cold at step 0, warm on a refresh step, keep inside the window, plain after it) instead of standing in a representative step, so the captured graphs record no step bookkeeping and the cold graph no random draw: a cold start takes its seed rows from a fixed host draw and replays the same grouping as eager. Signed-off-by: Harrison Zhang <[email protected]>
…llow-up on the dev tip Pin tensorrt_llm/_torch/attention/backends/prims_ts to kris1025/flashinfer linquanh/trtllm-prims-ts-dev-ds41-followup-r3 at d8c40b52f9. That branch is the PrimTS dev branch main pins (yuxianq/flashinfer trtllm-prims-ts-dev-20261107 at d81912f0b, NVIDIA#22274) plus: - the FlashInfer main PrimTS changes the dev branch lacks, in order: flashinfer-ai/flashinfer#6988, NVIDIA#9315, NVIDIA#9375 and NVIDIA#9224 (NVIDIA#9087, NVIDIA#9222, NVIDIA#5489 and NVIDIA#8549 are already on it). Where they meet the dev branch's CUTLASS DSL 4.9 task-API changes (runtime_domain_end, consumer_work_stage, _resolve_domain, ContextTask), the conflict resolutions keep the upstream logic in the dev branch's form; - the DeepSeek-V4.1 sparse MLA decode commits of flashinfer-ai/flashinfer#9701: the FP8+NVFP4 one-CTA Keep-AB decode, PDL after the prologue, FP8 tiles TMA-gathered into the retained K/V tile, the TMA-staged Q slot released after the last QK, and their tests; - one commit that puts the loops and stage reads NVIDIA#9315 and NVIDIA#9375 added in that same form; on the CuTe DSL 4.7/4.8 task API it changes nothing. The compatibility patch is main's, regenerated for the new pin, plus one adaptation: _hardware.py's SM107 check imports flashinfer.cute_dsl.availability absolutely, since its relative import would leave the vendored package. The vendored tree differs from main's only in the 29 files the follow-up commits change, and main's PrimTS users run on it unchanged. Signed-off-by: linquanh <[email protected]>
…llow-up on the dev tip Pin tensorrt_llm/_torch/attention/backends/prims_ts to kris1025/flashinfer linquanh/trtllm-prims-ts-dev-ds41-followup-r3 at d8c40b52f9. That branch is the PrimTS dev branch main pins (yuxianq/flashinfer trtllm-prims-ts-dev-20261107 at d81912f0b, NVIDIA#22274) plus: - the FlashInfer main PrimTS changes the dev branch lacks, in order: flashinfer-ai/flashinfer#6988, NVIDIA#9315, NVIDIA#9375 and NVIDIA#9224 (NVIDIA#9087, NVIDIA#9222, NVIDIA#5489 and NVIDIA#8549 are already on it). Where they meet the dev branch's CUTLASS DSL 4.9 task-API changes (runtime_domain_end, consumer_work_stage, _resolve_domain, ContextTask), the conflict resolutions keep the upstream logic in the dev branch's form; - the DeepSeek-V4.1 sparse MLA decode commits of flashinfer-ai/flashinfer#9701: the FP8+NVFP4 one-CTA Keep-AB decode, PDL after the prologue, FP8 tiles TMA-gathered into the retained K/V tile, the TMA-staged Q slot released after the last QK, and their tests; - one commit that puts the loops and stage reads NVIDIA#9315 and NVIDIA#9375 added in that same form; on the CuTe DSL 4.7/4.8 task API it changes nothing. The compatibility patch is main's, regenerated for the new pin, plus one adaptation: _hardware.py's SM107 check imports flashinfer.cute_dsl.availability absolutely, since its relative import would leave the vendored package. The vendored tree differs from main's only in the 29 files the follow-up commits change, and main's PrimTS users run on it unchanged. Signed-off-by: linquanh <[email protected]>
Summary by CodeRabbit
Description
The usage of the default invalid value is extended to handle arbitrary expert numbers larger than 128. For example, expert number 160.
Test Coverage
pytest -s tests/unittest/_torch/thop/parallel/test_noaux_tc.py
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
/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...Provide a user friendly way for developers to interact with a Jenkins server.
Run
/bot [-h|--help]to print this help message.See details below for each supported subcommand.
Details
run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]Launch build/test pipelines. All previously running jobs will be killed.
--reuse-test (optional)pipeline-id(OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.--disable-reuse-test(OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.--disable-fail-fast(OPTIONAL) : Disable fail fast on build/tests/infra failures.--skip-test(OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.--stage-list "A10-PyTorch-1, xxx"(OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.--gpu-type "A30, H100_PCIe"(OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.--test-backend "pytorch, cpp"(OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.--only-multi-gpu-test(OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.--disable-multi-gpu-test(OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.--add-multi-gpu-test(OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.--post-merge(OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx"(OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".--detailed-log(OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.--debug(OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in thestage-listparameter to access the appropriate container environment. Note: Does NOT update GitHub check status.For guidance on mapping tests to stage names, see
docs/source/reference/ci-overview.mdand the
scripts/test_to_stage_mapping.pyhelper.kill
killKill all running builds associated with pull request.
skip
skip --comment COMMENTSkip testing for latest commit on pull request.
--comment "Reason for skipping build/test"is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.reuse-pipeline
reuse-pipelineReuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.