feat(engine): overlap decode steps with asynchronous token handoff - #524
Open
qinyiqun wants to merge 2 commits into
Open
feat(engine): overlap decode steps with asynchronous token handoff#524qinyiqun wants to merge 2 commits into
qinyiqun wants to merge 2 commits into
Conversation
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.
Summary
This PR reduces the CPU-side gap between consecutive decode steps by
overlapping sampled-token handoff with CUDA graph submission.
The sampled token is first copied into a stable GPU relay buffer. An
asynchronous D2H transfer into pinned host memory is then queued before the
submission thread starts the next graph. The scheduler waits only for the
corresponding output event when it needs to materialize the token on the host.
No chunked-prefill behavior is introduced by this PR.
Motivation
The original decode path performs host token materialization between two model
forwards. Python scheduling, synchronization, and D2H transfer can therefore
leave the GPU idle between consecutive decode graphs.
The asynchronous handoff path moves graph submission onto a dedicated thread
and preserves stream ordering:
Configuration
The server exposes:
--async-token-handoff=auto--async-token-handoff=on--async-token-handoff=offautois the default.It enables the optimization only when all validated requirements are met:
Explicit
onreports the unsupported conditions instead of silently fallingback.
Changes
handling.
Validation
Build
--graph=y, SM80, CCL, ATen, cuDNN, andFlashAttention.
Runtime
enable_graph=Trueasync_token_handoff=autoAsync GPU token handoff enabledA 70B TP=8 functional run produced approximately 41.5 output tokens/s for a
256-token response. This is reported as a smoke-test observation rather than a
formal performance claim because its prompt length and repetition methodology
do not exactly match the existing baseline suite.
Compatibility
Unsupported models and hardware platforms retain the existing synchronous
decode path. The optimization is not enabled globally unless the runtime and
processor explicitly satisfy the compatibility checks.
Dependency
Depends on the InfiniCore asynchronous tensor copy PR:
<InfiniCore PR link>.The first commit preserves the original optimization work and authorship of
@GodKickMyAss. The follow-up integration, compatibility, and lifecycle changes
are authored by @qinyiqun.