[TRTLLM-8136][feat] Dynamic draft length in spec decode (stage 2).#8703
Closed
zheyuf wants to merge 3 commits intoNVIDIA:mainfrom
Closed
[TRTLLM-8136][feat] Dynamic draft length in spec decode (stage 2).#8703zheyuf wants to merge 3 commits intoNVIDIA:mainfrom
zheyuf wants to merge 3 commits intoNVIDIA:mainfrom
Conversation
42a70e0 to
f4f3baa
Compare
f4f3baa to
c789000
Compare
361bf82 to
5a7a837
Compare
Collaborator
Author
|
/bot run --disable-fail-fast |
Collaborator
|
PR_Github #25787 [ run ] triggered by Bot. Commit: |
Collaborator
|
PR_Github #25787 [ run ] completed with state |
854be6e to
0cfdfeb
Compare
Collaborator
Author
|
/bot run --disable-fail-fast |
Signed-off-by: Zheyu Fu <zheyuf@NVIDIA.com>
Signed-off-by: Zheyu Fu <zheyuf@NVIDIA.com>
0cfdfeb to
feff6ee
Compare
Collaborator
Author
|
/bot run --disable-fail-fast |
Collaborator
|
PR_Github #25875 [ run ] triggered by Bot. Commit: |
Collaborator
|
PR_Github #25875 [ run ] completed with state |
Collaborator
Author
|
Close the PR as we shift focus to one model path. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@coderabbitai summary
Description
This PR updates the LLM API design from the dynamic draft length Stage 1 PR to improve CUDA graph compatibility. Aslo, this PR implements the CUDA graph capture logic and runtime Selection/Padding logic for dynamic draft length.
LLM API Design
Users can specify a new field draft_len_schedule in spec_config.
Example: {4:4, 8:2, 32:1, 64:0}.
Logic:
Batch Size 1-4 --> Draft Length 4
Batch Size 5-8 --> Draft Length 2
Batch Size 9-32 --> Draft Length 1
Batch Size 33-64 --> Draft Length 0
Constraint: All keys in draft_len_schedule must be present in cuda_graph_config.batch_sizes to align CUDA graph capturing behavior with the legacy (static) behavior.
CUDA Graph Capture
We will only capture the specific (batch_size, draft_len) pairs defined by the schedule, rather than the full Cartesian product.
Example: cuda_graph_config.batch_sizes = [1,2,3,4,5,6,7,8,16,24,32,64], max_draft_len = 4.
New Behavior: with draft_len_schedule={4:4, 8:2, 32:1, 64:0}. Captures [(1,4),(2,4),(3,4),(4,4),(5,2),(6,2),(7,2),(8,2),(16,1),(24,1),(32,1),(64,0)].
Legacy Behavior: Captures (BS, 4) for all batch sizes (plus extra graphs with draft len = 0 for disabled spec decode).
This feature produces equal or lower graph capture overhead compared to the legacy behavior.
Runtime Selection/Padding Logic
We use the pre-scheduling active batch size to determine the draft length.
Example: If pre-scheduling BS = 10 --> Runtime DL = 1. We pad to the nearest round-up graph: (16, 1).
Edge Case (Batch Size Decrease): Active batch size may drop after scheduling. We treat the determined runtime draft length as the source of truth and pad the batch size up to the nearest existing graph for that draft length.
Scenario: Pre-schedule BS = 6 --> DL = 2. Post-schedule BS drops to 4.
Resolution: We stick to DL = 2. Since (4, 2) was not captured (BS 4 maps to DL 4 in the schedule), we pad up to the nearest graph with DL 2, which is (5, 2).
Planned Timeline
Stage 1 (merged): LLM API design and drafter changes (ngram/model drafter). [PR] (Note: API in this stage1 PR is stale; updated in Stage 2).
Stage 2 (current): Target side changes (CUDA graph capture and selection/padding logic). Also update the llm api design.
Stage 3 (future): Perf study and extend to Chain Drafter.
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)
Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
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.