Skip to content

[None][perf] strict_accept: one compiled variant for every batch - #21424

Merged
longlee0622 merged 4 commits into
NVIDIA:mainfrom
xguannv:user/xguan/strict-accept-one-variant
Nov 5, 2026
Merged

longlee0622 merged 4 commits into
NVIDIA:mainfrom
xguannv:user/xguan/strict-accept-one-variant

Conversation

@xguannv

@xguannv xguannv commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Dev Engineer Review

strict_accept now uses a fixed 128-row program block. _strict_accept_kernel excludes the draft pointer, draft strides, and context/generation counts from Triton specialization. The launch grid still covers the larger request count. This targets repeated kernel compilation when batch counts or draft-view layouts change. Current review findings were not supplied, so severity counts are unavailable.

QA Engineer Review

tests/unittest/_torch/speculative/test_spec_tail_kernels.py adds test_strict_accept_one_variant_for_all_batches. It checks compiled-kernel cache stability across context-only, generation-only, and mixed batches with different sizes and draft-view layouts, and compares results with an eager reference. It skips when Triton does not expose JITFunction.device_caches.

The test file is listed in the CI test list tests/integration/test_lists/test-db/l0_b200.yml. No matching manual-QA list entry was found. The author reports that all 16 tests in the file pass on GB300 with Triton 3.8.0; this result was not independently verified. Coverage verdict: sufficient for the tested specialization-stability and result-parity cases.

Per-File QA Perspective

  • tensorrt_llm/_torch/speculative/spec_tail_kernels.py: Verify result correctness across request counts and draft-view strides. The fixed block changes the kernel launch configuration.
  • tests/unittest/_torch/speculative/test_spec_tail_kernels.py: The new test checks cache variant-count stability and eager-reference parity across batch sizes and draft-view layouts. The test file is listed in the CI test list tests/integration/test_lists/test-db/l0_b200.yml.

Description

strict_accept runs on every sampler iteration, each time with a different request count. BLOCK_B followed the count's power-of-two bucket, and Triton specialized on the counts and on the draft view's strides and alignment, so new variants kept being compiled and loaded while serving.

On Rubin, Kimi K3 disaggregated serving with one-model DSpark loaded _strict_accept_kernel 86 times during a run: 42 s in total and up to 1.1 s each, spread over the context and generation workers. Each load stalls that iteration's sampling path.

This PR fixes the rows per program at 128 and keeps the counts, the draft pointer and its strides out of the specialization key (do_not_specialize), so one compiled variant per draft length serves every batch. In the same Rubin setup with the change, the kernel was loaded 0 times in the measured serving window, and GSM8K was 95.98.

Test Coverage

  • New test_strict_accept_one_variant_for_all_batches in tests/unittest/_torch/speculative/test_spec_tail_kernels.py. After a first call, context-only, generation-only and mixed batches of different sizes, with draft views of different alignment, must not add a kernel variant. Each result is also checked against the eager reference.
  • Ran on GB300 (Triton 3.8.0): with the old module the new test fails (the variant count grows); with the fix all 16 tests in the file pass. Not yet run on this base; CI will cover it.

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.

The sampler calls strict_accept on every iteration with a different
request count. BLOCK_B followed the count's power-of-two bucket, and
Triton specialized the counts and the draft view's strides and alignment,
so new variants kept compiling and loading modules while serving. Fix the
rows per program and keep those arguments out of the specialization key.

The new test checks that one compiled variant serves context-only,
generation-only and mixed batches of different sizes, with draft views of
different alignment.

Signed-off-by: Xin Guan <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

strict_accept now uses a fixed 128-row block and excludes selected arguments from Triton specialization. A test compares outputs with the eager reference and checks device-cache counts across varied cases.

Changes

Strict acceptance kernel

Layer / File(s) Summary
Kernel configuration and validation
tensorrt_llm/_torch/speculative/spec_tail_kernels.py, tests/unittest/_torch/speculative/test_spec_tail_kernels.py
The kernel uses a fixed 128-row block and excludes the draft pointer, draft strides, and request counts from specialization. The test compares outputs with the eager reference across varied batch shapes and draft offsets, then checks that device-cache size does not increase.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Merge Risk: Minimal · up to dbeb0

No merge-blocking issue is established from the supplied evidence.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title follows the required [None][type] format and clearly states the main performance change: using one compiled strict_accept variant for every batch.
Description check Passed The description explains the problem, the implementation, the measured impact, and the test coverage. It includes the required Description, Test Coverage, and PR Checklist sections, with the checklist…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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.
Full details: Description check

Explanation

The description explains the problem, the implementation, the measured impact, and the test coverage. It includes the required Description, Test Coverage, and PR Checklist sections, with the checklist review confirmation marked.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 6dafc05 and dbeb01e.

Files selected for processing: 2
  • tensorrt_llm/_torch/speculative/spec_tail_kernels.py
  • tests/unittest/_torch/speculative/test_spec_tail_kernels.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

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

  • Fix comments: Fix CodeRabbit comments on this PR

… strides

The variant test now also runs draft views with row strides 7 and 16 and
column strides 1 and 2, in every combination and at two start offsets,
and still expects no new compiled variant and the eager result.

Signed-off-by: Xin Guan <[email protected]>
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements.

@svc-trtllm-gh-bot svc-trtllm-gh-bot added the Community want to contribute PRs initiated from Community label Nov 2, 2026
@xguannv

xguannv commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82202 [ run ] triggered by Bot. Commit: 6dafc05 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82202 [ run ] completed with state SUCCESS. Commit: 6dafc05
/LLM/main/L0_MergeRequest_PR pipeline #67831 completed with status: 'SUCCESS'

CI Report

Link to invocation

…ccept-one-variant

Signed-off-by: Xin Guan <[email protected]>

# Conflicts:
#	tests/unittest/_torch/speculative/test_spec_tail_kernels.py
@xguannv

xguannv commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82389 [ run ] triggered by Bot. Commit: dbeb01e Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@xguannv

xguannv commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82429 [ run ] triggered by Bot. Commit: dbeb01e Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@xguannv

xguannv commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82456 [ run ] triggered by Bot. Commit: dbeb01e Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82456 [ run ] completed with state SUCCESS. Commit: dbeb01e
/LLM/main/L0_MergeRequest_PR pipeline #68067 completed with status: 'SUCCESS'

CI Report

Link to invocation

Wanli-Jiang added a commit to Wanli-Jiang/TensorRT-LLM that referenced this pull request Nov 10, 2026
…once across batch splits

fused_accept._strict_accept_kernel and _step0_epilogue_kernel
specialized on the per-step request counts (== 1, divisible by 16), the
accept tile size followed the batch, and the accept kernel and
spec_tail_kernels._strict_accept_kernel specialized on the alignment of
the token buffers, whose start follows the batch layout. Each new batch
split therefore compiled and loaded a new variant inside served
requests, which shows up as latency spikes and voided two benchmark
screens that audit compilation in their timed window. Mark the counts
do_not_specialize, the token pointers do_not_specialize_on_alignment,
and fix the accept tile at 64 rows (the kernel loops over row blocks,
rows are independent). This extends what NVIDIA#21424 did for
spec_tail_kernels. A sweep of 1,704 calls (0 to 17 context and 0 to 128
generation requests, draft length 2 and 3, sliced token inputs at
several offsets, the three forced-acceptance modes) compiled 12
variants of the fused kernels instead of 312 and 2 of the spec tail
kernel instead of 160, with bitwise identical outputs.

Tests: the fused accept (natural and forced) and step-0 kernels keep one
compiled variant across batch splits and token-view offsets and match
the stock results; the spec tail compile-count test also takes the
target tokens at an unaligned offset.

Signed-off-by: Wanli Jiang <[email protected]>
Wanli-Jiang added a commit to Wanli-Jiang/TensorRT-LLM that referenced this pull request Nov 10, 2026
…once across batch splits

fused_accept._strict_accept_kernel and _step0_epilogue_kernel
specialized on the per-step request counts (== 1, divisible by 16), the
accept tile size followed the batch, and the accept kernel and
spec_tail_kernels._strict_accept_kernel specialized on the alignment of
the token buffers, whose start follows the batch layout. Each new batch
split therefore compiled and loaded a new variant inside served
requests, which shows up as latency spikes and voided two benchmark
screens that audit compilation in their timed window. Mark the counts
do_not_specialize, the token pointers do_not_specialize_on_alignment,
and fix the accept tile at 64 rows (the kernel loops over row blocks,
rows are independent). This extends what NVIDIA#21424 did for
spec_tail_kernels. A sweep of 1,704 calls (0 to 17 context and 0 to 128
generation requests, draft length 2 and 3, sliced token inputs at
several offsets, the three forced-acceptance modes) compiled 12
variants of the fused kernels instead of 312 and 2 of the spec tail
kernel instead of 160, with bitwise identical outputs.

Tests: the accept and step-0 kernels keep one compiled variant across
batch splits and token-view offsets; the spec tail compile-count test
also takes the target tokens at an unaligned offset. The existing
fused-vs-unfused tests cover the results.

Signed-off-by: Wanli Jiang <[email protected]>
Wanli-Jiang added a commit to Wanli-Jiang/TensorRT-LLM that referenced this pull request Nov 11, 2026
…once across batch splits

fused_accept._strict_accept_kernel and _step0_epilogue_kernel let Triton
specialize the per-step request counts (== 1, divisible by 16), and the
accept kernel's row tile (16, 32 or 64) followed the batch. Each new
batch split therefore compiled and loaded a new variant inside served
requests, which voided two benchmark screens that audit compilation in
their timed window. The accept kernel runs on every step under forced
acceptance.

Mark the counts do_not_specialize and fix the accept tile at 64 rows
(the kernel loops over row blocks, rows are independent), as NVIDIA#21424 did
for spec_tail_kernels. Outputs are unchanged.

Tests: the accept and step-0 kernels keep one compiled variant across
batch splits. The existing fused-vs-unfused tests cover the results.

Signed-off-by: Wanli Jiang <[email protected]>
Wanli-Jiang added a commit to Wanli-Jiang/TensorRT-LLM that referenced this pull request Nov 11, 2026
…once across batch splits

fused_accept._strict_accept_kernel and _step0_epilogue_kernel let Triton
specialize the per-step request counts (== 1, divisible by 16), and the
accept kernel's row tile (16, 32 or 64) followed the batch. Each new
batch split therefore compiled and loaded a new variant inside served
requests, which voided two benchmark screens that audit compilation in
their timed window. The accept kernel runs on every step under forced
acceptance.

Mark the counts do_not_specialize and fix the accept tile at 64 rows
(the kernel loops over row blocks, rows are independent), as NVIDIA#21424 did
for spec_tail_kernels. Outputs are unchanged.

Tests: the accept and step-0 kernels keep one compiled variant across
batch splits. The existing fused-vs-unfused tests cover the results.

Signed-off-by: Wanli Jiang <[email protected]>
Wanli-Jiang added a commit to Wanli-Jiang/TensorRT-LLM that referenced this pull request Nov 12, 2026
…once across batch splits

fused_accept._strict_accept_kernel and _step0_epilogue_kernel let Triton
specialize the per-step request counts (== 1, divisible by 16), and the
accept kernel's row tile (16, 32 or 64) followed the batch. Each new
batch split therefore compiled and loaded a new variant inside served
requests, which voided two benchmark screens that audit compilation in
their timed window. The accept kernel runs on every step under forced
acceptance.

Mark the counts do_not_specialize and fix the accept tile at 64 rows
(the kernel loops over row blocks, rows are independent), as NVIDIA#21424 did
for spec_tail_kernels. Outputs are unchanged.

Tests: the accept and step-0 kernels keep one compiled variant across
batch splits. The existing fused-vs-unfused tests cover the results.

Signed-off-by: Wanli Jiang <[email protected]>
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.

6 participants