Repository navigation
Conversation
Reuse the graph KV scatter for ordinary Triton graphs and retain the existing active-row and masked paths.
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.
Required human contributor answers
1. What outcome are you trying to achieve?
Reduce decode latency for looped models using the Triton backend with ordinary CUDA Graphs. The contributor delegated the specific optimization choice and requested real-weight validation on the other supported models.
2. What is the highest-leverage variable for that outcome?
GPU time spent on the per-layer K/V scatter, which repeats in every executed loop. On Ouro-1.4B at four loops, the ordinary graph path executes 192 indexed writes per generated token.
3. How will this work move that variable rather than create busywork?
Reuse the existing graph KV writer for ordinary unmasked Triton graphs. It writes K and V in one kernel, bringing Ouro's 192 writes down to 96 for the same cache addresses and bytes. The graph still reads the current block and offset tensors on every replay.
4. Who is the customer or user, and what do they actually need?
Operators serving Ouro, Dory, Nanbeige, and Huginn through Triton CUDA Graphs need lower decode token latency with the same generated tokens and cache contents.
PR necessity and bugfix evidence
A PR is needed to change the writer selected by ordinary Triton graph capture. This is a performance change.
Purpose
_DeviceCachecurrently calls PyTorch indexed assignment once for keys and once for values in ordinary unmasked captures. The existing graph writer already supports both tensors and strided inputs. When no dynamic active-row count is present, every row in the ordinary capture may write. Masked writes retain the existing dispatch and the other attention backends keep their current path.ExactLoop's observation that per-layer work is multiplied by recurrence motivates targeting this path. ExactLoop preprint
Test Plan
vllm-rlt Version / Commit:
a87f6c8versusea17646.pre-commit run --all-fileson Linux.pytest --run-gpu tests/test_cuda_graph.py tests/test_dory_gpu.py -k 'not flash_attn',pytest --run-gpu tests/test_huginn.py -k graphandpytest --run-gpu tests/test_async_speculative.py -k 'graph and not flash'on RTX 5090.574fa66(4 loops), Dory 4B BF16ee517dd(2 loops), Nanbeige4.2-3Bb82e54b(2 loops), and Huginn-0125bb6621b(32 loops). The benchmark uses 16-token KV blocks and fixes their count per checkpoint at 368, 192, 192, and 1296 respectively. Greedy cases generate 48 tokens per request, or 24 for Huginn. Sampled cases generate 16, withtemperature=0.7,top_k=24,top_p=0.9and seeds starting at 1243.Test Result
Real-checkpoint results
Cells show the median of three runs. Percentages are the median of the three paired relative changes.
Dory was also tested with 1,056 input tokens, crossing its 1,024-token sliding window. These runs used 560 KV blocks and generated 32 greedy or 16 sampled tokens per request.