Skip to content

[None][feat] DSv4 prep: IndexerTopK and TopK primitives#15381

Merged
longlee0622 merged 2 commits into
NVIDIA:mainfrom
lfr-0531:user/fanrongl/dsv4-indexer-topk
Jun 24, 2026
Merged

[None][feat] DSv4 prep: IndexerTopK and TopK primitives#15381
longlee0622 merged 2 commits into
NVIDIA:mainfrom
lfr-0531:user/fanrongl/dsv4-indexer-topk

Conversation

@lfr-0531

@lfr-0531 lfr-0531 commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

Release Notes

  • New Features

    • Added compression ratio support for optimized KV cache handling during decoding operations
    • Introduced auxiliary buffer management for improved decoding performance across different hardware configurations
  • Bug Fixes

    • Fixed edge cases in decoding block scheduling and hardware saturation scenarios
  • Tests

    • Expanded test coverage for compressed KV operations and decoding path transitions

Description

This is PR 3 from the staged split of #14751. It lands the IndexerTopK and heuristic TopK primitives as an independent, reviewable change while keeping DSv4 sparse attention dispatch, compressor/mHC, MoE routing, and DSv4 model/tokenizer integration in later PRs.

Changes included here:

  • Update the IndexerTopK CUDA kernel and thop binding.
  • Update heuristic TopK decode kernel entry points and policy behavior.
  • Register the updated fake custom-op schema for indexer_topk_decode, including compress_ratio, radix_aux_indices, and radix_aux_logits.
  • Expand focused IndexerTopK/heuristic TopK unit coverage in tests/unittest/_torch/thop/parallel/test_indexer_topk.py.

Deferred by design:

  • test_deepseek_v4_fp4_indexer.py remains deferred to the later sparse attention/model PR because it imports DSv4 sparse config/backend pieces.
  • RoutingKernelTopK.cuh and MoE routing changes remain deferred to the MoE/routing PR.
  • Sparse MLA backend dispatch and attention op plumbing remain in separate PRs.

No new dependency is introduced.

Test Coverage

  • Built TensorRT-LLM from this branch with:
    python3 ./scripts/build_wheel.py --trt_root /usr/local/tensorrt --benchmarks --use_ccache --cuda_architectures "90-real;100-real" --configure_cmake
  • Confirmed the build compiled indexerTopK.cu, heuristicTopKDecode.cu, and IndexerTopKOp.cpp; the wheel was produced successfully as build/tensorrt_llm-1.3.0rc18-cp312-cp312-linux_x86_64.whl.
  • Installed the built wheel into .venv-3.12 and ran an import smoke test from this worktree. tensorrt_llm.__file__ and cpp_custom_ops.__file__ both resolved under this branch, and torch.ops.trtllm.indexer_topk_decode / indexer_topk_prefill were present.
  • Checked GPU state before testing; selected idle GPU 0.
  • Ran:
    CUDA_VISIBLE_DEVICES=0 timeout 1800 .venv-3.12/bin/python -m pytest -q --tb=short -ra tests/unittest/_torch/thop/parallel/test_indexer_topk.py
    Result: 2871 passed, 2 warnings in 926.27s (0:15:26).
  • Ran:
    pre-commit run --files $(git diff --name-only HEAD)
    Result: passed.
  • Ran scope leakage check. The diff contains only the intended IndexerTopK/heuristic TopK files, and forbidden grep for sparse MLA backend, compressor/mHC, RoutingKernelTopK, MoE, DSv4 model/tokenizer, attention op plumbing, and DSA relocation tests returned no output.

Build note: the attribution generation step emitted ninja -t inputs returned no results for wheel targets, but the wheel build completed with exit code 0. This is the same non-fatal attribution warning observed in the preceding split PR.

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-compatible or api-breaking. For api-breaking, include BREAKING in 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.

@lfr-0531
lfr-0531 requested a review from a team as a code owner June 15, 2026 16:32
@lfr-0531
lfr-0531 requested a review from yizhang-nv June 15, 2026 16:32
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR extends the IndexerTopK CUDA decode pipeline with a compressRatio parameter for compressed-KV support, replaces scratch-buffer-based multi-pass radix dispatch with caller-owned auxiliary buffers and a new "Scheme X" hardware-derived block-per-row selection, refactors shared-memory layout and histogram state in the core CUDA kernels, updates the Torch operator boundary to match, and adds DSv4 (cr=4) test coverage.

Changes

IndexerTopK compressRatio & Scheme X Dispatch

Layer / File(s) Summary
Public API contracts (headers)
cpp/tensorrt_llm/kernels/IndexerTopK.h, cpp/tensorrt_llm/kernels/heuristicTopKDecode.h
computeIndexerTopKDecodeBlocksPerRow is added. All three invokeIndexerTopKDecode overloads replace scratch/scratchBytes/is_prefill with outLogitsAux/outIndicesAux and compressRatio. indexerTopKDecodeScratchBytes is removed. launchHeuristicTopKDecode gains int compressRatio before cudaStream_t across all overloads.
Heuristic TopK decode kernel: compressRatio propagation
cpp/tensorrt_llm/kernels/heuristicTopKDecode.cu
fp32 and bf16/fp16 multi-row kernels derive actual_kv_len = seq_len / compressRatio and gate preIdxOffset on compressRatio == 1. Template instantiations, the internal launch impl, and all three public overloads are updated to propagate compressRatio.
Core CUDA kernel: SMEM layout, histogram fixes, compressRatio in decode
cpp/tensorrt_llm/kernels/indexerTopK.cu
Introduces kNumBins=2048. processHistogramStep step-1 resets shared counters. processBins drops step0WillContinue gating. topKPerRowJob replaces wrapper SMEM with a direct __shared__ union; radix path initializes indices to -1 sentinels and bounds reads on smemFinalDstIdx. topKPerRowDecode incorporates compressRatio into rowEnd.
Scheme X dispatch and block-per-row selection
cpp/tensorrt_llm/kernels/indexerTopK.cu
New tuning constants and computeIndexerTopKDecodeBlocksPerRow select blocksPerRow from SM-count bounds. fp32 dispatcher routes to GVR heuristic, single-block, or split-and-merge with stream serialization. bf16/fp16 dispatcher enforces tier limits and throws on unsupported split-work. Prefill splits into insertion-sort and radix-sort launches at kSortingAlgorithmThreshold.
Torch operator wiring and PyTorch fake-op update
cpp/tensorrt_llm/thop/IndexerTopKOp.cpp, tensorrt_llm/_torch/custom_ops/cpp_custom_ops.py
indexer_topk_decode accepts heuristic_scratch, compress_ratio, radix_aux_indices, radix_aux_logits; removes prior scratch/is_prefill parameters; enforces compress_ratio > 0 and CUDA-graph-safe aux buffer presence for multi-block. indexer_topk_decode_scratch_bytes and its Torch registration are removed. Torch schema and fake-op signature are updated to match.
Test suite: compressRatio, Scheme X, radix aux, DSv4
tests/unittest/_torch/thop/parallel/test_indexer_topk.py
_run_indexer_topk_decode_check centralizes decode correctness with compress_ratio and radix aux setup. New tests cover SM saturation, launch-policy transitions, radix aux invariance, CUDA Graph replay, and aux validation errors. DSv4 helpers and test_indexer_topk_decode_dist_v4_cr4 add cr=4 GVR coverage; direct GVR heuristic test is removed.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller (Python/Torch)
    participant TorchOp as indexer_topk_decode (IndexerTopKOp.cpp)
    participant SchemeX as computeIndexerTopKDecodeBlocksPerRow
    participant GVR as launchHeuristicTopKDecode
    participant Radix as invokeIndexerTopKDecode (fp32 split-and-merge)
    participant SingleBlock as invokeIndexerTopKDecode (single-block)

    Caller->>TorchOp: logits, seq_lens, compress_ratio, radix_aux_indices, radix_aux_logits
    TorchOp->>TorchOp: TORCH_CHECK(compress_ratio > 0)
    TorchOp->>SchemeX: numRows, numColumns, splitWorkThreshold
    SchemeX-->>TorchOp: blocksPerRow
    alt canUseGvr and eligible
        TorchOp->>GVR: logits, compressRatio, heuristicScratch
        GVR-->>TorchOp: indices
    else blocksPerRow == 1
        TorchOp->>SingleBlock: logits, outIndices, compressRatio
        SingleBlock-->>TorchOp: indices
    else blocksPerRow > 1
        TorchOp->>TorchOp: enforce radix_aux_indices/logits present (CUDA-graph safety)
        TorchOp->>Radix: logits, outLogitsAux, outIndicesAux, compressRatio
        Radix-->>TorchOp: indices
    end
    TorchOp-->>Caller: indices
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

  • NVIDIA/TensorRT-LLM#14268: Introduced the original invokeIndexerTopKDecode fp32 API with scratch, scratchBytes, and is_prefill parameters and added indexerTopKDecodeScratchBytes — this PR directly replaces that contract at the same dispatcher function boundary.

Suggested reviewers

  • mingyangHao
  • longcheng-nv
  • Funatiq
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: introducing IndexerTopK and TopK primitives as preparation for DSv4, which is the primary focus of this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description thoroughly explains objectives, test coverage, validation steps, and deferred components with clear justification.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/unittest/_torch/thop/parallel/test_indexer_topk.py (1)

1305-1416: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Duplicate test function definitions.

The CuTE DSL test functions (test_cute_dsl_topk_decode_single_cta, test_cute_dsl_topk_decode_multi_cta, test_cute_dsl_indexer_topk_decode, test_cute_dsl_topk_decode_single_pass_multi_cta) are defined twice in this file — first at lines 729-840 and again at lines 1305-1416 with # noqa: F811 suppressions. The second definitions shadow the first, so only the later parametrizations run.

This appears unintentional. If the intent was different parametrizations, they should have distinct names or be merged; if it's accidental duplication, the second block should be removed.

🤖 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 `@tests/unittest/_torch/thop/parallel/test_indexer_topk.py` around lines 1305 -
1416, The test functions test_cute_dsl_topk_decode_single_cta,
test_cute_dsl_topk_decode_multi_cta, test_cute_dsl_indexer_topk_decode, and
test_cute_dsl_topk_decode_single_pass_multi_cta are defined twice in this
file—the second definitions shadow the first. Determine whether the duplication
is intentional (in which case merge the parametrizations and remove the noqa
suppressions, or rename the functions to be distinct) or accidental (in which
case remove the second set of definitions entirely at lines 1305-1416).
🧹 Nitpick comments (2)
cpp/tensorrt_llm/thop/IndexerTopKOp.cpp (1)

128-162: 💤 Low value

Consider explicit validation when only one aux tensor is provided.

The condition at line 128 checks if both aux tensors are provided, but if a caller provides only one (e.g., radix_aux_indices without radix_aux_logits), the else branch silently ignores it when blocks_per_row == 1, or produces a somewhat misleading error when blocks_per_row > 1.

This is safe but could confuse callers who accidentally omit one tensor.

💡 Optional: Add explicit both-or-neither validation
+        bool hasAuxIndices = radix_aux_indices.has_value();
+        bool hasAuxLogits = radix_aux_logits.has_value();
+        TORCH_CHECK(hasAuxIndices == hasAuxLogits,
+            "radix_aux_indices and radix_aux_logits must both be provided or both be None");
         if (radix_aux_indices.has_value() && radix_aux_logits.has_value())
🤖 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 `@cpp/tensorrt_llm/thop/IndexerTopKOp.cpp` around lines 128 - 162, The current
code at line 128 only checks if both radix_aux_indices and radix_aux_logits are
provided together, but if a caller accidentally provides only one tensor, it
silently falls through to the else branch without warning. Add explicit
validation before the existing if-else block to ensure that either both
auxiliary tensors (radix_aux_indices and radix_aux_logits) are provided
together, or neither is provided. Use TORCH_CHECK to reject cases where only one
tensor is supplied, providing a clear error message indicating that both tensors
must be provided together or not at all.
tests/unittest/_torch/thop/parallel/test_indexer_topk.py (1)

584-628: ⚡ Quick win

Missing device mismatch validation test.

The docstring at line 585-586 mentions "wrong device" as one of the validation cases, but the test body doesn't include a device mismatch check. This leaves a gap in validation coverage (the C++ op does check device equality).

💡 Suggested addition for device mismatch test
     with pytest.raises(RuntimeError, match="must be contiguous"):
         call(non_contig_idx, good_log)
+
+    # Wrong device (CPU instead of CUDA).
+    if torch.cuda.device_count() > 0:
+        cpu_idx = torch.empty_like(good_idx, device="cpu")
+        cpu_log = torch.empty_like(good_log, device="cpu")
+        with pytest.raises(RuntimeError, match="must be CUDA tensors"):
+            call(cpu_idx, cpu_log)
🤖 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 `@tests/unittest/_torch/thop/parallel/test_indexer_topk.py` around lines 584 -
628, The test function test_indexer_topk_decode_radix_aux_validation has a
docstring claiming it validates "wrong device" scenarios, but the test body is
missing this validation case. Add a test case that creates radix_aux buffers
(indices and logits) on a different device than the input tensors (for example,
create them on CPU when inputs are on CUDA, or vice versa) and verify that
calling the call function with these mismatched-device buffers raises a
RuntimeError with an appropriate device-related error message, consistent with
how the other validation cases use pytest.raises to check for expected errors.
🤖 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.

Inline comments:
In `@cpp/tensorrt_llm/kernels/indexerTopK.cu`:
- Around line 1132-1143: The logic at lines 1132-1143 incorrectly uses row index
count (`numRows`) with `kSortingAlgorithmThreshold` to decide sorting
algorithms, but `kSortingAlgorithmThreshold` is documented as a column-count
threshold. The function already receives `numColumns` as a parameter (line 1126)
which should be used instead. Replace the current split that applies the
threshold to row indices with a check against the actual column count
`numColumns` (similar to how it is correctly done in the decode path at line
953). If all rows have uniform width, check `numColumns >=
kSortingAlgorithmThreshold` once and call the appropriate topKPerRowPrefill
variant accordingly. If rows can vary in width, the per-row check via
`rowEnds[i] - rowStarts[i]` would be needed, but verify if the current kernel
structure supports this.

In `@tests/unittest/_torch/thop/parallel/test_indexer_topk.py`:
- Around line 1584-1674: The hardcoded value 12288 in the
_run_indexer_topk_decode_v4_gvr_check function creates a silent coupling with
the kernel constant kSeqSmallDefault from
cpp/tensorrt_llm/kernels/indexerTopK.cu:748, causing tests to silently use an
outdated value if the kernel constant ever changes. Extract 12288 to a
module-level constant (e.g., _KERNEL_SEQ_SMALL_DEFAULT = 12288) with a comment
referencing the kernel constant and file location, then replace the hardcoded
value in the min_uncompressed calculation with this named constant to maintain
clarity and catch future mismatches.

---

Outside diff comments:
In `@tests/unittest/_torch/thop/parallel/test_indexer_topk.py`:
- Around line 1305-1416: The test functions
test_cute_dsl_topk_decode_single_cta, test_cute_dsl_topk_decode_multi_cta,
test_cute_dsl_indexer_topk_decode, and
test_cute_dsl_topk_decode_single_pass_multi_cta are defined twice in this
file—the second definitions shadow the first. Determine whether the duplication
is intentional (in which case merge the parametrizations and remove the noqa
suppressions, or rename the functions to be distinct) or accidental (in which
case remove the second set of definitions entirely at lines 1305-1416).

---

Nitpick comments:
In `@cpp/tensorrt_llm/thop/IndexerTopKOp.cpp`:
- Around line 128-162: The current code at line 128 only checks if both
radix_aux_indices and radix_aux_logits are provided together, but if a caller
accidentally provides only one tensor, it silently falls through to the else
branch without warning. Add explicit validation before the existing if-else
block to ensure that either both auxiliary tensors (radix_aux_indices and
radix_aux_logits) are provided together, or neither is provided. Use TORCH_CHECK
to reject cases where only one tensor is supplied, providing a clear error
message indicating that both tensors must be provided together or not at all.

In `@tests/unittest/_torch/thop/parallel/test_indexer_topk.py`:
- Around line 584-628: The test function
test_indexer_topk_decode_radix_aux_validation has a docstring claiming it
validates "wrong device" scenarios, but the test body is missing this validation
case. Add a test case that creates radix_aux buffers (indices and logits) on a
different device than the input tensors (for example, create them on CPU when
inputs are on CUDA, or vice versa) and verify that calling the call function
with these mismatched-device buffers raises a RuntimeError with an appropriate
device-related error message, consistent with how the other validation cases use
pytest.raises to check for expected errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3769b4a3-de61-415c-b555-0733d5dab3c6

📥 Commits

Reviewing files that changed from the base of the PR and between 130ae82 and 3142a2b.

📒 Files selected for processing (7)
  • cpp/tensorrt_llm/kernels/IndexerTopK.h
  • cpp/tensorrt_llm/kernels/heuristicTopKDecode.cu
  • cpp/tensorrt_llm/kernels/heuristicTopKDecode.h
  • cpp/tensorrt_llm/kernels/indexerTopK.cu
  • cpp/tensorrt_llm/thop/IndexerTopKOp.cpp
  • tensorrt_llm/_torch/custom_ops/cpp_custom_ops.py
  • tests/unittest/_torch/thop/parallel/test_indexer_topk.py

Comment thread cpp/tensorrt_llm/kernels/indexerTopK.cu
Comment thread tests/unittest/_torch/thop/parallel/test_indexer_topk.py
@lfr-0531

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54331 [ run ] triggered by Bot. Commit: 3142a2b Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54331 [ run ] completed with state SUCCESS. Commit: 3142a2b
/LLM/main/L0_MergeRequest_PR pipeline #43400 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

CI Agent Failure Analysis

Link to invocation

@lfr-0531

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54389 [ run ] triggered by Bot. Commit: 3142a2b Link to invocation

@lfr-0531
lfr-0531 force-pushed the user/fanrongl/dsv4-indexer-topk branch from 70c7925 to 3142a2b Compare June 16, 2026 01:42
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54389 [ run ] completed with state SUCCESS. Commit: 3142a2b
/LLM/main/L0_MergeRequest_PR pipeline #43457 completed with status: 'SUCCESS'

CI Report

Link to invocation

@lfr-0531

Copy link
Copy Markdown
Collaborator Author

/bot help

@github-actions

Copy link
Copy Markdown

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) --high-priority]

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. Supports wildcard * for pattern matching (e.g., "*PerfSanity*" matches all stages containing PerfSanity). Examples: "A10-PyTorch-1, xxx", "PerfSanity". 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. Supports wildcard * for pattern matching. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx", --extra-stage "Post-Merge".

--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 the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

--high-priority (OPTIONAL) : Run the pipeline with high priority. This option is restricted to authorized users only and will route the job to a high-priority queue.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip 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-pipeline

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

@lfr-0531
lfr-0531 force-pushed the user/fanrongl/dsv4-indexer-topk branch from 3142a2b to 5f9d69a Compare June 16, 2026 03:53
@lfr-0531
lfr-0531 requested a review from a team as a code owner June 16, 2026 03:53
@lfr-0531
lfr-0531 requested a review from pengbowang-nv June 16, 2026 03:53
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
@lfr-0531
lfr-0531 force-pushed the user/fanrongl/dsv4-indexer-topk branch from 5f9d69a to f8400e4 Compare June 16, 2026 04:22
@lfr-0531

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast --add-multi-gpu-test

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54456 [ run ] triggered by Bot. Commit: f8400e4 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54456 [ run ] completed with state FAILURE. Commit: f8400e4
/LLM/main/L0_MergeRequest_PR pipeline #43520 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

CI Agent Failure Analysis

Link to invocation

@lfr-0531

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast --add-multi-gpu-test

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54490 [ run ] triggered by Bot. Commit: f8400e4 Link to invocation

@longcheng-nv longcheng-nv 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 — approving.

Reviewed the full kernel refactor end-to-end (including the unchanged multi-block/merge addressing in the head source) and cross-checked the prefill path against feat/deepseek_v4. This is a clean, well-documented stage-3 split of #14751.

Strengths

  • The two correctness fixes in topKPerRowJob are real and minimal: (1) the step==1 reset of smemFoundTopKValues[0]/smemFinalDstIdx[0] (replacing the old step0WillContinue suppression) correctly kills the 2x-duplicated-index defect in the multi-block merge path when -FLT_MAX padding dominates the threshold bin; (2) finalIndices[ii] = -1 pairing with the -FLT_MAX sentinel so unused radix-sort slots survive the sort as -1 instead of garbage.
  • The caller-owned radix_aux_{indices,logits} design is the correct fix for the G4 CUDA-Graph stale-pointer hazard, and mirrors the existing heuristic_scratch convention. I verified the part-1 write (rowIdx*gridDim.y*topK + blockIdx.y*topK) and part-2 read (rowIdx*numBlocksToMerge*topK) use a self-consistent flat stride, so the over-sized (max_gen_tokens, 10, topK) allocation is correct and the cpp needed_elts check matches exactly.
  • compress_ratio threading (N = actual_kv_len/cr, preIdxOffset=0 for cr!=1) is consistent across fp32/bf16/fp16 entries and the heuristic launcher.
  • Good test discipline: the split+merge path is validated vs torch.topk via the SM-saturation / launch-policy tests (which reach bp up to ~9), plus allocation-independence + CUDA-graph-replay equivalence and malformed-buffer validation.

Non-blocking note (no change required to approve)

  • The prefill compile-time useRadixSort split (and the decode single-block choice) intentionally replaces the runtime per-row finalCount-based selection that #14268 landed on main; the prefill logic here is byte-identical to feat/deepseek_v4. Correctness is unaffected (both paths run the identical histogram refinement and differ only in the bounded final-sort). Worth a one-line note in the PR/commit message that this is a deliberate replacement of #14268's runtime-adaptive path, and optionally one >=200k-column equivalence case to cover the forced blocksPerRow=10 branch (the removed multi-pass-radix tests previously exercised 131k-524k columns; the new ground-truth tests top out near 32k).

Nice work.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54490 [ run ] completed with state SUCCESS. Commit: f8400e4
/LLM/main/L0_MergeRequest_PR pipeline #43553 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

CI Agent Failure Analysis

Link to invocation

@lfr-0531

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast --add-multi-gpu-test

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54602 [ run ] triggered by Bot. Commit: 7fe184c Link to invocation

@lfr-0531
lfr-0531 requested a review from yuxianq June 17, 2026 08:42
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54602 [ run ] completed with state ABORTED. Commit: 7fe184c

Link to invocation

@lfr-0531

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast --add-multi-gpu-test

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54862 [ run ] triggered by Bot. Commit: 7fe184c Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #54862 [ run ] completed with state SUCCESS. Commit: 7fe184c
/LLM/main/L0_MergeRequest_PR pipeline #43867 completed with status: 'SUCCESS'

CI Report

Link to invocation

@longlee0622
longlee0622 enabled auto-merge (squash) June 23, 2026 00:32
Comment thread tensorrt_llm/_torch/attention_backend/sparse/dsa.py
@longlee0622
longlee0622 merged commit b41876f into NVIDIA:main Jun 24, 2026
8 checks passed
xinhe-nv pushed a commit to tensorrt-cicd/TensorRT-LLM that referenced this pull request Jun 24, 2026
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
Co-authored-by: Fanrong Li <lfr-0531@users.noreply.github.com>
Signed-off-by: GitLab CI Bot <gitlab-ci@nvidia.com>
BrianLi23 pushed a commit to BrianLi23/TensorRT-LLM that referenced this pull request Jul 9, 2026
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
Co-authored-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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants