Repository navigation
[None][perf] strict_accept: one compiled variant for every batch - #21424
Conversation
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]>
|
No actionable comments were generated in the recent review. Walkthrough
ChangesStrict acceptance kernel
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Refactor Merge Risk:
|
… 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]>
|
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. |
|
/bot run --disable-fail-fast |
|
PR_Github #82202 [ run ] triggered by Bot. Commit: |
|
PR_Github #82202 [ run ] completed with state |
…ccept-one-variant Signed-off-by: Xin Guan <[email protected]> # Conflicts: # tests/unittest/_torch/speculative/test_spec_tail_kernels.py
|
/bot run --disable-fail-fast |
|
PR_Github #82389 [ run ] triggered by Bot. Commit: |
|
PR_Github #82389 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #82429 [ run ] triggered by Bot. Commit: |
|
PR_Github #82429 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #82456 [ run ] triggered by Bot. Commit: |
|
PR_Github #82456 [ run ] completed with state |
…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]>
…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]>
…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]>
…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]>
…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]>
Dev Engineer Review
strict_acceptnow uses a fixed 128-row program block._strict_accept_kernelexcludes 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.pyaddstest_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 exposeJITFunction.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 listtests/integration/test_lists/test-db/l0_b200.yml.Description
strict_acceptruns on every sampler iteration, each time with a different request count.BLOCK_Bfollowed 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_kernel86 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
test_strict_accept_one_variant_for_all_batchesintests/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.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.