Repository navigation
[ASM] [HIP] [JIT] Add gfx1250 R1 NVFP4 MLA decode and cache producers - #7987
Conversation
Signed-off-by: junxiaguo <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
ROCm/aiter#7987 added q_aux, kv_aux, nvfp4_params and nvfp4_lse to mla_decode_fwd as keyword-only parameters. The run takes them by name, and the selector declines a call that passes any of them: that is aiter's NVFP4 path.
ROCm/aiter#7987 added q_aux, kv_aux, nvfp4_params and nvfp4_lse to mla_decode_fwd as keyword-only parameters. The run takes them by name, and the selector declines a call that passes any of them: that is aiter's NVFP4 path.
ROCm/aiter#7987 added q_aux, kv_aux, nvfp4_params and nvfp4_lse to mla_decode_fwd as keyword-only parameters. The run takes them by name, and the selector declines a call that passes any of them: that is aiter's NVFP4 path.
ROCm/aiter#7987 added q_aux, kv_aux, nvfp4_params and nvfp4_lse to mla_decode_fwd as keyword-only parameters. The run takes them by name, and the selector declines a call that passes any of them: that is aiter's NVFP4 path.
…h the aiter provider, on aiter main and FlyDSL 0.5 (#271) * feat(plugins): serve aiter's 16-bit GEMMs and its Triton blockscale GEMM Selectors for the three GEMM contracts aiter routes next, in the provider's gemm module: - gemm_a16w16 (tuned_gemm: tgemm.mm, gemm_a16w16, gemm_a16w16_out) -> gemm. A with three or more dims is viewed as rows and the result viewed back; out is viewed to (rows, n) and returned. Declines scale_a/scale_b/scale_c, a shuffled B, an out whose dtype is not otype (aiter raises), and an A that cannot be viewed as rows (aiter runs F.linear). - gemm_a16w16_activation (Triton gemm_a16w16) -> gemm, y as out. Declines an activation and skip_reduce; config, kernel_type and persistent pick aiter's schedule only. - gemm_a8w8_blockscale_out (Triton gemm_a8w8_blockscale) -> gemm_a8w8_blockwise_scaled with operand_format "none:none", y as out. Declines skip_reduce, scales other than fp32, and an x_scale that is not contiguous (aiter's kernel reads it through its strides; AKLR's row-major a_scale is contiguous). For the Triton ops the output dtype is y's when y is given, as aiter's. Each run takes aiter's parameters by name and in order. * feat(plugins): serve aiter's fused_moe and biased_grouped_topk routes aiter routes two more MoE ops (ROCm/aiter, branch kyle/aklr-routes-moe): fused_moe, on the layer beneath its public fused_moe, and biased_grouped_topk. The provider gains a selector for each. - fused_moe -> AKLR's fused_moe, through the mapping the sglang and vLLM routes of aiter's public fused_moe use, now op_kwargs in aklr/plugins/aiter/fused_moe.py. The call arrives with aiter's enums as ints and is read back with aiter's enums. Declined: block_size_M other than -1, padding, activation scales, biases, the stage-2 scatter (any ep_* field), activation quant overrides, herd_topk, deterministic=True, and SiTUv2 where aiter would not quantize to fp8. The sorting policy and the HERD routing factor alone are not taken. - A sort a caller registered for aiter's next fused MoE (register_presorted_moe) is consumed beneath aiter's route, so the run pops it before anything else: left registered, it would apply to the next call aiter computes. - biased_grouped_topk -> AKLR's biased_grouped_topk, whose eight parameters are aiter's first eight. Declined: num_valid_rows, dropped groups (topk_group != num_expert_group), a bias in another dtype than the scores, and one group while aiter routes by HERD (AITER_FLYDSL_USE_HERD=1). The run returns None, as aiter's op does. tests/plugins/aiter/test_provider_moe.py covers both on CPU, with a stand-in aiter and, where aiter.plugin is importable, aiter's own dispatch. test_provider.py's contract table does not list the two ops yet, so its test_each_selector_serves_an_aiter_contract_at_its_version fails until they are added there. * feat(plugins): serve aiter's MLA and fused mHC routes as its provider aiter now routes five more ops through its kernel plugin interface (kyle/aklr-routes-mla): mla_decode_fwd, mla_paged_decode (the decode mode of mla_gluon), fp8_paged_mqa_logits, mla_sparse_prefill_v4 and mhc_fused_post_pre. Each gets a selector that unpacks aiter's call by name, declines what the AKLR contract does not take, and binds a run with aiter's parameters. - mla_decode_fwd -> mla_decode_fwd: the declines of aklr.plugins.aiter.mla, plus kv_layout, seq_lens, page_table, kv_csr_layout and return_logits; aiter's schedule metadata is ignored. Returns (o, lse). - mla_paged_decode -> flash_mla_with_kvcache, dense pool: q_nope and q_pe go as the one q they are adjacent views of (two tensors apart decline), the pool rows as (N, 1, 1, 576), the 2-D table with cache_seqlens or the flat one with cu_seqlens_k, a 4-D q as causal queries. The output is copied into aiter's o; the lse is dropped unless asked for. - fp8_paged_mqa_logits -> fp8_paged_mqa_logits: one query a request, preshuffled whole pages, no precomputed schedule, logits as wide as the block table and as max_model_len; [B, 1] lengths as [B]. - mla_sparse_prefill_v4 -> sparse_prefill_mxfp8, whose baseline is the same aiter kernel: the eleven tensors in order (fp8 NoPE as bytes), a sink required; the result is copied into out when given. - mhc_fused_post_pre -> mhc_fused_post_pre: post_layer_mix (T, 4, 1) as (T, 4); shuffled fn or residual declines. * test(plugins): list aiter's new routed ops in AITER_CONTRACTS * fix(plugins): take mla_decode_fwd's NVFP4 keyword-only parameters ROCm/aiter#7987 added q_aux, kv_aux, nvfp4_params and nvfp4_lse to mla_decode_fwd as keyword-only parameters. The run takes them by name, and the selector declines a call that passes any of them: that is aiter's NVFP4 path. * fix(plugins): take fused_moe's splitk, which aiter now passes to the route ROCm/aiter#4740 threads the public fused_moe's splitk down to fused_moe_, between bias2 and swiglu_limit, and aiter#8075 records the routed contract with it. The selector unpacked aiter's arguments by position, so the 40-argument call no longer unpacked, and every field after bias2 would have been read one place late. splitk is a split-K request to aiter's own kernels and moves only the order of the K sums, so AKLR serves the call whatever it is, as aiter's docstring for the route allows. * fix(plugins): return lse alone for aiter's mla_paged_decode ROCm/aiter#8075 now registers mla_paged_decode as a custom op that writes o in place and returns lse alone, so no result aliases an input; a custom op cannot return None for a tensor, so the op returns an empty fp32 tensor when return_lse is off. AKLR's run still writes its output into o, and now returns that lse instead of (o, lse). * refactor(plugins): no route of the sglang or vLLM plugin wraps an aiter function aiter routes sglang's aiter_calls (fused_moe, tgemm.mm, the Triton gemm_a16w16, mla_decode_fwd) and vLLM's layer routes on the same aiter functions (layers/fused_moe, gemm, mla) wrapped calls that aiter's kernel plugin interface now offers to AKLR's provider itself, so with both on a call reached AKLR twice. They go, with the argument mappings only they used (aklr/plugins/aiter/{mla,triton_gemm,tuned_gemm}); the provider serves these ops (fused_moe, gemm_a16w16, gemm_a16w16_activation, mla_decode_fwd) with the same checks, KV layouts included. * refactor(plugins): serve vLLM's MLA prefill through aiter's flash_attn_varlen vLLM's ROCM_AITER_FA MLA prefill backend calls aiter.flash_attn_varlen_func with the lse, over a step's new tokens and over each context chunk. The vLLM route on that backend wrapped what is now aiter's routed flash_attn_varlen, so the provider takes it instead: a selector that hands a bf16, causal or unmasked pass of at least 256 query rows to mla_prefill_varlen_lse in fp8, returning aiter's (out, softmax_lse as [heads, tokens]); every other call stays on aiter. The vLLM route and its tests go. * refactor(plugins): serve the DSA indexer's paged logits through aiter's fp8_paged_mqa_logits sglang's aiter_paged_mqa_logits calls aiter's deepgemm_fp8_paged_mqa_logits, which aiter routes as fp8_paged_mqa_logits, and the provider already serves its row calls. The sglang route on that wrapper goes. What it added, scoring a target verify's rows by request under DCP, moves into the provider's selector: the route on Indexer._get_topk_paged now only notes, through note_target_verify, whether the logits asked next are such a verify's, and the selector regroups those rows by views for fp8_paged_mqa_logits_verify, writing aiter's out_logits. Rows it cannot regroup, or a verify AKLR falls back on, take the row op as before. * ci: baseline aiter at a6c759b1f, which has the kernel plugin routes AKLR's provider serves ROCm/aiter#8075 routes flash_attn_varlen, mla_prefill_ps, mla_reduce, gemm_a8w8_bpreshuffle, causal_conv1d_split_qkv and the two KDA recurrences through aiter.plugin; #8179 restores the import aiter.fused_moe needs. This aiter pins flydsl==0.5.0 (a0c4b69c pinned 0.4.2). * docs(plugins): which framework routes stay beside aiter's provider A route may not wrap an aiter function aiter routes, nor a framework function that only calls one; a route that runs nothing may note framework state for the provider; aiter functions aiter does not route keep their routes. * fix(validation): trip on FlyDSL's compile in a capture from FlyDSL 0.5 FlyDSL before 0.5 reaches _build_call_state on a specialization's first call in the process only, so the tripwire hooked it to catch a kernel compiled inside a CUDA graph capture. FlyDSL 0.5 dropped the call-state cache: every JitFunction call traces again and rebuilds its call state, so a warmed kernel launched in the capture tripped it, and its runner died as candidate_crash (mla_decode_fwd_n_heads96 on aiter a6c759b1f). From 0.5 the tripwire hooks MlirCompiler.compile, which only a compile reaches. * test(plugins): keep aiter's own MLA routes in the dispatch test With an aiter that routes the MLA ops itself, routing a stand-in native under the same op name raised 'already routed' at setup (8 errors on aiter a6c759b1f). Those ops keep aiter's route: explain() checks the call against aiter's own contract, and only the test's own routes are called. * feat(jit): put FlyDSL's per-specialization launch cache back for AKLR's kernels on FlyDSL 0.5 FlyDSL 0.5 dropped the call-state cache: every JitFunction call traces the function again, lowers it and hashes the result before it launches. On MI355X mla_prefill_varlen_lse's launcher took 24.8 ms a call and mla_decode_fwd's 320 ms, against 0.16 and 0.09 ms on FlyDSL 0.4.2; aiter since ca6bc0f85 requires FlyDSL 0.5. FlyDSLBuilder now installs aklr.core.jit.flydsl_cache before it imports a kernel: for the JitFunctions an AKLR kernel package defines, the first call of a specialization goes through flyc.compile and every later one launches its CompiledFunction. The key is FlyDSL 0.4.2's, from FlyDSL's own signatures: the invalidating environment, the target, the compile hints, a Constexpr's value, and each runtime argument's cache signature. Other FlyDSL callers keep FlyDSL's path. Validation's compile tripwire hooks the cache's miss on FlyDSL 0.5, the first call of a specialization in the process, as _build_call_state was before 0.5. * feat(gemm): gemm_a8w8 on preshuffled weights, with Kimi-K3's KDA in-projection kernels `[email protected]` takes b preshuffled (layout variant `b_shuffled`, aiter's 16 x 16 shuffle_weight, b as (n, k)), detected by `b.is_shuffled`. Its baseline is aiter's per-token fp8 GEMM on a preshuffled weight, gemm_a8w8_bpreshuffle. Two FlyDSL schemas serve Kimi-K3's KDA in-projection (n6288, k7168): m 8-240, and m 320-8192. The kernels and their Points are those of the vLLM-route change; kernel.requires now names FlyDSL (>=0.3.2, as K3's other GEMM kernels), which moves both files to new uuids. * feat(ops): [email protected], Kimi-K3's KDA prefill short convolution, in aklr/ops/kda_conv The op vLLM's Kimi-K3 KDA prefill runs through aiter's fused q/k/v causal conv1d (causal_conv1d_split_qkv_triton_tile_fn): the contract, its reference and baseline, the FlyDSL kernel for proj 1536 with x and the conv state as strided rows, and the definition schema beside it. It was a vLLM plugin op with a route on KDA's conv; it comes to aklr/ops, where the aiter provider reaches it, and the route is not carried over. The contract id and the definition schema are unchanged. The kernel's file is renamed: its sources import aiter's FlyDSL buffer_ops, so kernel.requires names aiter too, and its workloads lose the measured fields only CI writes. n_tokens is a plain var axis here, without the bucketed dispatch that is not on this branch. * feat(plugins): serve aiter's gemm_a8w8_bpreshuffle by gemm_a8w8 on a shuffled weight aiter #8075 routes its per-token fp8 GEMM on a preshuffled weight (gemm_a8w8_bpreshuffle), which vLLM's preshuffled per-token fp8 linears call (Kimi-K3's KDA in-projection). The provider offers it to gemm_a8w8's b_shuffled layout: e4m3fn operands of one K, fp32 scales per token and per output column, no bias. check, a bias (aiter raises on one), a wider zero-padded weight, per-tensor scales, int8 (aiter's own rules) and e5m2 stay on aiter. aiter's op reads WQ as shuffled whatever it carries, and vLLM re-wraps the weight as a Parameter, which drops is_shuffled; AKLR tells a shuffled b only by that mark, and an unmarked one would read as row-major. select and run hand AKLR a view of WQ that carries it; the caller's tensor is not touched. * feat(plugins): serve aiter's causal_conv1d_split_qkv by kimi_k3_kda_conv aiter #8075 routes its Triton tile prefill conv with the q/k/v split (causal_conv1d_split_qkv), which Kimi-K3's KDA prefill calls on vLLM with x as the [dim, n_tokens] transpose of the packed q|k|v projection rows and the state as a (slots, dim, state_len) view of its SD pages. The provider hands AKLR those rows as (n_tokens, 3, proj), each slot's first width - 1 state rows (vLLM keeps more for speculative decoding) and dense index vectors (vLLM can pass a column of its slot table), as the strided_rows variant, and returns (q, k, v). Offered only inside the contract: silu (or swish), no bias, k_dim == v_dim, x rows of 3 * k_dim channel-contiguous, float32 taps of width 4, a bf16 state of x's dtype in SD pages, int32 cache_indices, bool has_initial_state and int32 query_start_loc given by the caller, and a negative or no pad_slot_id. aiter's block_m, block_n, num_warps and metadata only schedule its own kernel, and preserve_input_dtype changes nothing when x and the state share a dtype. The tests check the run against aiter's documented result, q, k, v and the state, and, with aiter's plugin interface, the route it takes. * chore(kernels): 3 kernels aiter a6c759b1f outruns become kernel-less schemas On aiter a6c759b1f (FlyDSL 0.5.0) no workload of these reaches 1.05 over aiter: sparse_prefill_mxfp8 at 128 heads (two kernels, 0.42-0.50x and 0.67-0.78x, where main recorded 1.23-1.37x and 1.89-2.08x; aiter's mla_sparse_prefill_v4 now takes 260 us) and the fused MoE of 513 experts top-11 inter 512 (1.03-1.12x). As #253 did, their workloads stay as kernel-less schemas for another optimization round; the two sparse prefill kernels share their workloads, so they leave one schema. * fix(plugins): select only reads the target-verify note; the call that runs takes it aiter's explain() asks select too and runs nothing, so a select that consumed the note let the next real call miss it. * feat(plugins): register K3's attn_res and wvSplitKrc routes on vLLM 0.32.1rc1.dev276 The vLLM of the K3 AgentX image (nightly-rocm72-df6603f0). At its commit df6603f0 both callers still call their callee, with the same parameters as v0.34.0's: _apply_attn_res calls attn_res, and rocm_unquantized_gemm_impl calls ops.wvSplitKrc. * fix(plugins): flash_attn_varlen asks with aligned stand-ins and copies offsets only to run Selecting a call with offsets off AKLR's 16-byte boundary cloned them, so a declined call or aiter's explain() enqueued device copies, and an accepted one copied them again in run. * fix(plugins): a pass sglang's MLA prefill route has declined is not offered to AKLR again The route's bf16 fallback calls aiter's flash_attn_varlen_func, which asks the provider: a causal pass the route declined could be taken there in fp8. The fallback now runs inside the provider's declining(), in which the provider declines every call on that thread. * test(validation): which compiles the graph-capture tripwire hooks on each FlyDSL With stand-in compilers: from FlyDSL 0.5 it trips on the launch cache's miss and on MlirCompiler, before 0.5 on _build_call_state; armed it trips on each hook, and disarmed restores them. * test(plugins): the stand-in fused_moe contract has aiter a6c759b1f's splitk aiter's pinned contract, provider/moe.py and test_provider_moe.py list splitk after bias2; test_provider.py's snapshot had dropped it. * feat(plugins): serve SiTUv2 on MXFP4 activations, vLLM's Kimi-K3 MoE, by situv2_a4w4_moe vLLM's Kimi-K3 recipe (AITER_SITUV2_A4W4) has aiter round SiTUv2's activations to MXFP4, which the provider declined: fused_moe takes SiTUv2 on fp8 only. situv2_a4w4_moe is that call's own contract, as its baseline makes it: gate and up rows separated, an e8m0 scale per 32. * feat(plugins): serve vLLM's verify under decode context parallelism by mla_decode_fwd_cprr vLLM's aiter MLA backend verifies draft tokens under decode context parallelism through aiter's mla_decode_fwd with g_kv_indptr, cp_world_size and cp_rank, every request with max_seqlen_q causal queries; the provider declined it as not one query a request. mla_decode_fwd_cprr is that call's contract: q and o as [batch, queries, heads, width] views of aiter's rows, the lse back as a row's. * test(plugins): the MoE dispatch tests keep aiter's own routes and check their contracts The fixture skipped both dispatch tests whenever aiter routed either op itself, so on the pinned aiter they never ran. Now an op aiter routes keeps its route, asked with explain() and never run, and only the others get a stand-in; a new test holds this file's contract snapshot to the installed routes' versions and positional parameters. * fix(plugins): tell SiTUv2 on MXFP4 activations from aiter's enums by value aiter's enums are pybind11's, a new object each lookup, so the identity test declined every Kimi-K3 MoE call on aiter a6c759b1f (found on MI355X: route native, provider declined). The stand-in enums of the tests were Python's, the same object each time; a test now uses enums that compare by value only. * chore(kernels): Kimi-K3's situv2 A4W4 MoE kernels from 61 tokens on become kernel-less schemas On MI355X with aiter a6c759b1f, through aiter's provider and against the float64 reference: - 16fab927 (61-1023 tokens): 1.00-1.04x over aiter, and 17.97 dB where aiter's own fused MoE reaches 30.46 dB; - a5d411fa (1024-16384 tokens): 1.06-1.64x, but 17.97-17.98 dB where aiter reaches 27.98-30.42 dB. Both pass the contract's 13 dB bound. The three kernels below 61 tokens match aiter (30.1-31.1 dB both, 44.7-48.0 dB between them) and stay. As #253 did, the two keep their workloads as kernel-less schemas for another round. * fix(plugins): situv2_a4w4_moe holds its kernels to 25 dB, not fused_moe's 13 aiter's own SiTUv2 A4W4 reaches 27.98-31.06 dB against the float64 reference on Kimi-K3's calls (MI355X, aiter a6c759b1f), and so do the three kernels kept (30.12-31.06 dB). fused_moe's 13 dB let two kernels 12 dB short of aiter through (17.97 dB); at 25 dB validation stops them. * chore(kernels): 3 sglang Triton MoE kernels no faster than sglang become kernel-less schemas #271 touches aklr/core, so its CI benches every plugin schema again, and these three have no workload at 1.05 over sglang's own: kimi_k3_latent_moe 02471a7b (4096-8192 tokens, 0.95-0.99x; main records 0.98-1.03x) and deepseek_v2_mxfp4_moe 22fee0b1 (24 tokens, 1.01x; main 1.02x) and f8cbd122 (32 tokens, 0.97x; main 0.99x). As #253 did, their workloads stay as kernel-less schemas. * test(ops): the preshuffled gemm_a8w8 Point at k 256, which aiter a6c759b1f's bpreshuffle takes From aiter a6c759b1f gemm_a8w8_bpreshuffle's heuristic dispatch takes k > 192 and a multiple of 64, so test_backend_matches_reference failed at the Point's k = 128 (Unsupported K).
Summary
Motivation
Changes
Performance (if applicable)
Testing
Documentation
Dependencies
Breaking Changes
PR Self-Review
Reviewed revision
Behavior and intent
Validation and unverified scope
PR-specific question
Changed op tests