Repository navigation
refactor(plugins/aiter): op families under provider/, contracts in aiter's signature, routes through aiter - #352
Conversation
…ter's signature, routes through aiter The op families move into aklr/plugins/aiter/provider. Each contract takes its aiter op's signature (rms_norm becomes rmsnorm and rmsnorm_with_add), and a selector per aiter op answers aiter's kernel plugin interface; a call AKLR declines runs aiter's own kernel. - contract: api params the result does not depend on; an output's dtype is picked through a param the contract names - validation: a kernel may read its own parameter named like an I/O builtin - provider: serves aiter's mhc_post, flash_attn_varlen without the lse, and a target verify's fp8_paged_mqa_logits rows by request (told by their block tables); the expert-parallel fused_moe kernel takes aiter's enums - vLLM's skinny GEMM, Muse Spark's pooler linear and the fp32 router GEMM call aiter.tuned_gemm.gemm_a16w16; sglang's paged top-k no longer notes a target verify - the nine contracts whose baseline is not an op aiter routes are marked TODO(aiter-route), to be routed or removed later
There was a problem hiding this comment.
🟡 Changes recommended
The BF16 attention path introduces unrequested FP8 rounding, Muse Spark fallbacks can reduce accuracy, and relocated schemas retain measured fields that fail CI guards.
7 open issues
Preserve BF16 values in the no-LSE attention path · New Handle measured fields when relocating schemas · New Preserve F.linear fallback for GEMM calls AKLR declines · New Use a common root for kernel report collection · New Remove retained measurements from relocated schemas · New Audit function defaults, decorators, and annotations for forbidden calls · New Update routing documentation to match current provider paths · New
What changed in this PR
Refactors AKLR’s aiter integration into provider-owned operator families, aligns contracts with aiter signatures, and routes framework GEMMs through aiter’s plugin interface.
Changes:
- Relocate operator families and selectors under
provider/, including aiter-style RMSNorm APIs. - Route vLLM GEMMs and warmup through aiter, extend mHC and prefill selectors, and remove SGLang’s verify-context notification route.
- Generalize output-dtype parameters and update auditing, tests, packaging, automation, and documentation.
| File | Description |
|---|---|
| tests/plugins/vllm/test_warmup.py | Tests provider gating and supported weight orientation for GEMM warmup. |
| tests/plugins/vllm/test_gemm_routes.py | Adds tests for aiter GEMM routing and provider detection. |
| tests/plugins/sglang/test_hook.py | Updates the provider-package fixture for the relocated operators. |
| tests/plugins/sglang/test_dsa_verify_logits.py | Removes tests for the deleted verify-context notification route. |
| tests/plugins/aiter/provider/test_sparse_prefill_reference.py | Updates sparse-prefill reference imports and schema paths. |
| tests/plugins/aiter/provider/test_reference.py | Updates imports for relocated operator references. |
| tests/plugins/aiter/provider/test_provider_moe.py | Updates MoE API and selector imports. |
| tests/plugins/aiter/provider/test_provider_moe_mapping.py | Targets the relocated MoE selector. |
| tests/plugins/aiter/provider/test_provider_gemm.py | Targets the relocated GEMM selector. |
| tests/plugins/aiter/provider/test_provider_conv.py | Updates convolution reference and selector imports. |
| tests/plugins/aiter/provider/test_kda_conv_reference.py | Updates the KDA convolution reference import. |
| tests/plugins/aiter/provider/test_hip_kernels.py | Calls the relocated GEMM API. |
| tests/plugins/aiter/provider/test_contracts.py | Adjusts contract snapshot paths after test relocation. |
| tests/plugins/aiter/provider/fused_moe/test_kernel.py | Updates kernel paths and adds aiter-enum compatibility coverage. |
| tests/plugins/aiter/provider/fused_moe/test_contract.py | Updates fused-MoE contract and fixture imports. |
| tests/plugins/aiter/provider/fused_moe/__init__.py | Provides the relocated fused-MoE test-package marker. |
| tests/plugins/aiter/provider/cases.py | Adopts aiter’s RMSNorm names and parameters in test fixtures. |
| tests/plugins/aiter/names.txt | Updates RMSNorm contract-name snapshots. |
| tests/op_case.py | Loads aiter test cases from the relocated provider package. |
| tests/core/validation/test_validation_scope.py | Updates schema-path classification fixtures for the provider layout. |
| tests/core/validation/test_pipeline.py | Updates validation fixtures and committed-schema paths. |
| tests/core/validation/test_audit.py | Adds parameter-shadowing audit cases and updates schema paths. |
| tests/core/runtime/test_dispatch.py | Exercises GEMM dispatch through the relocated API. |
| tests/core/contract/test_schema.py | Updates schema lookup paths and package references. |
| tests/benchmarks/test_kernels_report.py | Updates reporting fixtures and measurement paths for the provider layout. |
| pyproject.toml | Adjusts package-data and coverage patterns for relocated operator families. |
| harness/tests/shepherd/test_freshness.py | Updates candidate-freshness fixtures to use provider paths. |
| harness/tests/forge_task/test_driver_contract.py | Checks kernel publication under the provider directory. |
| harness/tests/forge_task/fake_aklr.py | Writes fake schemas beneath the provider directory. |
| harness/skills/tdd/tests.md | Updates operator API paths in testing examples. |
| harness/skills/tdd/mocking.md | Updates paths in mocking examples. |
| harness/skills/read-validation/SKILL.md | Updates contract-location guidance for the provider layout. |
| harness/skills/port-generated-kernels/references/workflow.md | Updates documented kernel destinations. |
| harness/skills/open-pr/SKILL.md | Updates schema classification guidance for provider paths. |
| harness/skills/kb/triton/moe.md | Updates MoE source citations to the provider layout. |
| harness/skills/kb/triton/debugging.md | Updates debugging examples and source-reference paths. |
| harness/skills/kb/SKILL.md | Updates the documented baseline location. |
| harness/skills/kb/pitfalls/speedup_from_another_ruler.md | Updates the baseline citation. |
| harness/skills/kb/pitfalls/eager_call_host_time.md | Updates top-k kernel citations. |
| harness/skills/kb/pitfalls/degenerate_points.md | Updates MLA contract and kernel citations. |
| harness/skills/kb/pitfalls/baseline_silently_wrong.md | Updates GEMM contract and baseline citations. |
| harness/skills/kb/moe/INDEX.md | Updates MoE contract and implementation locations. |
| harness/skills/kb/moe/grouped_sorted_tokens.md | Updates MoE contract and kernel evidence paths. |
| harness/skills/kb/moe/few_tokens.md | Updates MoE contract and kernel references. |
| harness/skills/kb/gemm/small_m.md | Updates the GEMM kernel evidence path. |
| harness/skills/kb/gemm/datapath.md | Updates synchronization-related source citations. |
| harness/skills/kb/gemm/correctness.md | Updates the GEMM correctness-evidence citation. |
| harness/skills/kb/flydsl/moe.md | Updates a kernel citation and example formatting. |
| harness/skills/kb/flydsl/kernels/flydsl_kernel_library.md | Updates documented baseline and kernel locations. |
| harness/skills/kb/flydsl/gemm.md | Updates the kernel-search example for the provider layout. |
| harness/skills/kb/communication/INDEX.md | Updates the MegaMoE package location. |
| harness/skills/kb/communication/ep_dispatch_combine.md | Updates MegaMoE kernel evidence paths. |
| harness/skills/bad-cases/cases/kernel_calls_reference_or_baseline.md | Updates the historical baseline import path. |
| harness/skills/bad-cases/cases/contract_changed_to_fit_kernel.md | Updates the contract-path citation. |
| harness/scripts/forge_task/schema.py | Discovers schemas within provider-owned operator families. |
| harness/scripts/forge_task/README.md | Updates schema-discovery instructions and path examples. |
| harness/scripts/forge_task/assets/aklr_forge_driver.py | Publishes generated kernels beneath the provider directory. |
| harness/automations/shepherd/skills/optimize-and-deliver-kernels/scripts/candidate.py | Moves automated candidate discovery to the provider root. |
| docs/vllm_plugin_tutorial.zh.md | Updates the contract snapshot-regeneration command. |
| docs/vllm_plugin_tutorial.md | Updates the contract snapshot-regeneration command. |
| docs/sglang_plugin_tutorial.zh.md | Updates the contract snapshot-regeneration command. |
| docs/sglang_plugin_tutorial.md | Updates the contract snapshot-regeneration command. |
| docs/forge_task.md | Updates the documented delivered-kernel location. |
| aklr/plugins/vllm/warmup.py | Warms supported GEMMs through aiter with provider and weight-orientation gating. |
| aklr/plugins/vllm/models/muse_spark/reference.py | Imports the relocated shared MoE reference. |
| aklr/plugins/vllm/models/muse_spark/contract.py | Explicitly declares the output-dtype parameter. |
| aklr/plugins/vllm/models/muse_spark/api.py | Routes pooler and unpooler linear calls through aiter GEMM when enabled. |
| aklr/plugins/vllm/models/kimi_k3/attn_res/contract.py | Explicitly declares the output-dtype parameter. |
| aklr/plugins/vllm/layers/utils/api.py | Routes enabled skinny GEMM calls through aiter. |
| aklr/plugins/vllm/layers/utils/__init__.py | Documents the revised aiter GEMM destination. |
| aklr/plugins/vllm/layers/__init__.py | Updates the description of aiter-based layer routing. |
| aklr/plugins/vllm/hook.py | Adds a helper for detecting whether aiter’s AKLR provider is enabled. |
| aklr/plugins/sglang/models/qwen3_moe/contract.py | Explicitly declares the output-dtype parameter. |
| aklr/plugins/sglang/models/qwen2_moe/reference.py | Imports the relocated shared weight-decoding reference. |
| aklr/plugins/sglang/models/qwen2_moe/contract.py | Explicitly declares the output-dtype parameter. |
| aklr/plugins/sglang/models/minimax_m2/reference.py | Imports the relocated shared weight-decoding reference. |
| aklr/plugins/sglang/models/minimax_m2/contract.py | Explicitly declares the output-dtype parameter. |
| aklr/plugins/sglang/models/kimi_k3/reference.py | Imports relocated shared MoE reference helpers. |
| aklr/plugins/sglang/models/deepseek_v2/reference.py | Imports the relocated shared weight-decoding reference. |
| aklr/plugins/sglang/models/deepseek_v2/contract.py | Explicitly declares output-dtype parameters for the contract variants. |
| aklr/plugins/sglang/layers/kda_triton/contract.py | Explicitly declares the output-dtype parameter. |
| aklr/plugins/sglang/layers/dsa_backend/reference.py | Imports the relocated shared top-k checker. |
| aklr/plugins/sglang/layers/dsa_backend/api.py | Removes the framework-side verify-context notification route. |
| aklr/plugins/README.md | Documents provider-owned operator families and aiter routing and fallback flow. |
| aklr/plugins/aiter/rms_norm/reference.py | Removes the former RMSNorm reference module. |
| aklr/plugins/aiter/rms_norm/contract.py | Removes the former RMSNorm contracts. |
| aklr/plugins/aiter/rms_norm/baseline.py | Removes the former RMSNorm baseline module. |
| aklr/plugins/aiter/rms_norm/api.py | Removes the former RMSNorm APIs. |
| aklr/plugins/aiter/rms_norm/__init__.py | Removes the former RMSNorm package exports. |
| aklr/plugins/aiter/provider/topk/selector.py | Uses the relocated top-k API. |
| aklr/plugins/aiter/provider/topk/reference.py | Relocates top-k references and checking logic under the provider. |
| aklr/plugins/aiter/provider/topk/contract.py | Updates imports and marks deferred aiter routing. |
| aklr/plugins/aiter/provider/topk/baseline.py | Relocates top-k baselines under the provider. |
| aklr/plugins/aiter/provider/topk/api.py | Imports relocated top-k contracts. |
| aklr/plugins/aiter/provider/topk/__init__.py | Exports the relocated top-k APIs. |
| aklr/plugins/aiter/provider/situv2_a4w4_moe/reference.py | Imports the relocated shared fused-MoE reference. |
| aklr/plugins/aiter/provider/situv2_a4w4_moe/contract.py | Updates imports and explicitly declares output-dtype metadata. |
| aklr/plugins/aiter/provider/situv2_a4w4_moe/baseline.py | Relocates the SiTUv2 baseline under the provider. |
| aklr/plugins/aiter/provider/situv2_a4w4_moe/api.py | Imports the relocated SiTUv2 contract. |
| aklr/plugins/aiter/provider/situv2_a4w4_moe/__init__.py | Exports the relocated SiTUv2 API module. |
| aklr/plugins/aiter/provider/rms_norm/selector.py | Selects RMSNorm calls using aiter-compatible signatures. |
| aklr/plugins/aiter/provider/rms_norm/reference.py | Implements renamed RMSNorm references using aiter’s operand names. |
| aklr/plugins/aiter/provider/rms_norm/baseline.py | Provides baselines for the renamed RMSNorm interfaces. |
| aklr/plugins/aiter/provider/rms_norm/api.py | Exposes aiter-compatible rmsnorm and rmsnorm_with_add APIs. |
| aklr/plugins/aiter/provider/rms_norm/__init__.py | Exports the renamed RMSNorm APIs. |
| aklr/plugins/aiter/provider/quant/selector.py | Uses the relocated quantization APIs. |
| aklr/plugins/aiter/provider/quant/reference.py | Relocates quantization references under the provider. |
| aklr/plugins/aiter/provider/quant/contract.py | Updates quantization baseline and reference imports. |
| aklr/plugins/aiter/provider/quant/baseline.py | Relocates quantization baselines under the provider. |
| aklr/plugins/aiter/provider/quant/api.py | Imports relocated quantization contracts. |
| aklr/plugins/aiter/provider/quant/__init__.py | Exports the relocated quantization APIs. |
| aklr/plugins/aiter/provider/norm.py | Removes the superseded RMSNorm selector module. |
| aklr/plugins/aiter/provider/mla/contract.py | Updates imports and documents deferred MLA pool routing. |
| aklr/plugins/aiter/provider/mla/api.py | Imports relocated MLA contracts. |
| aklr/plugins/aiter/provider/mla/__init__.py | Exports the relocated MLA APIs. |
| aklr/plugins/aiter/provider/mla_prefill/selector.py | Adds causal prefill selection for calls that do not request LSE. |
| aklr/plugins/aiter/provider/mla_prefill/contract.py | Updates prefill baseline and reference imports. |
| aklr/plugins/aiter/provider/mla_prefill/baseline.py | Updates the prefill planning-helper import. |
| aklr/plugins/aiter/provider/mla_prefill/api.py | Relocates prefill API declarations under the provider. |
| aklr/plugins/aiter/provider/mla_prefill/__init__.py | Exports the relocated prefill APIs. |
| aklr/plugins/aiter/provider/mla_absorb/reference.py | Relocates MLA absorb references under the provider. |
| aklr/plugins/aiter/provider/mla_absorb/contract.py | Updates imports and marks deferred aiter routing. |
| aklr/plugins/aiter/provider/mla_absorb/baseline.py | Updates the shared quantization-helper import. |
| aklr/plugins/aiter/provider/mla_absorb/api.py | Imports relocated MLA absorb contracts. |
| aklr/plugins/aiter/provider/mla_absorb/__init__.py | Exports the relocated MLA absorb API module. |
| aklr/plugins/aiter/provider/mhc/selector.py | Adds selection for aiter’s mhc_post operation. |
| aklr/plugins/aiter/provider/mhc/reference.py | Relocates mHC references under the provider. |
| aklr/plugins/aiter/provider/mhc/contract.py | Updates imports and explicitly declares output-dtype metadata. |
| aklr/plugins/aiter/provider/mhc/baseline.py | Relocates mHC baselines under the provider. |
| aklr/plugins/aiter/provider/mhc/api.py | Imports relocated mHC contracts. |
| aklr/plugins/aiter/provider/mhc/__init__.py | Exports the relocated mHC APIs. |
| aklr/plugins/aiter/provider/mega_moe/reference.py | Imports relocated shared MoE reference helpers. |
| aklr/plugins/aiter/provider/mega_moe/contract.py | Updates imports, output-dtype metadata, and deferred-routing notes. |
| aklr/plugins/aiter/provider/mega_moe/baseline.py | Imports the relocated shared MoE baseline. |
| aklr/plugins/aiter/provider/mega_moe/api.py | Imports the relocated MegaMoE contract. |
| aklr/plugins/aiter/provider/mega_moe/__init__.py | Exports the relocated MegaMoE APIs. |
| aklr/plugins/aiter/provider/kda_conv/selector.py | Uses the relocated KDA convolution API. |
| aklr/plugins/aiter/provider/kda_conv/reference.py | Relocates the KDA convolution reference under the provider. |
| aklr/plugins/aiter/provider/kda_conv/contract.py | Updates convolution baseline and reference imports. |
| aklr/plugins/aiter/provider/kda_conv/baseline.py | Relocates the KDA convolution baseline under the provider. |
| aklr/plugins/aiter/provider/kda_conv/api.py | Imports the relocated KDA convolution contract. |
| aklr/plugins/aiter/provider/kda_conv/__init__.py | Exports the relocated KDA convolution API. |
| aklr/plugins/aiter/provider/gemm/selector.py | Uses the relocated GEMM APIs. |
| aklr/plugins/aiter/provider/gemm/reference.py | Relocates GEMM arithmetic references under the provider. |
| aklr/plugins/aiter/provider/gemm/impls/triton/gemm_n6144_k2048/0ea9679fff769244.json | Relocates a kernel-less GEMM workload schema under the provider. |
| aklr/plugins/aiter/provider/gemm/impls/triton/gemm_n2624_k6144/44c9027be8bb7c33.json | Relocates a kernel-less GEMM workload schema under the provider. |
| aklr/plugins/aiter/provider/gemm/impls/triton/gemm_n2624_k6144/0e3be159d29b3f28.json | Relocates a kernel-less GEMM workload schema under the provider. |
| aklr/plugins/aiter/provider/gemm/impls/flydsl/gemm_n8448_k7168/beea053db0550c6d.json | Relocates a kernel-less GEMM workload schema under the provider. |
| aklr/plugins/aiter/provider/gemm/impls/flydsl/gemm_n768_k7168/0de3ea7c7da9a2a2.json | Relocates a kernel-less GEMM workload schema under the provider. |
| aklr/plugins/aiter/provider/gemm/impls/flydsl/gemm_n7168_k512/f741a86fad009fb9.json | Relocates a kernel-less GEMM workload schema under the provider. |
| aklr/plugins/aiter/provider/gemm/impls/flydsl/gemm_n256_k6144/3c141b55f849fbfe.json | Relocates a kernel-less GEMM workload schema under the provider. |
| aklr/plugins/aiter/provider/gemm/contract.py | Explicitly declares dtype parameters and marks deferred aiter routes. |
| aklr/plugins/aiter/provider/gemm/api.py | Imports relocated GEMM contracts. |
| aklr/plugins/aiter/provider/gemm/__init__.py | Exports the relocated GEMM APIs. |
| aklr/plugins/aiter/provider/fused_moe/selector.py | Uses relocated fused-MoE APIs and reference helpers. |
| aklr/plugins/aiter/provider/fused_moe/contract.py | Updates imports and explicitly declares output-dtype metadata. |
| aklr/plugins/aiter/provider/fused_moe/baseline.py | Relocates the fused-MoE baseline under the provider. |
| aklr/plugins/aiter/provider/fused_moe/api.py | Imports the relocated fused-MoE contract. |
| aklr/plugins/aiter/provider/fused_moe/__init__.py | Exports the relocated fused-MoE API. |
| aklr/plugins/aiter/provider/attention/reference.py | Relocates attention references under the provider. |
| aklr/plugins/aiter/provider/attention/contract.py | Explicitly declares dtype parameters and marks deferred aiter routes. |
| aklr/plugins/aiter/provider/attention/baseline.py | Relocates attention baselines under the provider. |
| aklr/plugins/aiter/provider/attention/api.py | Imports relocated attention contracts. |
| aklr/plugins/aiter/provider/attention/__init__.py | Exports the relocated attention APIs. |
| aklr/plugins/aiter/provider/__init__.py | Discovers selector modules within operator-family packages. |
| aklr/plugins/aiter/__init__.py | Documents the provider-owned operator-family layout. |
| aklr/core/validation/stages/_bench/_evaluation/_request.py | Assembles output-dtype arguments using parameter names declared by contracts. |
| aklr/core/validation/stages/_audit/_rules.py | Adds parameter-name exemptions to builtin-I/O detection. |
| aklr/core/contract/spec/_args.py | Adds and preserves explicit dtype-parameter metadata. |
| aklr/core/contract/fastkey/_fast_key_fn.py | Generalizes output-dtype dispatch-key generation to use declared parameter names. |
| .github/README.md | Updates the documented operator API namespace. |
Review effort: Max
| if return_lse: | ||
| return offer(mla_prefill_varlen_lse.serving(q, k, stand_in, offsets, **call), _run_flash_attn_varlen) | ||
| del call["causal"] | ||
| return offer(mla_prefill_varlen.serving(q, k, stand_in, offsets, **call), _run_flash_attn_varlen) |
There was a problem hiding this comment.
This is the design main already has for the pass with the lse (aklr/plugins/aiter/provider/mla_prefill.py on main serves aiter's bf16 flash_attn_varlen with mla_prefill_varlen_lse and qkv_fp8=True); the pass without the lse follows it, held to the contract's ATTENTION_FP8_SNR bound against the baseline. Whether a bf16 call should be served in fp8 at all is the owner's call; raised with them, no code change here.
There was a problem hiding this comment.
The owner keeps this as is: same design as main's pass with the lse.
| { | ||
| "schema_version": 5, | ||
| "name": "rms_norm_hidden_size6144", | ||
| "contract_id": "rms_norm@1.0", | ||
| "description": "normalized = x * rsqrt(mean(x**2) + epsilon) * weight, the mean over the hidden axis.", | ||
| "name": "rmsnorm_hidden_size6144", | ||
| "contract_id": "rmsnorm@1.0", | ||
| "description": "aiter's rmsnorm: normalized = input * rsqrt(mean(input**2) + epsilon) * weight, the mean over the hidden axis.", | ||
| "op_type": "rms_norm", | ||
| "axes": { | ||
| "n_tokens": { |
There was a problem hiding this comment.
Done in efe1403: the 284 moved schemas carry no speedup, accuracy or microseconds; the measurement bot writes them back after the merge (the PR body says so, with the risk until then). perf-guard passes on that head: https://github.com/AMD-AGI/AKLR/actions/runs/45644235518
| """The MoE pooler and unpooler, which vLLM runs through F.linear, as aiter's GEMM, which AKLR's aiter | ||
| provider answers; a call it declines runs aiter's tuned GEMM (its split-K kernels for these shapes | ||
| accumulate in bf16).""" | ||
| if not _IS_PROVIDER_ON: | ||
| return FallbackReason.DISABLED | ||
| from aiter.tuned_gemm import gemm_a16w16 | ||
|
|
||
| return gemm_a16w16(x, layer.weight, bias) |
There was a problem hiding this comment.
Kept as is, by the owner's decision: the vLLM routes call aiter's api directly, and a call the provider declines runs aiter's kernel (the docstring says so). AKLR_AITER_PLUGIN is off by default, and without it vLLM keeps F.linear. The accuracy risk with the plugin on is now in the PR's Risk section.
| @@ -143,7 +143,7 @@ def test_baseline_summary_is_the_first_sentence_of_the_baseline_docstring(baseli | |||
|
|
|||
|
|
|||
| def test_collect_reads_every_committed_kernel_with_any_size_axes_as_wildcards(): | |||
| root = locate.op_dir("aklr.plugins.aiter.gemm").parents[2] | |||
| root = locate.op_dir("aklr.plugins.aiter.provider.gemm").parents[2] | |||
There was a problem hiding this comment.
Not reproduced: locate.op_dir("aklr.plugins.aiter.provider.gemm") is aklr/plugins/aiter/provider/gemm, so parents[2] is still aklr/plugins, and the sglang and vLLM kernels are under the root. pytest tests/benchmarks/test_kernels_report.py: 9 passed on this head.
| @@ -468,7 +476,7 @@ def schema_at(source: str, ms: list[int], author: str = "") -> tuple[str, str]: | |||
| workloads=[{"axes": {"m": m}, **measurement} for m in ms], | |||
| kernel=case.schema(source).kernel.model_copy(update={"author": author}), | |||
| ) | |||
| return f"aklr/plugins/aiter/{op_type}/{schema.relative_path()}", schema.schema_text() | |||
| return f"aklr/plugins/aiter/provider/{op_type}/{schema.relative_path()}", schema.schema_text() | |||
There was a problem hiding this comment.
The measured fields are gone from the moved schemas (efe1403) and perf-guard passes on that head. A base-to-new-path case for the audit helper is not added in this PR.
| id(name) | ||
| for fn in ast.walk(source.tree) | ||
| if isinstance(fn, (ast.FunctionDef, ast.AsyncFunctionDef, ast.Lambda)) | ||
| for name in ast.walk(fn) |
There was a problem hiding this comment.
Confirmed: def _rows(open=open("/tmp/data")) got no SA3. Fixed in 0a9c20d: only names in the function's body count as its parameters, so defaults, decorators and annotations are audited; test builtin_called_in_the_default_of_a_param_of_that_name locks it. The audit over every schema under aklr/plugins still has 0 findings.
| (`aklr/plugins/aiter/provider/<op>/baseline.py`), the call bench times. At a Point no kernel serves, the api returns a | ||
| `FallbackReason` and its caller runs its own path. AKLR's plugins route a model to plugin ops and to some | ||
| `aklr/plugins/aiter` ops (vLLM's GEMM and MoE layers, sglang's DSA paged MQA logits; `aklr/plugins/README.md`), so an | ||
| `aklr/plugins/aiter` kernel runs in a model only where such a route or the engine calls its api. |
perf-guard takes a schema at a new path for a new schema, which may not carry speedup, accuracy or microseconds. The 284 moved schemas drop them; the publish-measurement bot writes them back after the merge.
…ion is still audited A function's own parameter hides the builtin of its name in its body only; its defaults, decorators and annotations run where the builtin still is, at import.
…o Point steadily at 1.05 It failed this PR's aiter-test as no_qualifying_workload on speed alone (1.01x-1.04x, accuracy ok): at its new path it is held to the entry threshold. Its content is main's, where the newest measurement is 1.010x-1.091x with 5 of 14 workloads at 1.05 or more. The file stays as a definition (c0450a5e): its scenario and workloads, no kernel. Dispatch falls back to aiter at those Points (n_tokens 96-384).
The moved schemas keep no measured fields (perf-guard takes them for new schemas); main's measurements of the sglang and vLLM schemas come in.
…der is on vLLM's routes no longer ask aiter whether it asks AKLR: they call aiter's function, and aiter reaches AKLR through the provider or runs its own kernel. The warmup counts a call aiter ran itself as not served. READMEs say sglang and vLLM call aiter, not the provider's apis.
…ype, as #352 asks Since #352 a contract's `out` output no longer brings an implicit out_dtype param: the contract names it on the output's dtype (param_name="out_dtype"), as minimax_m2 and qwen*_moe now do. Without it the audit's SA4 rejects the two ops' kernels, whose entries take out_dtype. glm53_dense_index_layer's layer_out keeps the index layer's spec, which has none, at glm53_moe_layer's bound. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…its output's dtype param Since #352 a contract's api takes an out_dtype only where an output's dtype names it; the tail's route and kernel take one, so its contract names it (the kernel and its schema file are unchanged).
…359) * fix(plugins/aiter): move gemm_n19360_k6144 under provider/gemm/impls #281 added the two gemm_n19360_k6144 schemas at aklr/plugins/aiter/gemm/impls while #352 moved the op families under provider/. Left at the old path, outside the gemm op package, they are not loaded: dispatch has no kernel for n=19360, k=6144 and aiter keeps its own. * fix(gemm): gemm_n19360_k6144 carries no measured fields at its new path A path absent at the base may not carry speedup, accuracy or microseconds (perf-guard and the audit): only the publish-measurement bot writes them.
…group Under DCP8, vLLM 0.34.0's MLA decode gathers each step's query on the DCP group, which has no aiter communicator, so the gather runs RCCL through torch.distributed. Where the DCP group holds the TP group's ranks, a route on MLADCPManager._gather_query (vLLM 0.34.0 and 0.32.1rc1.dev276) asks vLLM's TP group for the same gather (GroupCoordinator.all_gather): in a CUDA graph it then runs the path vLLM's own TP all-gathers take, on aiter's all-gather, and AKLR calls nothing of aiter's itself. - The first eager call is compared byte for byte with the DCP group's own gather; a gather of another shape or group goes back to vLLM. - No contract and no kernel: [email protected] turns the route off (the id names the route). - Measured before the rebase onto #352 (8 MI355X, Kimi-K3 TP8 DCP8, DSpark k7, concurrency 4, random 2048 in / 2048 out): 336.4 -> 349.8 output tok/s (+4.0%), every round of on above every round of off.
… attn_res variants, the DSA indexer prefill, indexer GEMMs, the latent-MoE tail Kimi-K3.1-Pro's InferenceX image runs a vLLM fork reporting 0.0.0+mum.14d1ec2336. This adds its routes and kernels, each checked against the fork's source. - KDA prefill and speculative decode ([email protected], [email protected]): vLLM's chunk_kda_prefill and fused_recurrent_kda on 0.34.0 and the fork; FlyDSL kernels. Their out dtype is the API's out_dtype (#352). - [email protected]: the fork's attention-residual calls (rows 0-8, with and without the add, norm or bank write) on the attn_res route, the kernel's variants for them. - [email protected], a new op on the fork only: prefill_indexer's query tile under DCP (MXFP4 query quantizer, the ragged-prefill scorer on the staged pages, top-k, the ids made relative); baseline vLLM's tile as it runs it. It asks aiter >= 0.1.0. - [email protected] at 128 x 7168 and 32 x 7168 (the indexer's GEMMs) on the wvSplitKrc route, declared for the fork. - The latent-MoE tail (#302) declared for the fork; a call its defer_projection branch may make (a resolved quantized routed input, a token group on the down-projection, min_sharded_tokens rows) stays on vLLM. Each kernel serves the token counts its schema lists: no range dispatch (#276's is not taken). Workloads carry no measurements; CI writes them.
… gemm's workloads at its decode token counts (#276) * feat(plugins/vllm): Kimi-K3's MLA DCP query gather through vLLM's TP group Under DCP8, vLLM 0.34.0's MLA decode gathers each step's query on the DCP group, which has no aiter communicator, so the gather runs RCCL through torch.distributed. Where the DCP group holds the TP group's ranks, a route on MLADCPManager._gather_query (vLLM 0.34.0 and 0.32.1rc1.dev276) asks vLLM's TP group for the same gather (GroupCoordinator.all_gather): in a CUDA graph it then runs the path vLLM's own TP all-gathers take, on aiter's all-gather, and AKLR calls nothing of aiter's itself. - The first eager call is compared byte for byte with the DCP group's own gather; a gather of another shape or group goes back to vLLM. - No contract and no kernel: [email protected] turns the route off (the id names the route). - Measured before the rebase onto #352 (8 MI355X, Kimi-K3 TP8 DCP8, DSpark k7, concurrency 4, random 2048 in / 2048 out): 336.4 -> 349.8 output tok/s (+4.0%), every round of on above every round of off. * feat(plugins/aiter): gemm's workloads at the token counts Kimi-K3's decode steps take Dispatch serves a GEMM only at an m some workload holds. Kimi-K3 decodes with draft tokens, so a decode step's m grows with the running requests in steps of the tokens a request verifies (5 on vLLM with DSpark k4, 8 on SGLang with DSpark block 7), not through the few sizes the committed workloads were recorded at: in a recorded 8K/1K run of the daily e2e flow (concurrency 1 to 48) most decode GEMMs found no workload and went back to aiter. This adds those m as workloads of the kernels already on main: 759 workloads in 14 schema files, each beside the file of the kernel it belongs to (the same kernel, the new workloads alone, so the measured file keeps its fields). They are the decode-step sizes (up to 480 tokens, vLLM's largest CUDA graph) the recorded runs on vLLM 0.34.0 and SGLang 0.5.23 reached without a workload, each given to the committed kernel whose workloads lie around it. Prefill sizes (any token count) are left out. The workloads are unmeasured: CI measures them, and one that does not reach the threshold stays with aiter. Replaying the recorded calls through dispatch on the CPU, every workload counted as qualified: gemm serves 508 thousand of vLLM's 1.15 million GEMM calls (82 thousand before) and 136 thousand of SGLang's 304 thousand (111 thousand before); what remains unserved by a kernel that could take it is prefill (212 thousand on vLLM). CI's run on the first version of this commit (774 workloads in 16 files) found two files with no workload at 1.05x of aiter, which validation fails: gemm_n1536_k7168 at m 195 to 235 (0.89x to 0.90x) and gemm_n3584_k7168 at m 65 to 76 (0.90x to 0.91x). Those two files are left out.
…ts fp8 attention residual, and the attention-residual and GEMM points main misses (#302) * feat(plugins/vllm): Kimi-K3's latent-MoE tail as one FlyDSL kernel on ROCmLatentMoERunner._shard_up_proj_tail Under tensor parallelism vLLM ends each Kimi-K3 latent-MoE layer on ROCm with four ops in ROCmLatentMoERunner._shard_up_proj_tail: the TP all-reduce of the routed experts' latent partial, the latent RMSNorm, the addmm of this rank's up-projection rows into its columns of the shared experts' partial, and the all-reduce of that shared output. The new contract [email protected] states the four as one op that every rank of the TP group calls (ranks="tp_size"); its baseline is vLLM's four ops on vLLM's TP group. Its one FlyDSL schema (B0, TP 8, hidden 7168, latent 3584) runs them in one launch and does both TP reductions over peer memory: an uncached buffer each rank allocates and every rank maps over HIP IPC, set up once over vLLM's TP CPU group. Below 28 rows the launch takes kernel_small.py, from 28 kernel.py (the up projection spread over up to 4 sets of workgroups, bulk hand-offs as data then flag). The schema is unmeasured; its workloads are the row counts 1, 2, 4, 5, 8, 10, 16, 20, 32, 40, 60, 64, 80, 120 and 128, matched exactly. The route, on vLLM 0.34.0 and 0.32.1rc1.dev276 (the same latent_moe_runner.py), takes 1 to 128 rows of dense bf16 at TP 8 and hands anything else back to vLLM. Every decision reads only what is the same on every rank, so the ranks launch the kernel together. The peer memory is set up by the first call outside a graph capture. The first eager call of each row bucket (rows of one bit length) is checked against vLLM's tail on the same operands; the ranks agree on the verdict, and a bucket any rank finds different stays with vLLM. Fail-stop: an in-kernel wait gives up after 10 s, records where it waited and sets a sticky FAILED word, so no rank hangs. The vLLM plugin gets AFTER_STEP, a list of watches run after each execute_model on every rank; the op registers one that every 16 steps has the ranks agree over the CPU group and raises on all of them at the same step once any rank's wait gave up. Switches: AKLR_VLLM_MOE_TAIL=0 hands every call back to vLLM; AKLR_VLLM_MOE_TAIL_CHECK=0 skips the first-call check. The kernel requires flydsl>=0.3.2, as CI runs; it has been compiled and run on FlyDSL 0.4.0 only. Measured on 8 MI355X in the vLLM 0.32.1rc1.dev276 image: 92 layers in one CUDA graph, cold weights, the slowest rank, us a layer: M B0 vLLM 1 9.78 40.92 2 10.40 42.63 4 11.66 45.25 5 12.21 44.25 8 14.26 43.67 10 16.30 45.85 16 19.65 45.00 20 22.99 45.10 24 25.46 45.35 32 28.70 46.07 40 29.93 48.81 60 35.28 53.06 64 35.76 53.38 80 42.10 56.48 120 49.80 63.69 128 51.76 64.07 At each M every harness check passes: the same bits on all ranks, within the contract's bound of the reference, the first-call check against vLLM, AKLR's dispatch serving the same bits, 100 graph replays each the eager bits, and no wait gave up. M=24 has no workload in this schema, so here it stays with vLLM. * feat(fastkey): rows of one page grid that never meet are not an overlap vLLM keeps a Mamba layer's convolution state and recurrent state in the same pages: a slot's convolution state, then its recurrent state. Their spans interleave, so the fast key's overlap test declined every call that writes one of them in place and reads the other. Two tensors whose spans meet are now apart when they have the same row stride in bytes, each row is dense, and the other's row lies, in every page, between the end of the written one's and the start of the next page. Rows that meet, or of another stride, still decline. This changes aklr/core, so validation re-benches every schema. * feat(plugins): kimi_k3_kda_spec_stage_c, Kimi-K3's KDA layer in a speculative verify step as one FlyDSL launch In a pure speculative verify step, vLLM's Kimi-K3 runs each KDA layer between in_proj and o_proj as three kernels: a copy of f_a, the f_b GEMM, and aiter's fused short convolution + recurrence + gated norm. The new contract [email protected] states that stage on vLLM's tensors (views of the in-projection's rows, the conv and recurrent states in their shared Mamba pages); its baseline is vLLM's f_b GEMM dispatch and aiter's fused kernel. The route at KimiDecoderLayer._run_self_attn (vLLM 0.34.0 and 0.32.1rc1.dev276) runs vLLM's in_proj, the op, then vLLM's o_proj. Everything else goes back to vLLM before anything runs: MLA layers, prefill, mixed and plain decode steps, ragged windows, breakable graphs, and a layer or cache outside the contract, such as a recurrent state that is not float32 (vLLM 0.34's mamba_ssm_cache_dtype). AKLR_VLLM_KDA_STAGE_C=0 hands every call back. One FlyDSL kernel (gfx950, 12 heads a rank, DSpark's window of 5), one schema with a workload at every count of 1-32 sequences, unmeasured. On MI355X, graph replay, us per layer: n_seqs 1 2 4 8 16 24 stage C 10.6 11.6 12.6 14.1 20.5 30.5 vLLM f_b + aiter 19.9 18.6 19.6 20.5 24.8 35.5 Against the contract's reference it passes on mixed, padded and chained windows, and two launches are bitwise equal. Needs the fast key to take the two caches' interleaved page rows (previous commit). * refactor(plugins/vllm): the latent-MoE tail and KDA stage C references in float32, called without decode #293's contract on main: no decode argument, operands read through to_float32. Stage C's tests' Points carry each operand's logical dtype. * feat(plugins/vllm): Kimi-K3's attention residual with an fp8 out, and the K3 attn_res and GEMM points main misses vLLM's _apply_attn_res asks attn_res for a per-token fp8 out (quant_dtype float8_e4m3fn, with its scale) where the linear after it takes fp8: about half of Kimi-K3's attention-residual calls. The new contract [email protected] states that out beside [email protected]'s (its reference in float32, as #293's); the route hands those calls to it (fnuz fp8 stays with vLLM) and also declares vLLM 0.32.1rc1.dev276, the K3 AgentX image. 124 schemas (unmeasured; CI measures) at the points of the Kimi-K3 AgentX trace that main does not serve, each kept only where an 11-20 validate on MI355X (vLLM 0.34.0 image, graph mode, paired against the baseline) passed accuracy and ran >= 1.05x with its lower bound >= 1.0 (310 points measured twice keep the worse): kimi_k3_attn_res 74 schemas, 1736 points, 1.05-2.09x kimi_k3_attn_res_fp8 44 schemas, 546 points, 1.06-2.20x gemm n2112/n6288 k7168 1.14-1.64x, n3584 k7168 1.20x, n20480 k7168 1.13x, n2304 k1536 1.06x, n3072 k512 1.05x * fix(fastkey): compare the written tensor's storage extent with the others', not their logical sizes A strided view reaches past its nbytes: a state view one page after its convolution view lands on the later pages' convolution rows, though the two views' logical sizes end before it. The overlap guard now compares the extents from the first element to the end of the last (_span) before it asks whether the two are rows of one page grid apart in every page. * fix(plugins/vllm): KDA stage C opt-in, tensor-dependent declines asked again, the baseline's float32 scale and staged conv weight - The route runs only with AKLR_VLLM_KDA_STAGE_C=1, read at each call: over three chained steps of two sequences the op and vLLM's served aiter chain are not yet shown to agree. - The route keeps a shape's verdict only: OUT_OF_CONTRACT, which can come from the step's own tensors (a slot table off the fast key's 16-byte alignment), is asked again at the next step, as NOT_WARMED was. - The baseline compares scale with head_dim ** -0.5 as float32s: the workloads record 0.0883883461356163. - The baseline's width-major conv weight belongs to the weight tensor, freed with it, and is staged again from the weight's values at every call outside a graph capture (validation reloads weights in place); a capture, what bench times, reads the copy of the eager call before it. - state_indices: positive slots distinct, 0 and -1 repeated in vLLM's padding windows; the schema re-rendered (uuid unchanged, unmeasured). The drawn distribution stays positive and distinct. - Tests: the switch, the recheck, the scale, the in-place reload and the staged copy's lifetime; on a GPU, the capture, and on gfx950 the kernel on padding windows of 0 and of -1 and a padding row against the reference. * fix(plugins/vllm): the latent-MoE tail's ranks agree before every collective path; shared written in place; a failed step reported at that step without a host wait - The route hands the dispatcher aligned, non-overlapping operands and agrees serve or fall back over the TP CPU group on each (rows, eps, capture) key's first call; setup agrees after each step that can fail on one rank (GPU check, allocation and export, mapping) before the next collective, and releases what it made. - shared is written in place, as vLLM's addmm_ does: the contract makes it mutable, the reference returns it, and both kernels write their own columns in the up stage's epilogue, after the flags. - Fail-stop: a wait that gives up writes FAILED into every rank's peer buffer; each step copies its rank's word to pinned memory on a side stream and the step's output leaves the worker only after that copy is checked in vLLM's output thread (no collective, no host wait, nothing inside a capture). PP falls back. - n_tokens covers the op's own range; the kernel's 128-row cap lives in its workloads and the route's guard. - Failure-injection tests on spawned gloo ranks. On 8 MI355X (vLLM 0.34.0 image): within the bound, shared's own columns in place and the others untouched, the same bits on every rank and over 100 graph replays; a stalled rank's step raises on all 8; setup and alignment faults agree on all 8; after_step 36 us CPU with the step's GPU work still running (49 of 50 steps), 12.8 us on the step's stream; 0.5-0.8 us a layer over the head's kernel at M >= 40. * fix(plugins/vllm): Kimi-K3 attention-residual kernels zero their claim counter in the call, mask with -inf, mix without overflow In the 12 kernel sources the review found (94 schemas, re-rendered and unmeasured): - the claim counter is torch.zeros in the call, only where a token past the statically assigned ones can be claimed; the rows5 split zeroes its slots' 8-byte tags and reads a partial only under its tag; - masked lanes score -inf; - the exponentials are scaled by 2**-4 (exact) instead of left unnormalized, so the mix and its sum of squares never exceed the normalized ones; outputs match the previous kernels bit for bit wherever their mix did not overflow. On MI355X: 1348 checks of the review's inputs (claims under a poisoned allocator, 20 eager calls and 20 graph replays; rows scoring -3.35e38; rows of 2**57) and 50 gfx950 cases pass. Paired with the head's kernels over 120 workloads, graph mode: geomean 0.998, the same bits; the rows5 split at 513-560 tokens is 1.14-1.16x for its per-call zeroing. * fix(plugins/vllm): the latent-MoE tail serves vLLM 0.34.0's unpadded calls, whose trunc_size is the hidden width vLLM 0.34.0 passes a latent MoE with shared experts the shared experts' width as the tail's trunc_size, padded or not, and keeps states[..., :trunc_size]. The route took any trunc_size as a padded hidden dim, so on Kimi-K3 it declined every call (seen serving the AgentX recipe on 8 MI355X). Only a size below the hidden width strips columns now; the test that called HIDDEN padded uses a real truncation, and a new one has None and HIDDEN reach the dispatcher. * refactor(plugins/vllm): the latent-MoE tail, KDA stage C and fp8 attention residual on #322's references, baselines and bounds - [email protected]: KimiK3LatentMoeTailReference (a DistOpReference, every rank's call and the rank) and KimiK3LatentMoeTailBaseline (a DistOpBaseline); group.py goes, its peer memory set up by the baseline's setup over the default group. No teardown: the buffers live until the process ends, as in vLLM, since a rank cannot free its buffer before its peers stop writing to it without a collective that a peer stopped at a finding would never join. - [email protected]: KimiK3KdaSpecStageCReference and KimiK3KdaSpecStageCBaseline on the call's keywords; L2_NORM_EPS moves to the reference, which alone reads it. max_violation_fraction goes: on MI355X (11-23, before the reference rounded its out) the committed kernel's state_cache peaked at 0.19 of its bound and out at 0.34, no element past either. - The references return their outputs in the declared dtypes, so the bf16 and fp8 outputs' bounds add one rounding of the output's dtype (2**-7, 2**-3), as #322 did for the bounds that relied on the compare's own allowance: the latent-MoE tail's out and shared, stage C's out and kimi_k3_attn_res_fp8's quantized. Float32 and exact bounds are unchanged. - The tests call the classes and read check()'s failures. - The 126 schema files of these contracts and of gemm drop max_violation_fraction and element_order, rendered by schema_text; their kernels and workloads are unchanged. * refactor(plugins/vllm): the latent-MoE tail's kernels import their runtime from aklr.core.jit (SA5) SA5 lets a kernel import nothing of aklr but aklr.core.jit; the tail's kernel.py and kernel_small.py imported the plugin's runtime module, the per-rank state they run with (the peer buffers, launch counters and health words) and its constants. The module moves, unchanged but for one thing, to aklr/core/jit/kimi_k3_latent_moe_tail.py, and the kernels' one import line follows; the schema file takes its new uuid. The kernels' code and the workloads are as they were. The one thing: setup no longer adds the fail-stop watch to the vLLM plugin's AFTER_STEP (core imports no plugin); the route adds it once its group is set up, as setup did there. * revert(plugins/vllm): KDA stage C and its fast key change leave this PR [email protected] is a route without end-to-end evidence: its one schema holds windows of 5 tokens, and the deployment verifies windows of 8, so the route never served a step there. Its contract, reference, baseline, route, schema, tests, small Point and names go, with the AKLR_VLLM_KDA_STAGE_C switch. The fast key's storage-extent and page-grid overlap tests were added for stage C's interleaved Mamba pages; they go with it, and aklr/core/contract/fastkey and its test are main's again. The latent-MoE tail and the attention residual pass their tests without them. * refactor(plugins/vllm): the latent-MoE tail's group state lives in its kernel's sources, not in aklr/core The per-rank state the tail kernel runs with (the peer buffers every rank maps, the launch counters, the health words and their setup) was aklr/core/jit/kimi_k3_latent_moe_tail.py, one op's code in the core. It is now runtime.py of the kernel's own sources, as mega_moe keeps its buffers in its sources, and the kernels import it relatively (SA5): - The vLLM route sets the group up through the module of the kernel the dispatcher serves the call with (api.serving's metadata names the kernel's module; runtime is a module of its package), over vLLM's TP group, before that kernel's first call. Where no caller set one up (validation's ranks), the kernel's first call sets it up over torch.distributed's default group, in a compile function (runtime.default_group). The CPU barrier after a build's first, compiling launch is a compile function too (runtime.every_rank_compiled). - The fail-stop watch, the vLLM plugin's step hook, is the plugin's (failstop.py); it copies the group's FAILED word with the runtime's HIP calls. TailGroup keeps only what launches read; its unused failed, clear_failed, given_up_waits and close go, with Hip.zero. - The baseline sets nothing up: vLLM's tail sets its TP group up at its first call. The route: - Shapes, dtypes, layouts and the TP size are the op's to judge: the route no longer checks them against 8 / 7168 / 3584, and hands vLLM's TP size over. It declines before the dispatcher only what vLLM's tail computes otherwise (padded columns stripped, a reduced routed output, no latent norm, pipeline stages) and, new, a skipped final all-reduce (moe_config.skip_final_all_reduce). Row counts past every committed schema's go back before the dispatcher's verdict, which costs a collective at each new count. - AKLR_VLLM_MOE_TAIL and AKLR_VLLM_MOE_TAIL_CHECK go: [email protected] hands every call to vLLM; the first eager call of a row bucket is always checked. - versions: 0.34.0, the release it was run on. The kernel's sources otherwise: run_traced (no caller) goes, run returns nothing, the entry docstring holds no measurement or commit, and requires FlyDSL >= 0.4.2, the version it was developed and run on. The kernels' device code is unchanged. * fix(plugins/vllm): the latent-MoE tail's contract states the op, not the kernel; common SQNR bounds - tp_size takes 2 and 4 too: vLLM runs the tail at any TP size that divides the hidden width. latent_size % tp_size goes: vLLM requires no such split; the kernel's own is its schema's. - out and shared take the GEMM's common bf16 bound (45 dB). The tolerance's absolute part held only for partials below 16 in magnitude, the workloads' draws: where a rank's own column cancels in the sum over ranks, the kernel's one rounding against vLLM's two (out), or a normalized latent rounded apart at a tie (shared), shows in full. The CPU model of the committed kernel's layout is at 55 dB (out) and 83 dB or more (shared) from 1 to 128 rows. * fix(gemm): Kimi-K3's n 2112 / 6288 kernel zeroes the scratch words a launch compares with its tag The kernel's split launches (tiled.py's two-way K split, which serves its m 600 and 1030 workloads, kernel.py's split-K and skw.py's folds) tell which split folds by comparing scratch words with the launch's tag (dispatch id and queue), and the call handed them torch.empty scratch: a word an earlier tensor left there could hold the tag, and a split would fold before the others wrote their planes. As the attention residual's kernels now do, the call zeroes those words (aklr/ops/README.md: scratch is written before it is read): the tiles' fold counters after the partial planes (_scratch; the builders report where they start), and skw.py's scratch whole. The planes, which every launch writes before it reads them, are not zeroed. The device code is unchanged; each call with split scratch runs one small fill before the launch. The schemas require FlyDSL 0.4.2, the version the kernel is run on. * fix(plugins/vllm): the rows5 attention residual's split build takes the mix's sum of squares from the mix Past 512 tokens the rows5 kernel spreads each leftover token over 14 column shares, which exchanged the rows' dots, sums of squares and cross products and took the mix's sum of squares from those Gram partials, sum w_r^2 |x_r|^2 + 2 sum w_r w_s x_r.x_s. Where rows cancel the terms are far larger than the result: in a float32 model of the merge, bank rows x and -x at 1024 times the others put 7140 of 7168 columns past the contract's bound, and at 4096 the sum is negative and the out NaN (the reference, vLLM and the other kernels sum the mix's squares). The shares now exchange twice: the dots and sums of squares (the scores; the cross products go), then each share's sum of squares of its own columns of the mix, summed over the token's shares in slot order; a partner late on either is recomputed from its rows, and p is stored into the prefix only after both exchanges. The call zeroes both tags of a slot. The float32 model of the new merge passes the bound at every ratio up to 2**20; a gfx950 test runs the committed kernel at its split workloads (520, 550) on such rows. The second exchange lengthens the share wave's merge, which the token waves' second barrier waits for: the split workloads are expected somewhat slower. * fix(plugins/vllm): the Kimi-K3 attention residual's fp8 bound, overflow-safe reference, export and requires - kimi_k3_attn_res_fp8's quantized bound is one fp8 code again (2**-3 of the value, 2**-9 below the normals): both sides are fp8 values, so the output's own rounding adds nothing. - The reference takes each mean square of a row scaled down by a power of two first: rows near 2**58 with a norm passed float32 in their squares and gave 0 where the normalized mix is the norm weight. Its results elsewhere are bit for bit the former ones. - The package exports kimi_k3_attn_res_fp8; the baseline's copy of vLLM's launcher is checked against vLLM's in fp8 too (gfx950). - The contract no longer comments on how a kernel or dispatch serves its tokens. - One schema of the rows5 kernel goes: it repeated another file's kernel at a subset of its workloads. - The 117 schemas this PR adds require FlyDSL 0.4.2, the version their kernels were developed and run on. * test(plugins/vllm): the latent-MoE tail's committed kernel on 8 gfx950 GPUs The GPU checks of the tail, run on 8 MI355X by hand so far, as gfx950 tests that spawn 8 ranks of one torch.distributed group (skipped on fewer than 8 GPUs): - the kernel computes the op on every rank, at every row count of both builds: the same bits on every rank, out and the shared partial's own columns within their bounds of the reference, the other columns untouched, 100 graph replays the eager bits, no wait given up; its first call sets its group up over the default group, as validation's ranks do; - through the route and the committed schema every rank serves, and the group the route set up through the serving kernel's runtime is the one the kernel reads (the kernel set none up), with the fail-stop watching it; - a rank late past the kernel's (2 s) wait: every rank finishes, the step's output and the next's raise on every rank, through the plugin's step hooks and the group word the kernel wrote; late below it, the exact out, the output handed over; - HIP's allocation, export or mapping failing on one rank: setup is None on every rank, nothing left, a clean setup after; - one rank's operand off alignment or aliased, or its dispatcher without the schema: the group serves (or declines) together. * docs(vllm): the plugin tutorial's fp8 output is kimi_k3_attn_res_fp8's; an op whose ranks call it together The tutorial said the attention residual's fp8 output was in no contract and _triton.py had no fp8 launcher; this PR adds both. A section on the latent-MoE tail states the rules of an op whose ranks call it together: the same path on every rank, the kernel's state in its own sources set up by the route (or by its first call over the default group), the in-kernel 10 s wait that fails the group, the plugin's AFTER_STEP step watch that stops the step, and AKLR_DISABLE to turn it off. * test(plugins/vllm): the tail's setup-failure test measures what a failed setup leaves, not the process's first tensors On 8 MI355X the mapping case failed on every run: it is the first case that gets as far as the group's tensors, and a process's first GPU tensors cost it 2 MiB of the device once (measured per rank: 2.0 MiB on the 7 ranks that mapped, at the first such case only; 0 at every later one, mapping failures included). The test makes such tensors before it measures, and the ranks meet at a CPU collective between the release and the measurement, as a peer that still maps a rank's buffer keeps its memory. * fix(plugins/vllm): the latent-MoE tail's baseline sets vLLM's TP group up where its sockets' paths fit CI's vllm-test aborted the tail's schema: every workload's baseline failed with "ZMQError: ipc path ... is longer than ...". vLLM's TP group binds its message queue's ZMQ sockets at <VLLM_RPC_BASE_PATH>/<uuid4>, the base by default the temp directory, and validation gives each task a TMPDIR nested deep enough that the path passes the 107 bytes a Unix socket path holds. The baseline now sets the group up with VLLM_RPC_BASE_PATH at /tmp (vLLM's default without TMPDIR) where the temp directory is too long, keeps a base the caller set, and puts the variable back afterwards. A CPU test sets up a stand-in vLLM under validation's nested TMPDIR, a short one, and a preset base; it fails without the fix. * docs(tests): the attention residual's scratch test names aklr/plugins/aiter's README, where #327 moved it * fix(plugins/vllm): the latent-MoE tail's baseline times its graphs inside vLLM's graph_capture vLLM's TP all-reduce (aiter's custom all-reduce on ROCm) registers the buffers a CUDA graph reads as vLLM's graph_capture ends, after the capture and before any replay. The bench captured the baseline's graph outside it and replayed it at once, so the replays read unregistered peer addresses: a GPU memory fault at a null address on all 8 ranks, every workload candidate_crash in CI's vllm-test. The baseline's profile (the candidate's clock too) now captures each graph inside graph_capture, on the timing's own stream; its eager calls stay outside, and with no vLLM TP group yet nothing changes. * perf(plugins/vllm): the latent-MoE tail's workloads are the rows it wins at in serving, 6 to 14 validate times the kernel alone, and there it is 1.5 to 4.3 times vLLM's tail at every row count to 128. A served decode step says otherwise past a few rows. Kimi-K3 on 8 MI355X, vLLM 0.34.0, the daily 8K/1K flow, CUDA graphs replayed on the eight ranks, each step timed alone, AKLR on with the tail served against the tail left to vLLM: rows of the step 6 10 16 20 30 40 80 step, tail served 16.82 17.39 - 21.53 24.45 26.57 34.08 ms step, tail vLLM's 16.56 18.04 - 21.02 22.93 25.41 33.18 ms the kernel saves -0.26 +0.65 -0.15 -0.51 -1.52 -1.16 -0.90 ms (two servers, one prompt a concurrency: about 0.5 ms of resolution). vLLM's two all-reduces, its norm and its addmm are not slow when eight ranks step together, and the waits of the kernel's hand-offs outweigh the launches it saves; the kernel's own time shows none of that. The schema, the same kernel in one file, now holds 6, 8, 10, 12 and 14 rows: the even graph sizes around the one where the step gains, all in the kernel's small launch (under 28 rows); 8, 12 and 14 were not timed in serving on their own. The route's guard is the largest committed row count, so it follows to 14. The tests that drove the route at 15 to 40 rows use rows up to 14. * fix(plugins/vllm): the latent-MoE tail's contract names out_dtype as its output's dtype param Since #352 a contract's api takes an out_dtype only where an output's dtype names it; the tail's route and kernel take one, so its contract names it (the kernel and its schema file are unchanged). * test(plugins/vllm): the tail's graph-capture test stands in for the timing module It imported aklr.core.utils.testing inside the test. Importing that module registers AKLR's profiler with rocprofiler-sdk, which the vLLM image's SDK refuses once the GPU is up: in vllm-test, where the tests before it have used the GPU, both cases failed on the import (8 MI355X, tests/plugins/vllm in one process). The test only needs the two names the baseline reads, which it replaced anyway: it now puts a module holding them in sys.modules and on aklr.core.utils (the baseline's 'from aklr.core.utils import testing' reads the package's attribute first), and both are put back afterwards. * test(plugins/vllm): the tail's route tests ask for the row counts its schema holds Two of the 8-GPU tests went through the route at 1 to 128 rows, and at 10 and 40. Since the schema kept the rows the kernel wins at in serving (6 to 14), the route serves no other count, and both failed on a GPU (served: False at the others). They now ask for the schema's own counts; the test of the kernel itself keeps 1 to 128 rows. * test(plugins/aiter): the K3 GEMM kernel test tells its kernel by the scratch it hands out, not by sizes The test picked, in gemm_n2112_k7168 and gemm_n6288_k7168, the schema files with skw.py whose smallest m is past 128 rows, to leave out main's sibling kernel (skw.py too, small m, no _scratch). A schema may hold any m: a file giving the sibling larger sizes (#276 adds one at 148 to 380 rows) was taken for the K3 kernel and failed on _scratch. It now picks the files whose sources define _scratch, which is what it tests. --------- Co-authored-by: kyle-256 <[email protected]>
… kernels under provider/gemm/impls (#366) #354 was merged without a rebase onto #352, which moved the op families under provider/. Its two fixed kernels (bf74e6e2, 93d75fc2) landed at aklr/plugins/aiter/gemm/impls, outside the gemm op package, where nothing loads them, and the files they replace (feac6650, f1dc78b3) stayed under provider/ and kept being served without the fix. Move the two new files to provider/gemm/impls, byte for byte, and remove the two they replace, as #354 intended. The two kb pages that cite the old files now cite the new ones, and the strip page describes the in-stage reads.
#352 moved fused_moe's reference under aklr/plugins/aiter/provider; qwen2_moe_mxfp4_router_experts's reference takes _mxfp4 and mxfp4_weight from there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
#352 dropped out_dtype from the kernel call keys (SA4); both kernels' run take exactly hidden_states, router_weight, shared_gate_weight, w1, w1_scale, w2, w2_scale, topk and out. No other change: the schemas' uuids follow their sources. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…der provider/ after #352
…ype, as #352 asks Since #352 a contract's `out` output no longer brings an implicit out_dtype param: the contract names it on the output's dtype (param_name="out_dtype"), as minimax_m2 and qwen*_moe now do. Without it the audit's SA4 rejects the two ops' kernels, whose entries take out_dtype. glm53_dense_index_layer's layer_out keeps the index layer's spec, which has none, at glm53_moe_layer's bound. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…to 40 tokens, TP4 (#240) * feat(plugins): Qwen3.5 MXFP4 MoE with the shared expert fused in, on _forward_router_experts A new contract, [email protected]: the router and 513 MXFP4 expert slots, the shared expert last at sigmoid(hidden_states shared_gate_weight^T), as sglang runs Qwen3.5's AttnFP8-V2 checkpoint (whose shared expert is MXFP4 and fused into the experts). The reference quantizes both expert linears' inputs to MXFP4 per 1 x 32 as [email protected]'s does (aiter's per_1x32 path), at the common MXFP4 MoE bound; the baseline is sglang's path: its small-M router or the gate, fused_topk and the fused shared append, then FusedMoE on aiter (the gfx950 small-M kernel up to 40 tokens, else fused_moe at per_1x32). The _forward_router_experts route takes Quark's MXFP4 experts too and calls the new op for them; where it does not serve, the whole call falls back to sglang (larger token counts then reach the fused_moe route). Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(plugins): Qwen3.5 V2 MoE block kernels for 4 to 40 tokens at TP4 Two kernels for [email protected] at hidden size 4096, 512 + 1 experts, intermediate size 256 (Qwen3.5-397B-A17B-MXFP4-AttnFP8-V2 at TP4), at its EAGLE verify token counts (4 per request, 1 to 10 requests): - 4 and 8 tokens (Gluon, three launches): the router-complete MoE kernel of qwen2_moe_mxfp4_moe with its BF16 shared-expert branch replaced by an 11th route to slot 512. - 12 to 40 tokens (four launches): a Triton router (split-K logits, then one wave per token for the stable top 10, their softmax and the shared slot's gate) ahead of the two-stage FlyDSL fold kernel of the 513-expert fused_moe schemas. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(plugins): the Qwen3.5 V2 MoE kernels take the call without out_dtype #352 dropped out_dtype from the kernel call keys (SA4); both kernels' run take exactly hidden_states, router_weight, shared_gate_weight, w1, w1_scale, w2, w2_scale, topk and out. No other change: the schemas' uuids follow their sources. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…2's indexer at batch 24-192 (#285) * feat(mla): FlyDSL fp8_paged_mqa_logits (page 64, 32 heads) for GLM-5.2's indexer at batch 24-192 Band-sorted, page-major scoring that loads each page's fp8 keys once per request group. 1.49-4.79x over aiter at the 16 listed batches, none of them served on main. * fix(mla): serve every pool and table size, and any finite weight, in the GLM-5.2 indexer logits kernel n_pages, max_blocks and max_seq_len are any_size axes, so dispatch routes any legal pool and table here. The page-major path now takes more bands for a large pool (each at most 1024 pages), sorts band-relative page ids and gives each band its own 64-bit-based key descriptor, so pools past 2 GiB and tables up to the contract's 16448 blocks fit its packing. Pools past 2^21 pages, and batches outside the table, run the direct kernel (the former band kernel walking the block table without the prepass, a descriptor per page). The 2^26 relu pre-scale moves from the bf16 weights onto the fp32 result, so no finite weight overflows. tests/ops/test_flydsl_kernels.py covers both paths. * fix(schemas): drop the compare fields #322 removed; test against Fp8PagedMqaLogitsReference * style(tests): sort imports in test_flydsl_kernels.py per ruff * fix(mla): move the FlyDSL fp8_paged_mqa_logits schema and its test under provider/ after #352
* feat(plugins): scaffold SGLang monokernels, with GLM-5.3 (FP8)'s spec Co-authored-by: Cursor <[email protected]> * feat(plugins): glm53_moe_layer, GLM-5.3's MoE layer reading the previous top-k, as a monokernel op Co-authored-by: Cursor <[email protected]> * feat(plugins): GLM-5.3 monokernel's remaining ops and MTP draft, switched by AKLR_SGLANG_PLUGIN - glm53_moe_index_layer, glm53_dense_index_layer, glm53_embed, glm53_head and glm53_nextn_entry: contracts, references, baselines and FlyDSL kernels; the NextN draft's spec (draft.py). - AKLR_SGLANG_PLUGIN=1 now registers the monokernel specs as well as hooking the routes. Where SGLang loads sgl-amd-mono too (its ROCm images ship it), AKLR registers no spec, and --enable-amd-monokernel on a model AKLR covers stops start-up and asks for one plugin through SGLANG_PLUGINS. - The dsa_indexer and deepseek_v2 reference helpers the monokernel reuses are public (k_norm, fp8_linear, ...). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(plugins): glm53 index layers name only KV pool pages; a full top-k row in any order From PR #355's review: - glm53_moe_index_layer and glm53_dense_index_layer: max_pages pages must fit in the KV pool (64 * max_pages <= n_slots), and the page table draws only pages the pool holds; a point with max_pages > n_pages or a page past the pool no longer passes as in the domain. - The contract text matches the check: only a row of fewer than index_topk keys is its slots in order. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(plugins): glm53_moe_layer and glm53_nextn_entry name their out_dtype, as #352 asks Since #352 a contract's `out` output no longer brings an implicit out_dtype param: the contract names it on the output's dtype (param_name="out_dtype"), as minimax_m2 and qwen*_moe now do. Without it the audit's SA4 rejects the two ops' kernels, whose entries take out_dtype. glm53_dense_index_layer's layer_out keeps the index layer's spec, which has none, at glm53_moe_layer's bound. Co-Authored-By: Claude Opus 5.5 <[email protected]> * revert(core): keep env.py's AKLR_SGLANG_PLUGIN comment as on main Any change under aklr/core re-benches every schema in CI, and this comment alone sent sglang-test's validation over its time limit (476 schemas). The plugins' README states what the switch covers. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(plugins): glm53's two-rank reference tests take the call from OpCase.contract_workload #282 renamed OpCase.request (a TrialRequest) to OpCase.contract_workload (a ContractWorkload), whose reference_call is the same; the six glm53 two-rank tests still read the old name. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Cursor <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
#352 moved the gemm op to aklr/plugins/aiter/provider/gemm; this PR's two b_shuffled schemas move with it, their schema text as main's contract now writes it (no compare defaults). Co-Authored-By: Claude Opus 5.5 <[email protected]>



Why
AKLR's ops for aiter did not take aiter's signatures, and sglang/vLLM routes called AKLR's ops directly. Now every op family lives under
aklr/plugins/aiter/provider/, each contract takes its aiter op's signature, and a selector per aiter op answers aiter's kernel plugin interface (aiter.plugin). A call AKLR declines runs aiter's own kernel, so no other fallback is needed.Scope
aklr/plugins/aiter/provider/<family>/(439 renames);rms_normbecomes aiter'srmsnormandrmsnorm_with_add. 21 of the 30 contracts have a selector on one of aiter's routed ops.aiter.tuned_gemm.gemm_a16w16; a target verify'sfp8_paged_mqa_logitsrows are served by request, told by their block tables.AKLR_AITER_PLUGINstays off by default.fused_moekernel54abf86b(n_tokens 96-384) stays as a definition (c0450a5e). At its new path it is held to the entry threshold and measured 1.01x-1.04x in this PR'saiter-test(run 45645312741, accuracy ok); main's newest measurement of the same content is 1.010x-1.091x, 5 of 14 workloads at 1.05 or more.TODO(aiter-route), to be routed or removed later:unified_attention,paged_attention_decode,mla_kc_rope_cache,mla_vc,mega_moe,bmm,topk_transform_paged,gemm_a4w4_mxfp4, andflash_mla_with_kvcache'sdsv4_fp8pool.Tradeoffs
The verify selector reads the block tables (one device sync), only for rows AKLR has no kernel for as rows, and never while a graph is being captured.
Verification
Environment: head 16b118d. Unit tests: MI300X,
lmsysorg/sglang:v0.5.22-rocm10-mi30x. GPU runs (on the pre-rebase trees 48cbfa0 and 826e147, see Not run): MI355X, sglang v0.5.23 image, aiter a6c759b1, vLLM v0.34.0 image.Gate overrides: none on this head. The routing check below was run at
AKLR_MIN_SPEEDUP=0and at the default.Contracts
Code
pytest tests/core tests/plugins/aiter: 1121 passed, 295 skipped, 2 failed:test_backend_matches_reference[[email protected]_{0,1}], which fail on the local MI300X only (they pass on MI355X).tests/core/contract/test_op.py,tests/plugins/vllm/test_gemm_routes.py, selector tests intests/plugins/aiter/provider/.AKLR_MIN_SPEEDUP=0, 3154 workloads decided foraklr, all results pass their contract; 0 dispatch cycles; the workloads not routed are those of the 9TODO(aiter-route)contracts, one workload AKLR declines as inaccurate and onefused_moeworkload it answersno_workload.aklr, 0 wrong results.sglang-testandvllm-testpassed;aiter-testran 1410 unit tests (passed) and 3932 workloads (accuracy ok on all) and failed on the one kernel withdrawn above. The run of this head decides.aklr/corechanges (contract,validation; nothing underaklr/core/runtime/): api params the result does not depend on, an output's dtype picked through a param the contract names, and a kernel may read its own parameter named like an I/O builtin. No schema or measurement version changes. Kernels that changed result against main: none found in the run before the rebase; CI on this head decides.Not run
AKLR_AITER_PLUGIN=1.mega_moe's three files were not exercised by the routing check (it has no process group).tests/plugins/sglang/test_reference.py::test_backend_matches_reference[[email protected]]failed on MI355X before the rebase; not compared on main.Risk
Affects: every kernel under
aklr/plugins/aiter(paths and contract signatures), the sglang and vLLM plugin routes that reach them, and validation of every schema.AgentX: all
If wrong: until the bot writes the measurements back, the moved kernels have none on main, and AKLR declines an unmeasured kernel at the default threshold; a call that used to be served by AKLR falls back to aiter's kernel (slower), or a CI validation failure; a wrong selector mapping would give wrong output. With
AKLR_AITER_PLUGIN=1, a Muse Spark pooler or unpooler call AKLR declines runs aiter's tuned GEMM, whose split-K kernels for these shapes accumulate in bf16, where main kept vLLM'sF.linear: accuracy can drop on those calls.Undo:
git revert;AKLR_AITER_PLUGIN=0(the default) keeps aiter from asking AKLR.