Skip to content

feat(validation): one 5% bar for admission and dispatch, and acceptance criteria for kernel and plugin PRs - #153

Merged
zhenhuang12 merged 5 commits into
mainfrom
cursor/min-speedup-5pct-f4ec
Nov 12, 2026
Merged

zhenhuang12 merged 5 commits into
mainfrom
cursor/min-speedup-5pct-f4ec

Conversation

@xiaobochen-amd

Copy link
Copy Markdown
Collaborator

Why

Validation admitted a kernel when one workload's clamped lower bound exceeded 1.02, while dispatch served a workload only from a stored speedup of 1.03. A kernel could merge and never be served (41 Points on main sat in between). This sets one bar, 5%, for both, and writes down what a kernel or plugin PR must show.

Scope

  • aklr/core: DEFAULT_MIN_SPEEDUP = 1.05 in platform/env.py. AKLR_MIN_SPEEDUP defaults to it, and it is the entry ratio. A workload qualifies on its published speedup (the unclamped lower bound, to 3 decimals) compared with >=, the same way dispatch compares it. Retain (0.99) and the 2% rewrite tolerance are unchanged.
  • Withdraws the 6 kernel files with no workload at 1.05. Each serves one workload, with stored speedups 1.009–1.049. Their other kernels of the same name are kept.
  • docs/acceptance_criteria.md (+ .zh.md):
    • Kernel: 5% per kernel file, checked by CI.
    • End to end: a new plugin route, or one that now handles more cases, reports a 2% gain with its ops off and on. Recommended, not required, for kernels of an existing op or route and for new ops in aklr/ops/.
    • The PR template gains an End to end section.
    • The skills, harness/gates.md, the plugin tutorial and the README point to the criteria.
  • Docs, skills and the knowledge base now state 1.05 wherever they give the rule. Measurements recorded against 1.03 keep 1.03.

Verification

Environment: changes on 502285f9 (rebased onto be087c4f: #141, #143, #121 add kernel files only, none touched here); MI355X ×8, lmsysorg/sglang:v0.5.22-rocm10-mi35x, ROCm 7.15, Triton 3.8.0, FlyDSL 0.3.2, AITER dbd8bf5 (CI's)
Gate overrides: none

Code

  • pytest tests on MI355X: 945 passed, 0 failed, 166 skipped.
  • python -m aklr export check: passed.
  • pre-commit on the changed files: passed. kb_lint.py: 0 errors.
  • python -m aklr validate --stages audit,bench --devices 0:
    • deepseek_v2_fp8_moe … /01abd396 (1 token): passed, 2.0000.
    • The withdrawn ee90a36c (32 tokens), restored for the run: no_qualifying_workload, 1.0248 < 1.05.
  • Updated tests in tests/core/validation/test_pipeline.py for the 1.05 entry ratio and the >= comparison on the published speedup.

Schema version and measurement profile (19): unchanged. Against main:

Not run

  • CI validation of every schema on this head (needs ci:gpu; aklr/core changed, so every schema is re-measured).
  • pytest tests on MI355X after the rebase. The rebase adds only other PRs' kernel files.

Risk

Affects: every op. Workloads under 1.05 are no longer served, and new kernels need one workload at 1.05 to merge. Open kernel PRs whose kernel file has no workload at 1.05 will fail validation on their next CI run (possible in #122, #88, #81, #49 by their reported ranges).
If wrong: fewer workloads served than intended (slower, never incorrect output).
Undo: AKLR_MIN_SPEEDUP=1.03 restores the old dispatch bar at runtime; git revert restores the entry ratio and the 6 kernel files.

Validation admitted a kernel when one workload's clamped lower bound exceeded 1.02, while dispatch served a workload only from a stored speedup of 1.03, so a kernel could merge and never be served. Both now read DEFAULT_MIN_SPEEDUP = 1.05: AKLR_MIN_SPEEDUP defaults to it, the entry ratio is it, and a workload qualifies on the published speedup (the unclamped lower bound to 3 decimals) compared with >=, as dispatch compares it. The timing stop rule decides entry on the same bounds. The retain ratio (0.99) and the 2% rewrite tolerance are unchanged.

Tests, the forge_task fake, and the docs and skills that state the threshold follow the new value.
Each file serves one workload, and none reaches the new 1.05 bar (stored speedups 1.009 to 1.049), so validation would report no_qualifying_workload for them. Their workloads fall back to the caller's code; the other kernels of each name are kept:

- fused_moe 257 experts topk 9 inter_dim 512 (FlyDSL, 4ea93103): 1.043
- per_group_quant_mxfp8 hidden_size 384 (HIP, 84cf7a4e): 1.047
- dsa_sparse_mla_decode 64 heads (Triton, 0bb2f7cb): 1.030
- deepseek_v2_fp8_moe inter_dim 512, 32 tokens (Triton, ee90a36c): 1.025
- deepseek_v2_mxfp4_moe inter_dim 512, 256 tokens (Triton, 2422a87b): 1.009
- qwen3_next gated attention decode fp8 (Triton, 8d203e32): 1.049
Sentences that state the current rule (a Point is served from, a re-measured Point below, AKLR_MIN_SPEEDUP's default) now say 1.05. Measurements recorded against 1.03 at a stated commit or run (the >= 1.03 columns, bold marks, served counts) keep 1.03, marked as the default then where a reader could take it for the current rule.
docs/acceptance_criteria.md (and its Chinese version) states the two criteria a PR meets: each kernel file has a workload 5% faster than the baseline, checked by CI; and a new plugin route, or one that now handles more cases, is 2% faster end to end on a workload the author names, reported in the PR with this PR's ops off and on and the commands to reproduce. End-to-end data is recommended, not required, for kernels of an existing op or route and for new ops in aklr/ops/.

The PR template gains an End to end section; aklr-open-pr, aklr-review-kernel-pr, harness/gates.md, step 7 of the plugin tutorial and the README point to the criteria.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Threshold-crossing and rounding inconsistencies can leave stale speedups in schemas and cause admission, dispatch, and measurement verdicts to disagree.

2 open issues
What changed in this PR

This PR establishes a common 5% default speedup bar for AKLR kernel admission and dispatch, and formalizes the evidence expected from kernel and plugin contributions.

Changes:

  • Centralizes the 1.05 default and checks admission against the published, three-decimal speedup; updates validation and Forge fixtures.
  • Withdraws kernel files whose stored workloads are below the new bar.
  • Adds bilingual acceptance criteria, including 2% end-to-end gains for new or expanded plugin routes, and updates contributor guidance.
File Description
tests/​core/​validation/​test_pipeline.py Updates threshold and admission tests.
harness/​tests/​forge_task/​test_driver_contract.py Expects the 1.05 serving anchor.
harness/​tests/​forge_task/​fake_aklr.py Updates the fake runtime default.
harness/​skills/​aklr-review-kernel-pr/​SKILL.md Adds acceptance-evidence checks.
harness/​skills/​aklr-read-validation/​SKILL.md Updates Point-selection guidance.
harness/​skills/​aklr-read-validation/​references/​ruler.md Explains the revised speed thresholds.
harness/​skills/​aklr-read-validation/​references/​ci.md Updates the diagnostic example.
harness/​skills/​aklr-port-generated-kernels/​references/​workflow.md Raises the recommended serving bar.
harness/​skills/​aklr-open-pr/​SKILL.md Adds plugin end-to-end evidence guidance.
harness/​skills/​aklr-kb/​triton/​tuning.md Updates the default dispatch rule.
harness/​skills/​aklr-kb/​triton/​authoring.md Labels the earlier default as historical.
harness/​skills/​aklr-kb/​SKILL.md Updates the dispatch-rule summary.
harness/​skills/​aklr-kb/​moe/​INDEX.md Updates kernel-serving guidance.
harness/​skills/​aklr-kb/​cases/​mla_sparse_fp8_kv_pool.md Updates serving and rollback thresholds.
harness/​skills/​aklr-kb/​cases/​mhc_fused_post_pre.md Updates serving and rollback thresholds.
harness/​skills/​aklr-kb/​cases/​k3_bf16_splitk_wide_n.md Updates dispatch and rollback rules.
harness/​skills/​aklr-kb/​cases/​k3_bf16_splitk_narrow_n.md Updates dispatch and rollback rules.
harness/​skills/​aklr-kb/​cases/​k3_bf16_short_k_large_m.md Updates serving-threshold references.
harness/​skills/​aklr-kb/​cases/​k3_bf16_band_stream.md Updates serving-threshold references.
harness/​skills/​aklr-kb/​cases/​fused_moe_shuffled_16x16.md Updates measurement and rollback guidance.
harness/​skills/​aklr-kb/​cases/​fused_moe_interleave_swiglu.md Updates dispatch rules and citations.
harness/​skills/​aklr-kb/​cases/​fused_moe_interleave_swiglu_hidden7168.md Updates the post-measurement serving bar.
harness/​skills/​aklr-kb/​cases/​fp8_paged_mqa_logits.md Updates serving and rollback thresholds.
harness/​skills/​aklr-kb/​cases/​bf16_small_m_column_strip.md Updates the default serving bar.
harness/​skills/​aklr-kb/​cases/​bf16_large_m_whole_k_tiles.md Updates the default serving bar.
harness/​skills/​aklr-kb/​cases/​bf16_k4096_splitk_hgemm.md Separates historical and current thresholds.
harness/​skills/​aklr-kb/​cases/​bf16_glm52_wide_n.md Updates dispatch and rollback thresholds.
harness/​skills/​aklr-kb/​cases/​bf16_glm52_narrow_n.md Separates historical and current thresholds.
harness/​skills/​aklr-kb/​cases/​a8w8_small_n_large_k.md Updates serving and rollback thresholds.
harness/​skills/​aklr-kb/​cases/​a8w8_row_major_a_scale.md Updates rollback guidance.
harness/​skills/​aklr-kb/​cases/​a8w8_n4096_k_sweep.md Updates dispatch and historical-count wording.
harness/​scripts/​forge_task/​README.md Updates the dashboard serving bar.
harness/​gates.md Links review gates to acceptance criteria.
docs/​plugin_tutorial.zh.md Adds Chinese end-to-end instructions.
docs/​plugin_tutorial.md Adds end-to-end benchmarking instructions.
docs/​ops_tutorial.zh.md Updates Chinese validation and dispatch guidance.
docs/​ops_tutorial.md Updates validation and dispatch guidance.
docs/​forge_task.md Updates the campaign serving bar.
docs/​acceptance_criteria.zh.md Adds Chinese acceptance criteria.
docs/​acceptance_criteria.md Defines kernel and plugin evidence requirements.
aklr/​plugins/​sglang/​models/​qwen3_next/​impls/​triton/​qwen3_next_gated_attention_decode_group_fp8_quant_qkv_dim2560_n_kv_heads1_head_dim256/​8d203e322be9766d.json Withdraws the 1.049-speedup kernel.
aklr/​plugins/​sglang/​models/​deepseek_v2/​impls/​triton/​deepseek_v2_mxfp4_moe_shuffled_16x16_model_dim6144_n_routed256_inter_dim512/​2422a87b3b814299.json Withdraws the 1.009-speedup kernel.
aklr/​plugins/​sglang/​models/​deepseek_v2/​impls/​triton/​deepseek_v2_fp8_moe_num_expert_group1_topk_group1_shuffled_16x16_model_dim6144_n_routed256_inter_dim512/​ee90a36c8e22674f.json Withdraws the 1.025-speedup kernel.
aklr/​plugins/​sglang/​layers/​dsa_backend/​impls/​triton/​dsa_sparse_mla_decode_n_heads64_kv_dim576_topk2048/​0bb2f7cbe49d1be3.json Withdraws the 1.030-speedup kernel.
aklr/​ops/​README.md Documents the shared default speed threshold.
aklr/​ops/​quant/​impls/​hip/​per_group_quant_mxfp8_hidden_size384/​84cf7a4e7c55223d.json Withdraws the 1.047-speedup kernel.
aklr/​core/​validation/​stages/​_measure.py Uses the shared entry threshold and published bounds.
aklr/​core/​validation/​stages/​_bench/​_report.py Qualifies workloads on published speedup.
aklr/​core/​platform/​env.py Defines and uses DEFAULT_MIN_SPEEDUP.
aklr/​benchmarks/​README.md Documents revised kernel admission.
.github/​README.md Updates runtime guidance and criteria links.
.github/​pull_request_template.md Adds threshold guidance and an end-to-end section.

Review effort: Max

Comment on lines +78 to +79
speedup = self.speedup
return speedup is not None and speedup >= THRESHOLD_RATIOS["entry"]
Comment on lines +78 to +79
speedup = self.speedup
return speedup is not None and speedup >= THRESHOLD_RATIOS["entry"]
@zhenhuang12
zhenhuang12 merged commit 449734c into main Nov 12, 2026
9 checks passed
zhenhuang12 added a commit that referenced this pull request Nov 12, 2026
- refactor(core): contract removal, schema/seam cleanup and bench execution runners
- docs: add TODO.md for mega_moe and aklr/plugins
- refactor(bench): rewrite the validation bench from its requirements
- refactor(bench): replace the thread runner with disposable and reuse process runners
- refactor(bench): reorganize the bench stage by phase, with schedule passes
- refactor(bench): time each accuracy trial once, judge by the geometric mean
- feat(bench): run multi-rank ops on their ranks, with mega_moe as the first

- refactor(validation): bench inputs through WorkloadKey and InputSampler
- fix(seam): restore main's fused_moe environment, ragged MLA baseline and mega_moe check
- refactor(validation): consolidate the bench into stage, admission, task and workload_call
- refactor(validation): make the bench's execution_policy package private
- fix(ops): hold mega_moe, mhc, flash_mla and attention checks to flashinfer's test tolerances

These ops' checks were looser than the tolerances flashinfer's own tests hold the same
kernels to:

- mega_moe: SQNR >= 13 dB (relative L2 error up to 22%), against flashinfer's DeepGEMM
  fp8 x fp4 mega MoE test: relative L2 < 0.02 and every element within atol 0.15, rtol 0.05.
- mhc post_mix/comb_mix (float32): 1e-2, against 2e-3 (test_mhc_pre_big_fuse).
- flash_mla lse (float32): 1e-2, against 1e-3 (test_deepseek_mla).
- attention in float16: 1e-2, against 1e-3; bfloat16 stays at 1e-2.

mega_moe gets a check of its own; fused_moe keeps SQNR >= 13 dB, which flashinfer's MXFP4
MoE tests do not beat (92% of elements within atol 0.1, rtol 0.85). As in flashinfer's tests,
no cosine floor. The committed kernel files embed the new check source; their file names are
kept.

Not run on a GPU: which committed kernels and baselines fail the tighter checks is left to
validation.

- refactor(schema): keep the test standard in code, out of the schema json

A schema's init, reference, check and baseline become one Standard, defined with the
schema template in code (aklr/ops/<op>/schema.py) and never written to its json. A
schema read from json takes its template's standard by name; templates are declared
by aklr_api as the op apis are imported.

- Schema drops its reference/check/init fields; the 223 committed json files are
  migrated in this commit.
- Each op's baseline moves from the seam adapter to aklr/ops/<op>/baseline.py.
- The bench and tracing read the Standard; dispatch and the seam do not.

Design: docs/schema_standard_design.md. aklr/plugins is not migrated yet (see TODO.md).

Rebased onto main at 8a3ad37, folding in:

- #119: the kernel tracer registers with torch's rocprofiler-sdk as aklr.core.utils.testing is
  imported; the runners and the forge driver import it before their first kernel.
- #153: one 5% bar. AKLR_MIN_SPEEDUP and the bench's Entry default to DEFAULT_MIN_SPEEDUP (1.05),
  and a workload is admitted on its published speedup, compared with >= as dispatch compares it.
  The six kernels #153 withdrew stay withdrawn.
- #122: fused_moe gets a swiglu template (gpt-oss's, on the 16 x 16 shuffled storage, bf16
  activations below 256 rows as aiter) for its two MiniMax-M3.1 TP4 kernels, converted to the
  schema format; its gemm renames are kept on the migrated files.
- #148: AKLR_TRACE is parsed by RuntimeEnv; the vLLM hook registry and the trace module come in as
  on main and wait with aklr/plugins (TODO.md).
- #154: biased_grouped_topk moves under aklr/ops/topk (api, baseline, reference, schema and its
  committed kernels); its op_type stays biased_grouped_topk, as topk_transform_paged's is its own
  name, so its schema names and uuids are unchanged.
- 8a3ad37 (MI355X measurements): not taken; the migrated files carry no measurements.
zhenhuang12 pushed a commit that referenced this pull request Nov 14, 2026
…1, inter 512 (#209)

Qwen3.5-397B MXFP4 (shared expert fused as expert 512) at TP2 runs aiter's
fused_moe a4w4 at every verify step; [email protected] takes the call but had
no schema for this shape. This adds one, at 4-32 tokens in steps of 4,
40-80 in steps of 8, 96, 128 and 160 (4 x the CUDA-graph batch sizes).

The kernel is the two-launch fold of the 257-expert inter-512 kernel that
#153 removed (4ea93103): every stage-1 workgroup sorts the routes in LDS,
zeroes out, quantizes its gathered rows to MXFP4 and runs the gate/up GEMM;
stage 2 adds the weighted down-projection rows with bf16 atomics. The sort
now gives each thread two experts (512 + 1).

Co-authored-by: Claude Opus 5.5 <[email protected]>
zhenhuang12 pushed a commit that referenced this pull request Nov 18, 2026
* docs(kb): name the kernel files main holds now, after #168 and #220 renamed them

#168 (kernel.requires) and #220 (aiter in kernel.requires) renamed every kernel file they touched without changing
its code, so the case pages' sources: lines and their text named files main no longer has (kb_reconcile: 0 covered,
100 gone). Each gone file is replaced by the file in its directory whose kernel (entry point and sources) is
byte-identical; where #212 added a second schema of the same kernel, by the one with the same workloads. The
withdrawn 4ea93103 is left for a separate edit.

* docs(kb): mark fused_moe 4ea93103 withdrawn

#153 withdrew it (1.043 over aiter, under the 5% bar). Its sources: line goes, the Points table says so, and S8 pins
the source to the revision before #153 so the citation still resolves.

* docs(kb): GEMM: nt at K=512, bounded-wait fold, ring barrier, cached fold workspace

- small_m.md §6: E134's nt cost at K=512 holds for that forge kernel only;
  #188's direct-to-LDS B stream at the same shape pays 1.66-1.69x with nt
  (E147). The shape does not decide the policy.
- wait_free_fold.md: a waiting fold is safe with a bounded wait, hand-off on
  timeout and a per-call workspace, as #159's FOLD 4/5 (exact under
  contention, two streams and concurrent graphs). Cost and risk: a
  workspace cached per (device, stream), as in #212's Triton n32_k6144, is
  shared by every graph captured on that stream (wrong outputs).
- datapath.md §4: a ring barrier before a DMA refill must also wait
  lgkmcnt(0); #110's n4096_k8192 races under contention without it.
  correctness.md and flydsl/gemm.md point there.

* docs(kb): mHC 4096 Gram form without a clamp; aiter's stage 2 drops b_nt

- cases/mhc_fused_post_pre.md: the hidden-4096 kernel returns NaN when
  the residual streams cancel; clamp the form at 0 like the hidden-7168
  kernel.
- moe/grouped_sorted_tokens.md §4, flydsl/moe.md §4: aiter's mixed stage-2
  builder discards b_nt, so a _bnt2 row loads w2 cached; restoring it took
  #122's fused MoE from 256.8 to 217.5 us at 512 tokens.

* docs(kb): pitfalls: degenerate Points, eager host time, in-place state

- degenerate_points.md (new): Points whose inputs all take a kernel's fast
  path (#201's FlashMLA q8: every request 8 KV rows) score a speedup that
  realistic lengths reverse. attention/measurement.md §8 points there.
- eager_call_host_time.md (new): the graph-replay speedup leaves out a
  @flyc.jit launcher's per-call host time; #134's top-k is 2.8-7.1x in
  replays and 0.18-0.68x of aiter called eagerly.
- state_kept_across_calls.md: form 3, a kernel that skips unchanged state
  stores timed on state replayed in place (#75's GDN decode: 2.40x in
  place, 1.62x with fresh state). triton/gdn.md points there.

* docs(kb): mHC case: the hidden-7168 HIP file #168 renamed, and #202's FlyDSL kernel beside it

* docs(kb): evidence counts from the runs' logs; R2 at batch 4 and 8; aiter's top-k fails the reference at 16384
@xiaobochen-amd
xiaobochen-amd deleted the cursor/min-speedup-5pct-f4ec branch November 20, 2026 08:18

This branch was previously deployed

1 inactive deployment
gpu-trusted — 03a2282d Deployed Nov 12, 2026 by xiaobochen-amd via prepare-gpu / prepare #631
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants