perf(cuda): use PDL for paged attention and V4 prefill - #4861
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces CUDA Programmatic Dependent Launch (PDL) wiring to reduce launch gaps between adjacent Triton kernel pipelines in decode (split‑K paged attention) and DeepSeek‑V4 prefill (score → state fill), while also raising the minimum supported Triton version to simplify compatibility code paths.
Changes:
- Add PDL producer/consumer signaling + waits to split‑K paged attention (producer signals, reducer launches with
launch_pdl=Trueand waits before scratch reads) on SM90+. - Add a new prefill wrapper (
score_and_fill_state_prefill) to optionally overlapscore_kvwithfill_compress_state, plus a CUDA SM90+/token-count gating heuristic and a correctness test. - Bump minimum Triton to
>=3.4.0and remove legacy version branches / imports across multiple CUDA kernels and env checks.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/pytorch/kernel/test_v4_compressor.py | Adds a prefill test validating PDL vs sequential behavior for the V4 compressor. |
| requirements/runtime_cuda.txt | Raises Triton minimum version to >=3.4.0 for CUDA runtime installs. |
| lmdeploy/pytorch/kernels/cuda/w8a8_triton_kernels.py | Removes Triton version branching and uses a single rounding implementation. |
| lmdeploy/pytorch/kernels/cuda/v4_compressor.py | Implements PDL signaling/waiting between score_kv and fill_compress_state, and adds the new prefill wrapper + heuristic. |
| lmdeploy/pytorch/kernels/cuda/utils.py | Simplifies capability/TMA support detection and exposes compute_capability via get_device_props. |
| lmdeploy/pytorch/kernels/cuda/pagedattention.py | Adds PDL producer/consumer synchronization to split‑K paged attention kernels (SM90+). |
| lmdeploy/pytorch/kernels/cuda/flashattention.py | Removes version/capability globals and switches to device-props-based capability selection. |
| lmdeploy/pytorch/kernels/cuda/blocked_gemm_fp8.py | Updates TMA gating to use the new supports_tma(device) API and imports TensorDescriptor directly. |
| lmdeploy/pytorch/kernels/cuda/bitonic_topk.py | Cleans up Triton constexpr helper handling and renames _concate→_concat. |
| lmdeploy/pytorch/kernels/cuda/activation.py | Removes Triton version branching and standardizes fast_expf selection. |
| lmdeploy/pytorch/check_env/triton.py | Updates minimum Triton version check to 3.4.0. |
| lmdeploy/pytorch/backends/cuda/v4_compressor.py | Switches prefill path to use the new combined score_and_fill_state_prefill wrapper. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| """Prefill score and state fill with an optional PDL anti-dependency.""" | ||
| assert kv.size(0) != state_ids.size(0) | ||
| if use_pdl is not False: |
There was a problem hiding this comment.
This is intentional. The compressor dispatch defines decode as kv.size(0) == state_ids.size(0) and routes that case to the fused score_and_fill_state_decode kernel.
score_and_fill_state_prefill is called only from the opposite branch, so this assertion documents the wrapper’s internal call contract. A batch containing one token per request does not reach this wrapper.
Summary
Use CUDA Programmatic Dependent Launch (PDL) to reduce launch gaps in two adjacent Triton kernel pipelines:
score_kv→fill_compress_state.This also raises the minimum supported Triton version from 3.0 to 3.4 and removes obsolete compatibility branches.
Changes
Split-K paged attention
launch_pdl=True.DeepSeek-V4 prefill compressor
Triton cleanup
>=3.4.0.Performance
H200 split-K paged-attention CUDA graph latency:
All nine measured CUDA graph cases improved. The eager batch-1/context-1K case regressed from 14.464 µs to 16.352 µs; paged attention is used for decode, which uses CUDA graphs by default. Eager mode remains opt-in.
For V4 ratio-4 prefill at 4K–8K tokens, eager p50 improved by approximately 1.3%–3.2%. CUDA graph results were neutral to slightly better. Smaller prefills and ratio-128 do not automatically enable PDL.