Repository navigation
[feat] Reuse GDN prefill metadata - #4694
Merged
Merged
Conversation
5 tasks done
3 of 4 tasks
yicyang
added a commit
to yicyang/aiter
that referenced
this pull request
Oct 20, 2026
…q_lens_cpu) chunk_gated_delta_rule_opt_vk derived its chunk indices/offsets from the device cu_seqlens: prepare_chunk_indices (.tolist()), prepare_num_chunks (int()) and prepare_chunk_offsets (new_tensor([0]) H2D) each forced a device->host sync on the first GDN layer of every step. In a serving engine with async scheduling this stalls mixed prefill/decode steps: measured in vLLM on MI355X (Qwen3.8-27B), a 4K prefill arriving while 15 requests decode took +3.9% TTFT with this backend. Add optional seq_lens_cpu (same name/semantics as ROCm#4694 on Qwen3.5_dev): register_host_seq_lens() attaches the host lengths to cu_seqlens, and the three helpers build their results on the host and copy them with pinned non_blocking H2D. Without seq_lens_cpu behaviour is unchanged, except that prepare_chunk_offsets uses new_zeros(1) instead of new_tensor([0]). Verified on gfx950 (torch sync debug mode "error"): with seq_lens_cpu the Triton-K5 and FlyDSL-K5 paths issue 0 syncs (before: 2 and 3); output and final state are bit-identical to the original 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.
Motivation
GDN variable-length prefill kernels repeatedly derived identical scheduling metadata from
cu_seqlensfor every layer and kernel stage.This introduced redundant metadata copies and device-to-host synchronization. This PR adds reusable prefill metadata that can be constructed once per batch and shared across all GDN layers and K1-K6 stages.
Modifications
Qwen3.5_devindexed-state and in-place update behavior..tolist()device readbacks andCatArrayBatchedCopy_contig.Accuracy Tests
Compared legacy and reusable-metadata paths using BF16 inputs and indexed FP32 state.
Output and final state matched with:
rtol=1e-3atol=2e-3Companion SGLang GDN suite:
28 passedSpeed Tests and Profiling
Configuration:
Profiling results with the companion SGLang integration:
CatArrayBatchedCopy_contig:4 -> 04 -> 00.001 us0.001 us0.001 us25,463 tokens/sChecklist