[TRTLLM-12669][refactor] Remove allow_advanced_sampling and capture dual CUDA graphs#14745
Open
zhaoyangwang-nvidia wants to merge 1 commit into
Conversation
…tected dual-graph dispatch Remove the static `allow_advanced_sampling` config flag and replace it with a per-step auto-detected `is_all_greedy_sample` boolean on SpecMetadata. The flag is computed in `populate_sampling_params_for_one_model` from the actual temperature/top_k/top_p of every request in the batch. `is_all_greedy_sample` is included in the CUDA graph key so we lazily capture two graph variants (argmax fast-path vs advanced sampling kernel) and dispatch by replaying the right one based on the current batch composition. Both variants stay CUDA-graph-compatible because the dispatch is a host-side decision outside the captured region. Additional optimizations for the all-greedy batch (the common default): - Populate skips per-token list building and 6 H->D copies entirely. - Rejection sampling is bypassed (argmax is equivalent for all-greedy) in both linear and dynamic-tree paths. - _compute_and_store_draft_probs is skipped, saving a softmax pass and draft-probs copy. Signed-off-by: ZhaoyangWang <zhaoyangw@nvidia.com>
903b453 to
d237690
Compare
Collaborator
Author
|
/bot run |
Collaborator
Author
|
Hi @mikeiovine please help to review this PR, thanks~ |
Collaborator
|
PR_Github #51043 [ run ] triggered by Bot. Commit: |
Collaborator
|
PR_Github #51043 [ run ] completed with state
|
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.
Replace static config flag with auto-detected per-step uses_advanced_sampling based on actual sampling params. Include this in CUDA graph key so we lazily capture two graph variants (argmax fast-path vs advanced sampling kernel) and dispatch by replaying the right one.
@coderabbitai summary
Description
allow_advanced_samplingconfig flag fromDecodingBaseConfig.is_all_greedy_samplebased onactual
temperature/top_k/top_pof requests in the batch.captured (argmax fast-path vs advanced sampling kernel) and dispatched
at replay time based on batch composition.
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)
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.