Repository navigation
attention: unified_attention and paged_attention_decode contracts - #79
fanxingran wants to merge 1 commit into
Conversation
…contracts [email protected] is one-token paged decode on vLLM's kv_split_pages cache, timed against aiter's paged_attention_v1; [email protected] is the multi-token decode vLLM's ROCM_AITER_FA backend runs, timed against aiter's Triton unified_attention. Both baselines call aiter as that backend does. An attr value may now be a tuple of ints, so window_size is the attr (-1, -1) or (2047, 0) as vLLM passes it; softcap is a scalar and the descales optional inputs that must be absent. Adds the KvSplitPages and StridedRows layouts and Muse (16/2/64/16) definition schemas for both.
|
CI run 42678258130: code-lint, unittest and the audit passed; |
…ion (#114) * feat(attention): paged_attention_decode and unified_attention decode contracts [email protected] is one-token paged decode on vLLM's kv_split_pages cache, timed against aiter's paged_attention_v1; [email protected] is the multi-token decode vLLM's ROCM_AITER_FA backend runs, timed against aiter's Triton unified_attention. Both baselines call aiter as that backend does. An attr value may now be a tuple of ints, so window_size is the attr (-1, -1) or (2047, 0) as vLLM passes it; softcap is a scalar and the descales optional inputs that must be absent. Adds the KvSplitPages and StridedRows layouts and Muse (16/2/64/16) definition schemas for both. * feat(plugins): vLLM plugin with GEMM and MoE routes AKLR_VLLM_PLUGIN=1 hooks, in each vLLM worker once its device is bound, the aiter functions vLLM's opaque custom ops look up at run time: tgemm.mm (rocm_unquantized_gemm) and fused_moe (rocm_aiter_fused_moe). Each wrapper asks the AKLR op and falls back to aiter on a FallbackReason, and always inside a compiled region. Tested on vLLM 0.33.0rc1.dev910. * feat(plugins): warm the AKLR kernels vLLM's warmup does not reach An AKLR kernel compiles at its first eager call. vLLM runs each CUDA graph size eagerly once, so steps past the graph sizes and the LM head (outside the graphs) first reached their kernels while serving: c64 ITL p99 went 157 ms on a fresh server vs 122 ms once warm. After vLLM's warmup, run one eager dummy step per served GEMM token count past the graph sizes and the LM head at each served size (about 8 s per rank for Muse). * fix(plugins): run each vLLM step from a frame chunk of its own The routes' frames move CPython's frame-chunk boundary onto aiter's MoE launch calls: each then maps and unmaps a chunk, 7% of a c128 step's host time. Each step now runs from a 64 KiB chunk with room for the whole step. * feat(plugins): routes from the model files vLLM runs uncompiled A model vLLM runs without torch.compile (@ignore_torch_compile, as Muse Spark) runs its Python at every eager call and CUDA graph capture, so a route can replace any function it looks up, not only aiter's inside an opaque custom op. The plugin now imports plugins.vllm.models, which mirrors vLLM's models package; models/muse_spark holds no route yet. * feat(plugins): route vLLM's skinny GEMM to gemm vLLM on gfx950 sends 10 to 128 token unquantized GEMMs to its own wvSplitKrc ahead of aiter's tgemm.mm, so the gemm route missed them there (qkv and o_proj at most decode steps); route wvSplitKrc too. * fix(plugins): the vLLM entry point is the plugin's; warm up only where routes installed pyproject's vllm.general_plugins entry point still named dispatch's register_vllm_plugin, so an installed AKLR started without the routes; it now names aklr.plugins.vllm:register, which starts AKLR the same way first, and installs nothing more without AKLR_VLLM_PLUGIN=1. AKLR's warmup drives vLLM's model runner through its private API (_dummy_run), as of the vLLM releases the routes were tested on; on any other release no route installs, and the warmup now leaves vLLM alone too. A pipeline stage without the LM head (a placeholder without weight) warms no LM head. The plugins README lists the plugin's modules. * feat(plugins): route vLLM's ROCM_AITER_FA attention to unified_attention AiterFlashAttentionImpl.forward reaches aiter's triton unified_attention; the route serves it with AKLR's unified_attention (#79's contract) and falls back to aiter on a FallbackReason. Tested on vLLM 0.33.0rc1.dev910. --------- Co-authored-by: Cursor <[email protected]>
|
Closing: the |
Why
Muse Spark's decode attention on vLLM's ROCM_AITER_FA backend runs aiter's Triton
unified_attentionfor multi-token decode (DSpark verify, q=8; drafter, q=7) and aiter's
paged_attention_v1forone-token decode, and AKLR has a contract for neither. This adds both contracts and their baselines,
which call aiter as that backend does. Kernels follow in their own PRs.
Scope
[email protected]and[email protected]: contract, baseline, reference, and Muse(16 heads, 2 KV heads, head_dim 64, block 16) definition schemas:
unified_attentionq=8 global,q=8 window (2047, 0), and
paged_attention_decode, batch 1..64 each.aklr/core: an attr value may be a tuple of ints (window_sizeis the attr(-1, -1)or(2047, 0), as vLLM passes it); new layoutsKvSplitPages(vLLM'skv_cache.transpose(1, 2) .split(head_dim)views) andStridedRows(the query sliced from the fused qkv buffer).Tradeoffs
window_sizeas one tuple attr rather than an attr per element: vLLM passes the tuple, and onlythe two tuples it passes are in the contract.
softcapandq/k/v_descalehave no default in aiter, so they are a scalar (values=(0.0,)) andoptional inputs that must be absent: vLLM main passes
Nonedescales for an unquantized cache(
rocm_aiter_fa.py_get_kv_cache_descales).Verification
Environment: head
5b278d4(main3db8ca2), MI355X (pit2-p03-g29),lmsysorg/sglang:v0.5.22-rocm10-mi35x(sha256:1438dd8b), torch 2.11.0+rocm10.0.0, FlyDSL 0.3.2,Triton 3.8.0, AITER
dbd8bf5bd(AKLR_BASELINE_AITER)Gate overrides: none
Contracts
Workloads from Muse Spark's decode on vLLM (16/2/64/16, block tables up to 2048 blocks, DSpark
verify q=8 and one-token decode at batch 1..64).
Code
python -m pytest tests: 701 passed, 113 skipped. New: the two contracts' cases and schema names intests/ops(cases.py,names.txt; these exercise the tuple attr), andkv_split_pagespages intests/core/contract/test_fastkey.py. No schema or measurement version changes; no existing kernelchanges result (an attr that is not a tuple takes the old path).
Not run
aklr/corechange): left to this PR's CI run.Risk
Affects: the
aklr/coreattr change touches every contract's attr parsing; the new ops have nokernel, so
aklr.ops.unified_attention/aklr.ops.paged_attention_decoderun AITER.If wrong: a contract whose attrs no longer parse, or a CI failure.
Undo:
git revert.