Graph-Compatible Dynamic Sparse Attention for End-to-End Prefix Capture
Capture variable-width sparse attention inside bucketed CUDA graphs so local inference engines avoid falling back to slow eager execution on every decoder layer.
Time
Compute level
Resources
What the paper used
Prerequisites
Scope
The Gap
During decode, TIDEWAY splits each decoder layer into three piecewise CUDA Graph segments to isolate host expert paging (Section 5.2 and Figure 6). However, sparse attention—used in frontier models such as DeepSeek-V4-Flash—is left outside graph capture and executed eagerly between the attention prefix graph and the router graph.
“Sparse attention stays eager. Capturing it would require padding the candidate set to a fixed width, and a different width can change the model’s behavior.”
Limitation
Leaving sparse attention in eager mode forces per-layer CPU kernel dispatch and synchronization on every decode token, eroding the launch-overhead savings of piecewise CUDA Graph replay as models scale in layer count and sparse attention complexity.
Proposed Solution
Replace eager sparse attention execution with graph-compatible dynamic scheduling using power-of-two bucketed CUDA Graphs paired with GPU-side indirection buffers (similar to FlashInfer's ragged metadata planning). Before launching the layer's captured graph, compute the sparse token index list into a fixed-address GPU buffer while masking padded slots inside the attention kernel so model numerics remain identical without changing the effective candidate set.
Why This Matters
Eliminating the eager sparse-attention gap is expected to reduce per-token CPU dispatch overhead and tighten decode step latency, particularly for deep MoE models with long-context sparse attention.
How to Get Started
How to test it: Test whether masked, bucketed CUDA Graph capture of sparse attention matches eager numerical outputs (zero output divergence) while reducing decode TPOT compared to TIDEWAY's current piecewise graphs on DeepSeek-V4-Flash at 32K–128K context under 64–128 GiB RAM; stop if graph-padding compute overhead exceeds eager launch overhead across tested context lengths.
- Instrument TIDEWAY's decode timeline on DeepSeek-V4-Flash (32K and 128K tokens) to isolate CPU launch time and GPU idle gaps caused by the eager sparse-attention segment.
- Implement bitmask-aware padding in the sparse-attention Triton/CuTe kernel so padded candidate slots contribute zero attention weight and preserve exact numerical equivalence.
- Integrate power-of-two bucketed CUDA Graphs merging Segment 1, sparse attention, and Segment 2 in TIDEWAY's Execution Engine.
- Evaluate TPOT and token-level output parity against unmodified TIDEWAY across 4K–128K static shapes.
Suggested by AI. Adapt it to your setup.
Has This Been Done?
FlashInfer and MOIRA provide efficient primitives and ragged attention indexing for serving engines. The specific design of combining power-of-two bucketed CUDA Graphs with GPU-side indirection buffers and masked padding for dynamic sparse attention remains partially distinct.
- MOIRA: Mass-Oriented Indexing with Ragged Attention for Long-Context Decoding · 2026 · 0 citations
- FlashInfer: Efficient and Customizable Attention Engine for LLM Inference Serving · 2025 · 452 citations
We searched OpenAlex and arXiv for “CUDA Graph dynamic sparse attention ragged metadata LLM decode” and “Graph-Compatible Dynamic Sparse Attention for End-to-End Prefix Capture” and an AI compared the idea with the top 10 results. A small search can miss relevant work.
Source Paper
Tideway: Phase-Aware Tiered Memory Management for MoE Inference on Consumer DevicesYifei Wang, Tsun-yu Yang, Yechen Xu +7 more · 2026
This paper introduces TIDEWAY, a phase-aware tiered memory management and execution system for running frontier-scale Mixture-of-Experts (MoE) language models locally on memory-constrained consumer PCs. When model weights exceed GPU VRAM and host RAM and spill onto an NVMe SSD, TIDEWAY unites VRAM and host RAM into a unified pool with phase-specific layouts and paging-resilient CUDA Graph execution, achieving average speedups of 1.97x in end-to-end latency, 2.40x in TTFT, and 1.61x in TPOT over state-of-the-art baselines.
Related Ideas
- Fused Latent-Cache Attention and Memory-Coalesced Binary Factorized CUDA KernelsLittleBit: Ultra Low-Bit Quantization via Latent Factorization🟠Medium
- Joint Inter-DP and Intra-Sequence Layout Optimization for Multi-Document Sparse AttentionTeleChat to Xing4: Advancing Frontier Agentic Models on Domestic Chips and Frameworks🟠Medium
- Direct GPU Graph Recording and Persistent Memory Pointers to Eliminate Decode Dispatch OverheadThe Other Half of the Memory Wall: Serving 35B MoEs from SSD with Trained Routing Prediction🟠Medium
- Multi-Shape Generalization and End-to-End Workload Evaluation for NPU Kernel OptimizationAscendGYM: A Cost-Aware Kernel Optimization Benchmark for Real-World Workloads on Ascend NPUs🟠Medium
- Integration of Sequence Parallelism for Long-Context TrainingLlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models🔴Hard