Repository navigation
docs(kb): updating alkr knowledge base - #251
Merged
Merged
Conversation
…enamed 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.
…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.
- 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.
- 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.
… FlyDSL kernel beside it
kyle-256
requested review from
RuibinCheung,
irvineoy,
jiejingzhangamd,
xiaobochen-amd and
zhenhuang12
as code owners
November 18, 2026 01:58
kyle-256
marked this pull request as draft
November 18, 2026 01:58
…iter's top-k fails the reference at 16384
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved findings include inaccurate historical evidence references, overstated correctness and serving-failure claims, and scratch-safety guidance lacking required initialization guarantees.
7 open issues
Do not treat invalid identity input as evidence of a correctness failure · New Qualify the m=2 failure as an unserved direct-kernel probe · New Qualify the no-failure result and require safe scratch initialization · New Initialize cached scratch on every call, not only before capture · New Clarify that the slowdown is in direct calls, not serving dispatch · New Preserve historical UUIDs and annotate their current successors · New Add the renamed source’s revision without changing historical measurements · New
What changed in this PR
Updates AKLR’s kernel knowledge base with recent correctness and performance evidence. This is a documentation-only change; the kernel fixes discussed remain outside this PR.
Changes:
- Adds guidance on misleading benchmark inputs, eager-call overhead, and state replay.
- Revises synchronization, cache-policy, and mHC numerical guidance.
- Refreshes renamed kernel references and the pitfalls index.
| File | Description |
|---|---|
harness/skills/kb/triton/SKILL.md |
Refreshes a GEMM evidence identifier. |
harness/skills/kb/triton/numerics.md |
Updates the fixed-order reduction citation. |
harness/skills/kb/triton/kernels/kernel_library.md |
Refreshes GEMM source and measurement references. |
harness/skills/kb/triton/gluon/memory.md |
Updates remapping evidence identifiers. |
harness/skills/kb/triton/gdn.md |
Links state replay to benchmark interpretation. |
harness/skills/kb/triton/debugging.md |
Updates the example schema path. |
harness/skills/kb/pitfalls/state_kept_across_calls.md |
Adds stateful replay timing evidence. |
harness/skills/kb/pitfalls/INDEX.md |
Indexes new and expanded pitfalls. |
harness/skills/kb/pitfalls/eager_call_host_time.md |
Documents eager host overhead omitted by graph timing. |
harness/skills/kb/pitfalls/degenerate_points.md |
Documents fast-path bias from degenerate workloads. |
harness/skills/kb/moe/INDEX.md |
Refreshes MoE kernel identifiers. |
harness/skills/kb/moe/grouped_sorted_tokens.md |
Adds stage-2 cache-policy evidence. |
harness/skills/kb/moe/few_tokens.md |
Refreshes folded-routing kernel references. |
harness/skills/kb/gemm/wait_free_fold.md |
Expands bounded-wait and graph-workspace guidance. |
harness/skills/kb/gemm/small_m.md |
Adds kernel-specific evidence for non-temporal loads. |
harness/skills/kb/gemm/datapath.md |
Documents LDS-read completion before ring-slot reuse. |
harness/skills/kb/gemm/correctness.md |
Links ring synchronization and bounded-fold guidance. |
harness/skills/kb/flydsl/moe.md |
Explains dropped cache modifiers and builder workarounds. |
harness/skills/kb/flydsl/kernels/flydsl_kernel_library.md |
Refreshes MoE implementation references. |
harness/skills/kb/flydsl/gemm.md |
Adds the explicit LDS completion wait. |
harness/skills/kb/cases/mla_sparse_fp8_kv_pool.md |
Refreshes sparse MLA source and reproduction paths. |
harness/skills/kb/cases/mhc_fused_post_pre.md |
Adds cancellation evidence and hidden-7168 context. |
harness/skills/kb/cases/k3_bf16_splitk_wide_n.md |
Refreshes split-K kernel references. |
harness/skills/kb/cases/k3_bf16_band_stream.md |
Refreshes band-stream kernel references. |
harness/skills/kb/cases/fp8_paged_mqa_logits.md |
Updates logits kernel references. |
harness/skills/kb/cases/dsa_sparse_mla_8_heads.md |
Updates the eight-head kernel identifier. |
harness/skills/kb/cases/dsa_sparse_mla_16_heads.md |
Updates the sixteen-head kernel identifier. |
harness/skills/kb/cases/bf16_small_m_column_strip.md |
Refreshes column-strip kernel references. |
harness/skills/kb/cases/bf16_glm52_wide_n.md |
Refreshes wide-output GEMM references. |
harness/skills/kb/cases/bf16_glm52_narrow_n.md |
Refreshes narrow-output GEMM references. |
harness/skills/kb/cases/a8w8_small_n_large_k.md |
Refreshes block-scaled GEMM references. |
harness/skills/kb/cases/a8w8_row_major_a_scale.md |
Refreshes row-major scale kernel references. |
harness/skills/kb/attention/measurement.md |
Adds checks for branch coverage in benchmark inputs. |
Review effort: Max
|
|
||
| - E1 [2026-10, gfx950, FlyDSL 0.3.2, N=1, the predecessor repository's CI] speedup over aiter per Point 1.100–1.510, 13 of 13 ≥ 1.03; T 1 1.167, 2 1.185, 4 1.117, 8 1.144, 16 1.125, 32 1.132, 64 1.100, 128 1.225, 256 1.325, 512 1.393, 1024 1.423, 2048 1.397, 4096 1.510 (mhc_fused_post_pre_has_norm_weight_hidden_size4096, T 1–4096) | ||
| - E2 [2026-10, gfx950, FlyDSL 0.3.2, N=5, the predecessor repository's CI] per-Point range and served count in commit order: 1.042–1.217, 1.134–1.439, 1.095–1.504, 1.134–1.451, 1.100–1.510, 13 of 13 each time; the kernel text is the same in all five (mhc_fused_post_pre_has_norm_weight_hidden_size4096, under the file's name before the rename) | ||
| - E3 [2026-11, gfx950 (MI355X), FlyDSL 0.3.2, N=100 calls per T and input family, the shipped file and a copy with the clamp inserted before its `_rsq` on the same inputs, outputs checked for non-finite values and against the contract's reference] inputs whose four residual streams cancel exactly (`x` 0, `comb_mix` the identity, equal pre gates: the true form and `layer_input` are 0), the workloads' norm_eps 1e-6: tokens with a non-finite `layer_input` as shipped 1034 of 6400 at T 64 and 7616 of 51200 at T 512, with `ssq = max(ssq, 0)` 0; the contract's own draws at the same T: none in either build (mhc_fused_post_pre_has_norm_weight_hidden_size4096) |
| distribution (6/11 bad, against 1/15 for the clean tree), so the cause of that race is not known. | ||
| - `s_barrier` does not drain `vmcnt`; `lgkmcnt` is 4 bits (max 15), `vmcnt` 6 bits (max 63). | ||
| - **A ring barrier that lets a DMA refill a slot the waves have read must also wait `lgkmcnt(0)`**; without it a | ||
| served GEMM gave wrong output only while another process shared the GPU (`datapath.md` §4). |
Comment on lines
+178
to
+185
| waits is safe when each wait is bounded and a split that runs out hands its share on instead of writing | ||
| (`../attention/split_kv.md` §2, Bounded wait), with launch-tagged arrival words in a per-call workspace: #159's | ||
| `gemm_n3648_k7168` (`df3ce763`, FOLD 4 at m 40 and 48, FOLD 5 at m 80–240) sums each split's share once the | ||
| arrival mask is full, waits at most 2000 `s_memrealtime` ticks (20 µs), then hands its share by compare-and-swap | ||
| to the split that completes the mask, and allocates its words with `torch.empty` per call (S18). *(field, E21)* It | ||
| gave no wrong, non-finite or nondeterministic output beside a matmul process on the same GPU, on two streams, | ||
| with graph replays beside eager calls and with two graphs replayed at once; the records do not say whether any | ||
| wait ran out. The kernel is served at those Points, 1.146–1.870 over the baseline *(field, E22)*; no ablation |
Comment on lines
+223
to
+224
| ruler, against 1.33–1.95 for the shipped kernel. Not tested: carving each capture's slice from a region zeroed | ||
| once before capture, which needs no zeroing per replay because the folding split returns its counter to 0. |
Comment on lines
+18
to
+19
| A kernel passes accuracy and CI stores a speedup at each of its Points, yet on the inputs serving sends it is | ||
| several times slower than the baseline. #201's FlashMLA kernel for a bf16 KV cache, 8 query tokens and 96 heads |
| - E2 [2026-11, gfx950 (MI355X), Triton 3.8.0, N=1, `python -m aklr validate --stages audit,bench` once per schema, each with its own `TRITON_CACHE_DIR`, on 4 GPUs; the cached `.amdgcn` and `.json` read] `num_warps`, `waves_per_eu`, VGPR (`.vgpr_count`, AGPRs included), AGPR, LDS, spills, MFMA opcodes and the count of every opcode (loads, stores and atomics included, buffer loads into LDS apart) of every AKLR kernel (a `@gluon.jit` or `@triton.jit` def of the schema's sources) compiled while validating each of the 154 schemas once: 897 compiled-cache records among 1709 compiled kernels, one per compilation, not deduplicated; N 3072 fp8 GEMM LDS 9, 9, 12, 36, 48, 49 KiB at M 1, 2, 4, 8, 16, 32; `1db6`, `ae4f`, `0675` 64.0, 66.1, 72.0 KiB; E64 MiniMax MXFP4 `cb88`, `b94f`, `62df`, `f839`, `8b22`: 0 atomic instructions (global, buffer, flat, ds), popcounts (`s_bcnt`) 4, 2, 4, 8, 8; every GDN prefill file (26) holds `v_mfma_f32_16x16x32_bf16` and `v_mfma_f32_16x16x4_f32`; 45 GDN decode kernels, 0 MFMA; RMSNorm loads with the nt bit, stores sc0 sc1 only, 16 B of LDS (all 154 Triton schemas as at `43e112e`; #89) | ||
| - E3 [2026-11, gfx950 (MI355X), Triton 3.8.0, N=1, AKLR CI bench: graph replay, 1 GiB read flush, per-kernel device durations under Kineto, speedup against the schema's baseline] fp8 GEMM, stored at `43e112e`: lowest 1.114 at N 7168, M 128 (`1bbf98a368b3fcba`, CI run 41197527705 at AKLR@a29581b), highest 1.840 at N 7168, M 8 (`1e021d44010accb1`, CI run 41991630592 at AKLR@43e112e) (`aklr/ops/gemm/impls/triton/gemm_a8w8_blockwise_scaled_n7168_k2048/`) | ||
| - E4 [2026-11, gfx950 (MI355X), Triton 3.8.0, N=1, AKLR CI bench as in E3] bf16 decode GEMM, stored at `43e112e`: lowest 1.048 at N 2624, M 2 (`gemm_n2624_k6144/b88c8d5f28d86777`), highest 1.292 at N 6144, M 8 (`gemm_n6144_k2048/f806ad2b086d757d`), both CI run 41976547645 at AKLR@90b9d50 (`aklr/ops/gemm/impls/triton/`) | ||
| - E4 [2026-11, gfx950 (MI355X), Triton 3.8.0, N=1, AKLR CI bench as in E3] bf16 decode GEMM, stored at `43e112e`: lowest 1.048 at N 2624, M 2 (`gemm_n2624_k6144/7511d8bbfacd4d06`), highest 1.292 at N 6144, M 8 (`gemm_n6144_k2048/8307d207feb8e734`), both CI run 41976547645 at AKLR@90b9d50 (`aklr/ops/gemm/impls/triton/`) |
| - S56 aklr/plugins/sglang/models/qwen2_moe/impls/triton/qwen2_moe_router_model_dim4096_n_routed512_topk10/c3889614985b700a.json#kernel.py:303 routing launch with `llvm_fn_attrs=[["amdgpu-ieee", "false"], ["amdgpu-sched-strategy", "max-ilp"]]` | ||
| - S57 harness/skills/kb/hardware/gfx950/cdna4/ch12_07_vop2_instructions.md:185 V_MAX_F32: a signaling NaN is quieted only in IEEE mode; otherwise a NaN operand returns the other (:189-192); V_MIN_F32 the same (:158-165) | ||
| - S58 aklr/ops/gemm/impls/triton/gemm_n2624_k6144/b88c8d5f28d86777.json#kernel.py:12 six fp32 partials summed "in a fixed order before rounding to bf16" (:12-15); `if m <= 16:` takes the unsplit path (:100), the rest `split_k = 6` (:129); `_reduce_kernel` (:86-93) | ||
| - S58 aklr/ops/gemm/impls/triton/gemm_n2624_k6144/7511d8bbfacd4d06.json#kernel.py:12 six fp32 partials summed "in a fixed order before rounding to bf16" (:12-15); `if m <= 16:` takes the unsplit path (:100), the rest `split_k = 6` (:129); `_reduce_kernel` (:86-93) |
kyle-256
marked this pull request as ready for review
November 18, 2026 03:23
zhenhuang12
approved these changes
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Brings the KB in line with AKLR main after the last ten days of kernel PRs. Each claim was checked on an MI355X with the CI stack (aiter dbd8bf5, FlyDSL 0.3.2); the numbers and their conditions are in each page's Evidence.
gemm/small_m.md§6nton B at K=512 is not a rule: on #188's LDS-DMA kernel it pays 1.66–1.69× (E134 scoped to its own kernel)gemm/wait_free_fold.mdgemm_n32_k6144: up to 214 of 400 wrong)gemm/datapath.md§4,flydsl/gemm.mdlgkmcnt(0): #110'sgemm_n4096_k8192is wrong in 10 of 2000 calls at m=2 beside another processcases/mhc_fused_post_pre.mdmoe/grouped_sorted_tokens.md§4,flydsl/moe.mdb_nt(1.18× at n 512)pitfalls/degenerate_points.md(new)pitfalls/eager_call_host_time.md(new)pitfalls/state_kept_across_calls.md4ea93103markedThe kernel fixes for
gemm_n4096_k8192, mHC hidden 4096 and the Tritongemm_n32_k6144are not in this PR.Checked:
kb_lint0 errors;kb_index --checkclean;kb_numbers_guardshows no existing number changed; everykernel.py:<line>cited read at e193b1d.