Repository navigation
[rl] GDN builder: stage steps with drafts in fixed buffers - #6473
Draft
liangel-02 wants to merge 3 commits into
Draft
liangel-02 wants to merge 3 commits into
liangel-02 wants to merge 3 commits into
Conversation
TorchTitanLinearAttentionMetadataBuilder builds GDN metadata for steps with MTP drafts: verify rows (1 + k tokens with context) go to GDN's verify kernels, the rest to the prefill kernels, in fixed buffers that FULL graphs can replay. - Rows of at most 1 + k tokens lead every batch (reorder threshold 1 + k); the runner checks it in calculate_reorder_batch_threshold. - The runner tells the builders which graph a step replays (packed or uniform) and whether a dummy run stages a uniform batch (null slots, accepted counts of 1). - Accepted counts come from the runner's buffer, which vLLM refreshes on every step. - Rows with drafts but no context raise; so does a uniform graph that meets another row. No caller sets drafts yet: the GDN layer runs these rows in the next PR, and MTP turns them on after it.
This was referenced Dec 2, 2026
This branch has not been deployed
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.
Supersedes #6432 (originally by felipemello1).
Summary (human-written)
Agent details
Stack, bottom to top:
The stack lands after the vLLM 0.33 PRs ("[rl] generator: vLLM 0.33 API fixes and TP padding in the model wrapper", "[rl] Install vLLM 0.33.0 on the torch nightly"). "[rl] generator: run on vLLM's model runner V2 (vLLM 0.34)" rebases on it.
TLDR: TorchTitan's GDN metadata builder can now stage steps that carry MTP draft tokens. It writes them into fixed buffers, so FULL CUDA graphs can replay any mix of rows. No caller sets drafts yet: the GDN layer PR (3) runs these rows, and the MTP PR (4) turns drafts on. Steps without drafts run main's code.
Problem
kMTP drafts, each decode step verifies 1 + k tokens per request ("verify rows"). A step can also hold 1-token rows and prefill rows.Solution
TorchTitanLinearAttentionMetadataBuildersubclasses vLLM'sGDNAttentionMetadataBuilder. vLLM's V1 runner passes draft and accepted counts only to known builder classes (GPUModelRunner._build_attention_metadata)._build_with_draftsstages each step with drafts in buffers sized for the largest step. A kernel gets the null slot (0) on rows it doesn't own, so no tensor size depends on the mix.update_block_tablereuses one GDN group's metadata for the next, drafts included.TorchTitanGPUModelRunner.calculate_reorder_batch_thresholdraises if they disagree.num_accepted_tokensbuffer, which vLLM refreshes on every step. vLLM passes them to builders only on steps with drafts.VLLMEngine.add_requestsrejects prompts under 2 tokens with drafts (this builder's raise is the backstop), and drafts at generator DP > 1 raise at engine start.buildruns main's code.__init__now starts with vLLM's GDN builder__init__(the new parent) in every GDN and KDA engine: 8 small buffers (the largest holds up tomax_num_seqs * (1 + k)rows of1 + kint32 slots) and a GDN prefill-backend lookup that readshf_text_config.Results
You may ask: why a subclass of vLLM's builder? vLLM's V1 runner hands draft counts only to known builder classes. The TODO at the class says to drop it once vLLM passes the counts to any builder that asks. vLLM's V2 runner gates them by class too.
NOTE:
test_gdn_graph_metadata.pyruns in CI's RL 1 GPU job (A10G) when the PR has theciflow/rllabel. That job was green at the old head of "[rl] MTP on GDN models: FULL CUDA graphs for steps with prefill" (tagciflow/rl/6403), which had these cases. There they skip only without CUDA or the model path, which the workflow sets, so they most likely ran. Its log was not read. Not run there at this head yet. The newtest_draft_builder_rejects_rows_it_cannot_stageonly regroups three raises those cases already checked.Test plan