Audit SGLang interfaces and refresh validated kernel solutions

#2
by ubospica - opened
This view is limited to 50 files because it contains too many changes. See the raw diff here.
Files changed (50) hide show
  1. README.md +18 -15
  2. blob/workloads/prefix_cached_block_causal_h32_d128/24beab98031b196a75c75450cb46208fcb182fd30a7033e98807bd3bbcfdbe9c.safetensors +0 -3
  3. blob/workloads/prefix_cached_block_causal_h32_d128/520f23a9d39a934f770e8cd0738b7c138afb297a1673242a8c7a74b240925220.safetensors +0 -3
  4. blob/workloads/prefix_cached_block_causal_h32_d128/634581f36b1de16bed0751230b45f5608b474b687879d22c8aecb083d9ef6e51.safetensors +0 -3
  5. blob/workloads/prefix_cached_block_causal_h32_d128/999a7517ad2b3237796e3467752e4a46a4860d2d7710f7994e8ccebb2694f920.safetensors +0 -3
  6. blob/workloads/prefix_cached_block_causal_h32_d128/a8b23c1dff21615d068e1505a14d17d38abb297be8fbf2c9155288b08b11aa06.safetensors +0 -3
  7. blob/workloads/prefix_cached_block_causal_h32_d128/b11ce9761bedd8e9e8a13b99754b6773f7bbe82882a27d474519c32b253afb60.safetensors +0 -3
  8. blob/workloads/prefix_cached_block_causal_h32_d128/d0bb365b82b6c21ea904fc9846b2f05d643af7ff2cfa2cf3970394fdf751be05.safetensors +0 -3
  9. blob/workloads/prefix_cached_block_causal_h32_d128/f98afd86600ad282fb4a1694aa5049808185ac822bdc6f330eab95be46d92bea.safetensors +0 -3
  10. blob/workloads/prefix_cached_block_causal_h32_d128_prefix0/607c76ea2c419ada0a021bacec4bac55dd9917cd9470a4005c461b2820a4c668.safetensors +0 -3
  11. blob/workloads/prefix_cached_block_causal_h32_d128_prefix0/73eb58664f39fa614a66165a80639e5ec0d06c90738d6101c6eebf185b9c68d6.safetensors +0 -3
  12. blob/workloads/prefix_cached_block_causal_h32_d128_prefix0/ac0de5352c580d07d8610324784802a5251137eca7461cad96656e36c7f1e883.safetensors +0 -3
  13. blob/workloads/prefix_cached_block_causal_h32_d128_prefix0/f3c2e24c613a2705414da699d8160e74518c9364384391094e3a8d7a1944fec6.safetensors +0 -3
  14. blob/workloads/prefix_cached_block_causal_h32_d128_prefix0/f7d9a8bf454a6461eec5eccd97dbdcd326027a6e6bfd2ab34d093c8e184b7a7d.safetensors +0 -3
  15. captures.jsonl +0 -0
  16. definitions/block_causal_attention/prefix_cached_block_causal_h32_d128.json +12 -37
  17. definitions/block_causal_attention/prefix_cached_block_causal_h32_d128_prefix0.json +4 -44
  18. definitions/dense_attention/noncausal_dense_attention_h32_d128.json +2 -7
  19. definitions/dense_attention/noncausal_dense_attention_h32_d64.json +2 -7
  20. docs/gdn-prefill-numerics.md +25 -2
  21. docs/interface-audit/README.md +196 -0
  22. docs/interface-audit/interfaces.json +345 -0
  23. docs/interface-audit/performance.md +17 -0
  24. docs/interface-audit/preferred-solutions.json +132 -0
  25. docs/interface-audit/qsa-tie-edge-cases.json +42 -0
  26. docs/interface-audit/results.jsonl +0 -0
  27. docs/interface-audit/sglang-head-recheck-diff.json +21 -0
  28. docs/interface-audit/summary.json +493 -0
  29. docs/interface-audit/upstream-head-recheck.json +41 -0
  30. docs/interface-audit/upstreams.json +112 -0
  31. scripts/audit_solutions.py +395 -0
  32. scripts/benchmark_solutions.py +8 -26
  33. scripts/capture_inputs.py +15 -9
  34. scripts/capture_ltx.py +1 -1
  35. scripts/task_acceptance.py +41 -0
  36. solutions/block_causal_attention/fa4_prefix0_h32_d128.json +21 -2
  37. solutions/block_causal_attention/fa4_prefix_h32_d128.json +22 -3
  38. solutions/block_causal_attention/sglang_prefix_cached_block_causal_h32_d128.json +1 -1
  39. solutions/block_causal_attention/sglang_prefix_cached_block_causal_h32_d128_prefix0.json +1 -1
  40. solutions/dense_attention/fa4_noncausal_h32_d128.json +4 -3
  41. solutions/dense_attention/fa4_noncausal_h32_d64.json +5 -4
  42. solutions/dense_attention/sglang_noncausal_dense_attention_h32_d128.json +1 -1
  43. solutions/dense_attention/sglang_noncausal_dense_attention_h32_d64.json +1 -1
  44. solutions/gdn/flashinfer_gdn_decode.json +26 -0
  45. solutions/gdn/flashinfer_gdn_prefill.json +26 -0
  46. solutions/gdn/flashinfer_wrapper_123ca6.json +0 -0
  47. solutions/gdn/flashinfer_wrapper_9b7f1e.json +0 -25
  48. solutions/gemm/deepgemm_bf16_n12288_k4096.json +20 -3
  49. solutions/gemm/deepgemm_bf16_n4096_k12288.json +19 -2
  50. solutions/gemm/hybrid_bf16_n4096_k4096.json +20 -3
README.md CHANGED
@@ -13,9 +13,9 @@ tags:
13
 
14
  Every published tensor input references a complete `safetensors` snapshot. Python scalar arguments use scalar descriptors. There are no random-input descriptors or synthetic activation generators. `captures.jsonl` joins each workload UUID to its model revision, request, engine operation, input adaptations, actual outputs, and validation results.
15
 
16
- **1,104 real workloads cover all 21 definitions:** 133 Qwen Image, 384 Qwen Flash-Next, 226 DeepSeek, 207 LTX, and 154 Qwen3-Next from the MLSys 2026 contest. The 950 SGLang captures pass complete-output replay; the contest publishes no engine outputs, so its workloads are checked by running the reference. The complete dataset is published at [humanfia-lab/inference-kernels](https://huggingface.co/datasets/humanfia-lab/inference-kernels), including definitions, workloads, capture records, baseline solutions, and tensors. The 5,506 tensor paths contain 5,124 unique snapshots of inputs, complete engine outputs, and auxiliary capture tensors. Fetch them with Git LFS before running workloads.
17
 
18
- The dataset was regenerated from full pinned checkpoints through SGLang on NVIDIA B300 GPUs. Definitions, reference code, tolerances, and baseline solutions are unchanged, apart from the [curation](#curation) for kernels that real inference uses.
19
 
20
  ## Kernels
21
 
@@ -39,7 +39,7 @@ BF16, FP16, FP32, and FP64 mean 16-bit Brain Floating Point, IEEE half precision
39
 
40
  Definitions describe complete logical operators. Captures preserve all model heads and experts; distributed shards must be gathered before publication. Backend padding, layout changes, and page remapping are recorded explicitly. Cache snapshots retain every referenced page, including its unused tail; unreachable allocator pages are omitted. Tensor strides are normalized to contiguous storage without changing values.
41
 
42
- The gated delta definitions are the MLSys 2026 contest's: Q/K/V with the gate inputs `A_log`, `a`, `dt_bias` and `b`, and the k-last state layout `[sequence, value head, value dimension, key dimension]`. Prefill takes variable-length sequences through `cu_seqlens`. These are unchanged Qwen3-Next TP=4 contest contracts, not a layout conversion of the removed Qwen Flash-Next captures. Their references do not perform Q/K L2 normalization, and they accept per-batch states rather than the original SGLang state pool and slot indices.
43
 
44
  Quantized byte carriers use `int8` because the trace schema lacks unsigned-byte and exponent-only scale types. The byte patterns remain unchanged. Grouped matrix multiplication uses logical scale layouts with one scale per 32 K elements. Mixed attention preserves the engine's physical pages: each page stores all payload rows followed by all scale rows. Both cache formats share the softmax denominator, including the zero-value attention sink.
45
 
@@ -100,21 +100,22 @@ Each is submitted with 1, 2, and 4 requested outputs, at 24 frames per second. M
100
 
101
  `solutions/` contains native FlashInfer Trace Solution JSON files, with embedded source code, entry points, and pinned dependencies. Each solution accepts the definition's complete inputs and returns its complete outputs. GPU layout conversions, padding, sparse gathers, and output reordering are included in the solution call.
102
 
103
- The existing baseline implementations and B200 measurements come from the original 768-workload dataset. They are retained unchanged. The regenerated dataset's SGLang captures have passed complete engine-output replay against the independent references; baseline solutions have not been rebenchmarked on this new dataset.
104
 
105
  | Kernels | Open-source implementation |
106
  |---|---|
107
- | Dense and grouped matrix multiplication | [DeepGEMM](https://github.com/deepseek-ai/DeepGEMM/tree/1fc9c66975ee322d628b3288534ca0e9ce12a64d); selected small dense shapes use [FlashInfer](https://github.com/flashinfer-ai/flashinfer) 0.7.2 CuTe DSL |
108
  | Sparse MLA prefill and mixed-format MLA decode | [FlashMLA](https://github.com/deepseek-ai/FlashMLA/tree/0f11e178da1f67becb087a324b400854931ec3e3) |
109
- | Dense, block-causal, and sparse grouped-query attention | [FlashAttention-4](https://github.com/Dao-AILab/flash-attention) 4.0.0b35, with runtime masks or sparse-input adapters |
110
- | Gated delta recurrence | The MLSys 2026 contest's FlashInfer prefill and decode wrappers, unchanged |
111
- | Sparse index scoring and selection | SGLang TileLang scoring, exact-threshold Top-512, and Triton compaction that preserves lower-ID ties |
112
- | Expert router | FlashInfer CUTLASS FP32-output projection and compiled PyTorch scoring/selection |
 
113
  | Three-dimensional neighborhood attention | [NATTEN](https://github.com/SHI-Labs/NATTEN/tree/39375ea1d2f3b1bb284315fa5f79f6ecbebb6382) 0.21.7 Blackwell fused neighborhood attention |
114
 
115
- Local B200 comparisons covered 45 dense GEMM shapes across 147 backend/shape pairs, nine grouped GEMM shapes with five implementations/configurations each, and all 19 sparse-index workloads. Dense dispatch selects the fastest tested backend per captured shape; DeepGEMM won all nine grouped comparisons. The index adapter was 1.21–2.58× faster than full stable sorting while returning exactly the same IDs. These measurements describe the tested B200 configurations.
116
 
117
- The audio-attention solution uses FP16 computation and converts the output back to BF16 to reduce attention-probability rounding error. In the original B200 validation, all 96 audio workloads passed the unchanged reference tolerances, and their inputs remained finite after conversion with maximum conversion error below `3e-8`. These measurements refer to the original tensors.
118
 
119
  Install the dependencies listed in each solution's `spec` before running it. The historical B200 baseline environment used PyTorch 2.11.0, CUDA 13.2, Triton 3.6.0, CUTLASS DSL 4.7.1, Quack 0.6.5, TileLang 0.1.15, and TVM FFI 0.1.12. NATTEN and FlashMLA were built from their pinned sources for Blackwell. FlashMLA's CUDA 13.2 build required its upstream `FLASH_MLA_SKIP_REG_SPILL_CHECK=1` option; timings include that build.
120
 
@@ -128,13 +129,15 @@ The runner uses the native Trace builder, validates every output element against
128
 
129
  ### SGLang baselines
130
 
131
- Each SGLang-captured definition also has `solutions/<family>/sglang_<definition>.json`: SGLang's own implementation at the capture commit `684fea8a`, called the way the engine calls it, so that a kernel can be timed against what serving actually runs. The module docstring cites the engine call path. Run these solutions inside the capture image `lmsysorg/sglang@sha256:ddae0e399d3d94f7827f16183301cf8dac4cf0eae0ef25590b7dac5881d713d8`. Each module also exposes `prepare(*inputs)`, which does the host-side setup the engine does once (layouts, block masks, workspaces) and returns a zero-argument `launch`; `run(*inputs)` does both.
132
 
133
  The SGLang solutions adapt the dataset's independent operator interfaces to the pinned engine implementations. Those adapters include padding, layouts, per-rank calls, metadata and output ordering where needed; their module docstrings describe the boundary. A passing standalone workload does not establish that a candidate can replace an engine call without integration work.
134
 
 
 
135
  ### Task acceptance configs
136
 
137
- `tasks/<definition>.json` is how KDA (Kernel Design Agents) judges a candidate kernel on that definition. The definition's reference is the truth. SGLang tasks time their engine baseline with only `launch` timed; imported GDN tasks time the complete packaged contest baseline call. The fields are:
138
  - `tolerance`: `atol` and `rtol` apply per element. A non-null `required_matched_ratio` is the fraction of elements that must pass; the LTX dense attention uses 0.9999 because fused attention kernels round the probabilities to BF16 and miss the every-element bound on 1–3 of up to 10⁹ elements.
139
  - `dev`: UUIDs selecting at most ten existing workloads for quick iteration. These UUIDs resolve in the listed workload files; they are not additional workloads. Final judgments use every workload, not just this subset.
140
  - `tolerance.comparison`: absent means `abs_error <= atol + rtol * abs(reference)`. The GDN configs explicitly use `absolute_or_relative`, matching the pinned FlashInfer-Bench evaluator: `abs_error <= atol` or `abs_error / (abs(reference) + 1e-8) <= rtol`. Nonfinite values fail.
@@ -147,7 +150,7 @@ A task config selects the definition, workload files, timed baseline and accepta
147
  This revision curates inference operator tasks for KDA (Kernel Design Agents). Per-shape definitions, workload files and solution names stay separate; model dimensions remain constant axes. Captured interface adaptations are retained explicitly.
148
  - **Removed `dense_gemm_bf16_nt_n64_k4096` and `dense_gemm_bf16_nt_n4096_k64`.** These are the image output and input projections: memory-bound 8–45 µs GEMMs that run once per forward.
149
  - **Removed `grouped_gemm_fp8_fp4_e384_n2304_k5120_g32`.** It was cut from the columns of the concatenated gate/up GEMM; no engine runs a separate gate or up GEMM.
150
- - **Replaced the gated delta definitions.** `gated_delta_rule_prefill_h48_dk128_dv128` pre-repeated 16 Q/K heads to 48; the old decode kept 16 raw Q/K heads and included normalization and gating. Both captures extracted states from the engine pool and transposed them to `[B, H, K, V]`. They are replaced by the [MLSys 2026 FlashInfer contest](https://huggingface.co/datasets/flashinfer-ai/mlsys26-contest/tree/5e832ce88dd1013032b22a0e942979d7d2769cc3) definitions `gdn_{decode,prefill}_qk4_v8_d128_k_last`, with their workloads and FlashInfer baselines unchanged. Each input tensor is stored in its own content-addressed file. Each receipt records the source workload, plus a check that the reference returns finite outputs of the declared shapes.
151
  - **The three remaining dense GEMMs keep only their `M >= 4096` rows.** The `M <= 32` rows were 11–27 µs launches.
152
  - **The LTX dense attention definitions drop the dense `[B, H, Nq, Nk]` visibility mask.** It was all True on every captured call (up to 839 MB). On one GPU the engine passes no mask, or an all-visible prompt mask. Replay against the captured engine outputs still passes.
153
  - **Receipts and tensors.** The receipts of removed workloads are dropped, along with every tensor that nothing references.
@@ -232,7 +235,7 @@ BF16 comparisons use `rtol=0.016, atol=0.005`; FP32 uses `rtol=1e-4, atol=2e-5`;
232
 
233
  One complete router workload is excluded from the 279 DeepSeek raw captures: at two rows of a 4,096-row call, FP32 ranking ties produce different expert selections. The original FP32 reference and exact selected-set requirement remain unchanged. This call was also absent from the original dataset. No rows are removed from published tensors. All nine LTX requests pass and are included.
234
 
235
- Tensor files are published directly as `blob/workloads/<definition>/<hash>.safetensors` through Git LFS. Every workload and capture record references tensors under its definition directory. Shared snapshots have identical LFS objects across directories: 5,506 paths contain 5,124 unique snapshots totaling 146.34 GB (146.44 GB when materialized at every path).
236
 
237
  ```bash
238
  git clone https://huggingface.co/datasets/humanfia-lab/inference-kernels
 
13
 
14
  Every published tensor input references a complete `safetensors` snapshot. Python scalar arguments use scalar descriptors. There are no random-input descriptors or synthetic activation generators. `captures.jsonl` joins each workload UUID to its model revision, request, engine operation, input adaptations, actual outputs, and validation results.
15
 
16
+ **1,104 real workloads cover all 21 definitions:** 133 Qwen Image, 384 Qwen Flash-Next, 226 DeepSeek, 207 LTX, and 154 Qwen3-Next from the MLSys 2026 contest. The 950 SGLang captures pass complete-output replay; the contest publishes no engine outputs, so its workloads are checked by running the reference. The complete dataset is published at [humanfia-lab/inference-kernels](https://huggingface.co/datasets/humanfia-lab/inference-kernels), including definitions, workloads, capture records, baseline solutions, and tensors. The 5,493 tensor paths contain 5,111 unique snapshots of inputs, complete engine outputs, and auxiliary capture tensors. Fetch them with Git LFS before running workloads.
17
 
18
+ The dataset was regenerated from full pinned checkpoints through SGLang on NVIDIA B300 GPUs. The [interface and implementation audit](docs/interface-audit/README.md) records all 21 call boundaries, the feasible interface simplifications, current implementation updates, validation evidence and remaining integration work. This audit does not change task tolerances, dev UUIDs or input tensor values.
19
 
20
  ## Kernels
21
 
 
39
 
40
  Definitions describe complete logical operators. Captures preserve all model heads and experts; distributed shards must be gathered before publication. Backend padding, layout changes, and page remapping are recorded explicitly. Cache snapshots retain every referenced page, including its unused tail; unreachable allocator pages are omitted. Tensor strides are normalized to contiguous storage without changing values.
41
 
42
+ The gated delta definitions are the MLSys 2026 contest's: Q/K/V with the gate inputs `A_log`, `a`, `dt_bias` and `b`, and the k-last state layout `[sequence, value head, value dimension, key dimension]`. Prefill takes variable-length sequences through `cu_seqlens`. These are unchanged Qwen3-Next TP=4 contest contracts, not a layout conversion of the removed Qwen Flash-Next captures. Their references do not perform Q/K L2 normalization. Decode accepts per-batch states rather than the mutable SGLang state pool and slot indices. The actual SGLang FlashInfer prefill leaf already accepts gathered per-batch states, but uses normalized Q/K, precomputed gates, preallocated outputs and optional checkpoints. See the [per-definition audit](docs/interface-audit/interfaces.json).
43
 
44
  Quantized byte carriers use `int8` because the trace schema lacks unsigned-byte and exponent-only scale types. The byte patterns remain unchanged. Grouped matrix multiplication uses logical scale layouts with one scale per 32 K elements. Mixed attention preserves the engine's physical pages: each page stores all payload rows followed by all scale rows. Both cache formats share the softmax denominator, including the zero-value attention sink.
45
 
 
100
 
101
  `solutions/` contains native FlashInfer Trace Solution JSON files, with embedded source code, entry points, and pinned dependencies. Each solution accepts the definition's complete inputs and returns its complete outputs. GPU layout conversions, padding, sparse gathers, and output reordering are included in the solution call.
102
 
103
+ Historical B200 measurements below describe the original 768-workload dataset. Current B300 validation and comparisons are reported separately in the [audit](docs/interface-audit/README.md). Version currency alone does not establish a fastest implementation, and a standalone pass does not prove direct engine integration.
104
 
105
  | Kernels | Open-source implementation |
106
  |---|---|
107
+ | Dense and grouped matrix multiplication | [DeepGEMM](https://github.com/deepseek-ai/DeepGEMM/tree/1fc9c66975ee322d628b3288534ca0e9ce12a64d); native PyTorch linear is selected on three measured large-M B300 shapes |
108
  | Sparse MLA prefill and mixed-format MLA decode | [FlashMLA](https://github.com/deepseek-ai/FlashMLA/tree/0f11e178da1f67becb087a324b400854931ec3e3) |
109
+ | Dense and block-causal attention | [FlashAttention-4](https://github.com/Dao-AILab/flash-attention) 4.0.0b35; tiny audio self-attention uses native SDPA |
110
+ | Sparse grouped-query attention | Current SGLang/FlashInfer TRT-LLM paged attention, plus the FA4 sparse-gather alternative |
111
+ | Gated delta recurrence | Maintained FlashInfer prefill/decode APIs; the contest recurrence, normalization boundary and state output contract remain explicit |
112
+ | Sparse index scoring and selection | Maintained SGLang TileLang scoring, exact-threshold Top-512, stable Triton compaction, and a score-free short-context path |
113
+ | Expert router | SGLang FP32-output projection and fused modality-aware Top-6 gate, with a combined Triton output ordering kernel |
114
  | Three-dimensional neighborhood attention | [NATTEN](https://github.com/SHI-Labs/NATTEN/tree/39375ea1d2f3b1bb284315fa5f79f6ecbebb6382) 0.21.7 Blackwell fused neighborhood attention |
115
 
116
+ Historical B200 comparisons covered 45 dense GEMM shapes across 147 backend/shape pairs, nine grouped GEMM shapes with five implementations/configurations each, and all 19 sparse-index workloads. Dense dispatch selects the fastest tested backend per captured shape; DeepGEMM won all nine grouped comparisons. The index adapter was 1.21–2.58× faster than full stable sorting while returning exactly the same IDs. These measurements describe the tested B200 configurations.
117
 
118
+ The current audio-attention solution uses BF16 FA4 directly, with native SDPA for self-attention tiles of at most 64 tokens. Both alternatives pass all 108 current audio workloads under the existing `required_matched_ratio=0.9999` policy. The former FP16 input/output conversions are removed; no tolerance was relaxed. Historical all-element B200 validation used different input tensors and the former FP16 computation.
119
 
120
  Install the dependencies listed in each solution's `spec` before running it. The historical B200 baseline environment used PyTorch 2.11.0, CUDA 13.2, Triton 3.6.0, CUTLASS DSL 4.7.1, Quack 0.6.5, TileLang 0.1.15, and TVM FFI 0.1.12. NATTEN and FlashMLA were built from their pinned sources for Blackwell. FlashMLA's CUDA 13.2 build required its upstream `FLASH_MLA_SKIP_REG_SPILL_CHECK=1` option; timings include that build.
121
 
 
129
 
130
  ### SGLang baselines
131
 
132
+ Each SGLang-captured definition also has `solutions/<family>/sglang_<definition>.json`: the capture-commit SGLang implementation behind an explicit dataset-to-engine adapter. These provide a serving implementation comparison, not a declaration that the dataset already has every native interface. The module docstring cites the engine call path. Run these solutions inside the capture image `lmsysorg/sglang@sha256:ddae0e399d3d94f7827f16183301cf8dac4cf0eae0ef25590b7dac5881d713d8`. Each module also exposes `prepare(*inputs)`, which does the host-side setup the engine does once (layouts, block masks, workspaces) and returns a zero-argument `launch`; `run(*inputs)` does both.
133
 
134
  The SGLang solutions adapt the dataset's independent operator interfaces to the pinned engine implementations. Those adapters include padding, layouts, per-rank calls, metadata and output ordering where needed; their module docstrings describe the boundary. A passing standalone workload does not establish that a candidate can replace an engine call without integration work.
135
 
136
+ The [audit runner](scripts/audit_solutions.py) can validate the complete packaged call, check byte-level input immutability, and compare eager and prepared-launch CUDA Graph timing under the task's exact tolerance. `scripts/benchmark_solutions.py` also reads `tasks/` for acceptance instead of applying a generic FP32 fallback.
137
+
138
  ### Task acceptance configs
139
 
140
+ `tasks/<definition>.json` is how KDA (Kernel Design Agents) judges a candidate kernel on that definition. The definition's reference is the truth. SGLang tasks time their engine baseline with only `launch` timed; imported GDN tasks time the complete maintained FlashInfer baseline call. The fields are:
141
  - `tolerance`: `atol` and `rtol` apply per element. A non-null `required_matched_ratio` is the fraction of elements that must pass; the LTX dense attention uses 0.9999 because fused attention kernels round the probabilities to BF16 and miss the every-element bound on 1–3 of up to 10⁹ elements.
142
  - `dev`: UUIDs selecting at most ten existing workloads for quick iteration. These UUIDs resolve in the listed workload files; they are not additional workloads. Final judgments use every workload, not just this subset.
143
  - `tolerance.comparison`: absent means `abs_error <= atol + rtol * abs(reference)`. The GDN configs explicitly use `absolute_or_relative`, matching the pinned FlashInfer-Bench evaluator: `abs_error <= atol` or `abs_error / (abs(reference) + 1e-8) <= rtol`. Nonfinite values fail.
 
150
  This revision curates inference operator tasks for KDA (Kernel Design Agents). Per-shape definitions, workload files and solution names stay separate; model dimensions remain constant axes. Captured interface adaptations are retained explicitly.
151
  - **Removed `dense_gemm_bf16_nt_n64_k4096` and `dense_gemm_bf16_nt_n4096_k64`.** These are the image output and input projections: memory-bound 8–45 µs GEMMs that run once per forward.
152
  - **Removed `grouped_gemm_fp8_fp4_e384_n2304_k5120_g32`.** It was cut from the columns of the concatenated gate/up GEMM; no engine runs a separate gate or up GEMM.
153
+ - **Replaced the gated delta definitions.** `gated_delta_rule_prefill_h48_dk128_dv128` pre-repeated 16 Q/K heads to 48; the old decode kept 16 raw Q/K heads and included normalization and gating. Both captures extracted states from the engine pool and transposed them to `[B, H, K, V]`. They are replaced by the [MLSys 2026 FlashInfer contest](https://huggingface.co/datasets/flashinfer-ai/mlsys26-contest/tree/5e832ce88dd1013032b22a0e942979d7d2769cc3) definitions `gdn_{decode,prefill}_qk4_v8_d128_k_last`, with their workloads and independent references preserved. The audit subsequently replaces the legacy vendored wrappers with maintained FlashInfer API calls. Each input tensor is stored in its own content-addressed file. Each receipt records the source workload, plus a check that the reference returns finite outputs of the declared shapes.
154
  - **The three remaining dense GEMMs keep only their `M >= 4096` rows.** The `M <= 32` rows were 11–27 µs launches.
155
  - **The LTX dense attention definitions drop the dense `[B, H, Nq, Nk]` visibility mask.** It was all True on every captured call (up to 839 MB). On one GPU the engine passes no mask, or an all-visible prompt mask. Replay against the captured engine outputs still passes.
156
  - **Receipts and tensors.** The receipts of removed workloads are dropped, along with every tensor that nothing references.
 
235
 
236
  One complete router workload is excluded from the 279 DeepSeek raw captures: at two rows of a 4,096-row call, FP32 ranking ties produce different expert selections. The original FP32 reference and exact selected-set requirement remain unchanged. This call was also absent from the original dataset. No rows are removed from published tensors. All nine LTX requests pass and are included.
237
 
238
+ Tensor files are published directly as `blob/workloads/<definition>/<hash>.safetensors` through Git LFS. Every workload and capture record references tensors under its definition directory. Shared snapshots have identical LFS objects across directories: 5,493 paths contain 5,111 unique snapshots totaling 146.34 GB (146.44 GB when materialized at every path).
239
 
240
  ```bash
241
  git clone https://huggingface.co/datasets/humanfia-lab/inference-kernels
blob/workloads/prefix_cached_block_causal_h32_d128/24beab98031b196a75c75450cb46208fcb182fd30a7033e98807bd3bbcfdbe9c.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9dc54d679a03210068bf873cc41dbdd118c9072c8b98d80c4aa82a5400797496
3
- size 16564
 
 
 
 
blob/workloads/prefix_cached_block_causal_h32_d128/520f23a9d39a934f770e8cd0738b7c138afb297a1673242a8c7a74b240925220.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:b179f21a2df8d3efa310357baf635a1b4019c79a576a2a567a030656da266106
3
- size 4201
 
 
 
 
blob/workloads/prefix_cached_block_causal_h32_d128/634581f36b1de16bed0751230b45f5608b474b687879d22c8aecb083d9ef6e51.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:0ee3434d35bc583597d0cb8d9ee4522bad4ffc5244ad34f5343332f5c4024173
3
- size 8301
 
 
 
 
blob/workloads/prefix_cached_block_causal_h32_d128/999a7517ad2b3237796e3467752e4a46a4860d2d7710f7994e8ccebb2694f920.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:4d3d1704df157ad89beb91feebb4c35c8c4c84b73b459e8e6c18193c75637722
3
- size 32964
 
 
 
 
blob/workloads/prefix_cached_block_causal_h32_d128/a8b23c1dff21615d068e1505a14d17d38abb297be8fbf2c9155288b08b11aa06.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5b204a1b9d61966e711684924afc1d3bdd4fc158529c3436c1aeead2b645e320
3
- size 6254
 
 
 
 
blob/workloads/prefix_cached_block_causal_h32_d128/b11ce9761bedd8e9e8a13b99754b6773f7bbe82882a27d474519c32b253afb60.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:07de2595b4db5c4cf99fb0b334fa3d185241af7d12f092e1b7eebe2759d64c7d
3
- size 24776
 
 
 
 
blob/workloads/prefix_cached_block_causal_h32_d128/d0bb365b82b6c21ea904fc9846b2f05d643af7ff2cfa2cf3970394fdf751be05.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:73838b70d506019c83a0fbba52a3a42de97a12278b52cb142e10cb499adcb402
3
- size 4208
 
 
 
 
blob/workloads/prefix_cached_block_causal_h32_d128/f98afd86600ad282fb4a1694aa5049808185ac822bdc6f330eab95be46d92bea.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:38a5217b228357f983ee83bb73bc31d4d017b6d99d18530ba7a5e9fb7a8592e0
3
- size 16592
 
 
 
 
blob/workloads/prefix_cached_block_causal_h32_d128_prefix0/607c76ea2c419ada0a021bacec4bac55dd9917cd9470a4005c461b2820a4c668.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:1d260ae51283fece71010a7d5ad6bb3c6c85fe4b6d531bf0a4d3c4dd75d0129d
3
- size 80
 
 
 
 
blob/workloads/prefix_cached_block_causal_h32_d128_prefix0/73eb58664f39fa614a66165a80639e5ec0d06c90738d6101c6eebf185b9c68d6.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:cf9f5bb5735a2adced8cb3ff460f768d24713fab5168b10e347e7c4acdf960ee
3
- size 4205
 
 
 
 
blob/workloads/prefix_cached_block_causal_h32_d128_prefix0/ac0de5352c580d07d8610324784802a5251137eca7461cad96656e36c7f1e883.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:3733af1da5d567aa09b7c304f9e79f1f408b83e0f1a852602773a4066e37e3b9
3
- size 104
 
 
 
 
blob/workloads/prefix_cached_block_causal_h32_d128_prefix0/f3c2e24c613a2705414da699d8160e74518c9364384391094e3a8d7a1944fec6.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:35d109d5b313aec365c9b681cb80c4c32f442d03e3ed426101b2aa4524befe48
3
- size 102
 
 
 
 
blob/workloads/prefix_cached_block_causal_h32_d128_prefix0/f7d9a8bf454a6461eec5eccd97dbdcd326027a6e6bfd2ab34d093c8e184b7a7d.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:ad2b659e721e3f5425248fa6eeed957c412e070d7ccc36d3ca6051c2dd3a57b0
3
- size 97
 
 
 
 
captures.jsonl CHANGED
The diff for this file is too large to render. See raw diff
 
definitions/block_causal_attention/prefix_cached_block_causal_h32_d128.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "prefix_cached_block_causal_h32_d128",
3
  "op_type": "block_causal_attention",
4
- "description": "Prefix-cached block-causal attention: allow j <= Np+i or matching nonnegative image IDs, then intersect key_valid. Text and different image blocks are causal; same-image tokens are bidirectional. Np=0 covers initial full evaluation. Prefix K/V are already computed; changed target-image K/V must be supplied as current inputs.",
5
  "tags": [
6
  "model:qwen-image-2.1-turbo",
7
  "status:draft",
@@ -18,11 +18,7 @@
18
  },
19
  "Np": {
20
  "type": "var",
21
- "description": "Runtime cached prefix length, possibly zero."
22
- },
23
- "Nall": {
24
- "type": "var",
25
- "description": "Total prefix and current length."
26
  },
27
  "H": {
28
  "type": "const",
@@ -43,61 +39,41 @@
43
  ],
44
  "dtype": "bfloat16"
45
  },
46
- "K_current": {
47
  "shape": [
48
  "B",
49
- "Nq",
50
  "H",
51
  "D"
52
  ],
53
  "dtype": "bfloat16"
54
  },
55
- "V_current": {
56
  "shape": [
57
  "B",
58
- "Nq",
59
  "H",
60
  "D"
61
  ],
62
  "dtype": "bfloat16"
63
  },
64
- "K_prefix": {
65
  "shape": [
66
  "B",
67
- "Np",
68
  "H",
69
  "D"
70
  ],
71
  "dtype": "bfloat16"
72
  },
73
- "V_prefix": {
74
  "shape": [
75
  "B",
76
- "Np",
77
  "H",
78
  "D"
79
  ],
80
  "dtype": "bfloat16"
81
- },
82
- "image_ids": {
83
- "shape": [
84
- "Nall"
85
- ],
86
- "dtype": "int32",
87
- "description": "Text=-1; nonnegative IDs identify distinct contiguous image blocks. Shared batch layout."
88
- },
89
- "key_valid": {
90
- "shape": [
91
- "B",
92
- "Nall"
93
- ],
94
- "dtype": "bool",
95
- "description": "Key padding visibility mask; each query must see a key."
96
- },
97
- "sm_scale": {
98
- "shape": null,
99
- "dtype": "float32",
100
- "description": "Model default 1/sqrt(128)."
101
  }
102
  },
103
  "outputs": {
@@ -114,8 +90,7 @@
114
  "constraints": [
115
  "B >= 1",
116
  "Nq >= 1",
117
- "Np >= 0",
118
- "Nall == Np + Nq"
119
  ],
120
- "reference": "import math\nimport torch\n\n@torch.no_grad()\ndef run(Q, K_current, V_current, K_prefix, V_prefix, image_ids, key_valid, sm_scale):\n \"\"\"Causal across blocks/text, bidirectional within each nonnegative image ID.\"\"\"\n nprefix, nquery = K_prefix.shape[1], Q.shape[1]\n keys = torch.cat((K_prefix, K_current), dim=1).float()\n values = torch.cat((V_prefix, V_current), dim=1).float()\n positions = torch.arange(keys.shape[1], device=Q.device)\n query_positions = positions[nprefix:]\n query_images = image_ids[nprefix:]\n same_image = (query_images[:, None] == image_ids[None, :]) & (query_images[:, None] >= 0)\n allowed = (positions[None, :] <= query_positions[:, None]) | same_image\n allowed = allowed[None, :, :] & key_valid[:, None, :]\n assert bool(allowed.any(dim=-1).all()), \"Each query needs a visible key\"\n scores = torch.einsum(\"bqhd,bkhd->bhqk\", Q.float(), keys) * float(sm_scale)\n scores = scores.masked_fill(~allowed[:, None], -torch.inf)\n return torch.einsum(\"bhqk,bkhd->bqhd\", scores.softmax(-1), values).to(torch.bfloat16)\n"
121
  }
 
1
  {
2
  "name": "prefix_cached_block_causal_h32_d128",
3
  "op_type": "block_causal_attention",
4
+ "description": "SGLang Qwen-Image target-image attention with a nonempty replicated KV prefix. All current queries belong to one image block and attend to every prefix/current key. Q/K/V keep the engine layout; scale is fixed to 1/sqrt(128).",
5
  "tags": [
6
  "model:qwen-image-2.1-turbo",
7
  "status:draft",
 
18
  },
19
  "Np": {
20
  "type": "var",
21
+ "description": "Runtime nonempty cached prefix length."
 
 
 
 
22
  },
23
  "H": {
24
  "type": "const",
 
39
  ],
40
  "dtype": "bfloat16"
41
  },
42
+ "K_prefix": {
43
  "shape": [
44
  "B",
45
+ "Np",
46
  "H",
47
  "D"
48
  ],
49
  "dtype": "bfloat16"
50
  },
51
+ "V_prefix": {
52
  "shape": [
53
  "B",
54
+ "Np",
55
  "H",
56
  "D"
57
  ],
58
  "dtype": "bfloat16"
59
  },
60
+ "K_current": {
61
  "shape": [
62
  "B",
63
+ "Nq",
64
  "H",
65
  "D"
66
  ],
67
  "dtype": "bfloat16"
68
  },
69
+ "V_current": {
70
  "shape": [
71
  "B",
72
+ "Nq",
73
  "H",
74
  "D"
75
  ],
76
  "dtype": "bfloat16"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
78
  },
79
  "outputs": {
 
90
  "constraints": [
91
  "B >= 1",
92
  "Nq >= 1",
93
+ "Np >= 1"
 
94
  ],
95
+ "reference": "import torch\n\n@torch.no_grad()\ndef run(Q, K_prefix, V_prefix, K_current, V_current):\n \"\"\"One SGLang target-image attention call; the current image sees every key.\"\"\"\n keys = torch.cat((K_prefix, K_current), dim=1).float()\n values = torch.cat((V_prefix, V_current), dim=1).float()\n scores = torch.einsum(\"bqhd,bkhd->bhqk\", Q.float(), keys) * (128 ** -0.5)\n return torch.einsum(\"bhqk,bkhd->bqhd\", scores.softmax(-1), values).to(torch.bfloat16)\n"
96
  }
definitions/block_causal_attention/prefix_cached_block_causal_h32_d128_prefix0.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "prefix_cached_block_causal_h32_d128_prefix0",
3
  "op_type": "block_causal_attention",
4
- "description": "Prefix-cached block-causal attention: allow j <= Np+i or matching nonnegative image IDs, then intersect key_valid. Text and different image blocks are causal; same-image tokens are bidirectional. Np=0 covers initial full evaluation. Prefix K/V are already computed; changed target-image K/V must be supplied as current inputs. Empty-prefix specialization: Np is a constant zero.",
5
  "tags": [
6
  "model:qwen-image-2.1-turbo",
7
  "status:draft",
@@ -16,14 +16,6 @@
16
  "type": "var",
17
  "description": "Runtime current query/token count."
18
  },
19
- "Np": {
20
- "type": "const",
21
- "value": 0
22
- },
23
- "Nall": {
24
- "type": "var",
25
- "description": "Total prefix and current length."
26
- },
27
  "H": {
28
  "type": "const",
29
  "value": 32
@@ -61,43 +53,12 @@
61
  ],
62
  "dtype": "bfloat16"
63
  },
64
- "K_prefix": {
65
- "shape": [
66
- "B",
67
- "Np",
68
- "H",
69
- "D"
70
- ],
71
- "dtype": "bfloat16"
72
- },
73
- "V_prefix": {
74
- "shape": [
75
- "B",
76
- "Np",
77
- "H",
78
- "D"
79
- ],
80
- "dtype": "bfloat16"
81
- },
82
  "image_ids": {
83
  "shape": [
84
- "Nall"
85
  ],
86
  "dtype": "int32",
87
  "description": "Text=-1; nonnegative IDs identify distinct contiguous image blocks. Shared batch layout."
88
- },
89
- "key_valid": {
90
- "shape": [
91
- "B",
92
- "Nall"
93
- ],
94
- "dtype": "bool",
95
- "description": "Key padding visibility mask; each query must see a key."
96
- },
97
- "sm_scale": {
98
- "shape": null,
99
- "dtype": "float32",
100
- "description": "Model default 1/sqrt(128)."
101
  }
102
  },
103
  "outputs": {
@@ -113,8 +74,7 @@
113
  },
114
  "constraints": [
115
  "B >= 1",
116
- "Nq >= 1",
117
- "Nall == Nq"
118
  ],
119
- "reference": "import math\nimport torch\n\n@torch.no_grad()\ndef run(Q, K_current, V_current, K_prefix, V_prefix, image_ids, key_valid, sm_scale):\n \"\"\"Causal across blocks/text, bidirectional within each nonnegative image ID.\"\"\"\n nprefix, nquery = K_prefix.shape[1], Q.shape[1]\n keys = torch.cat((K_prefix, K_current), dim=1).float()\n values = torch.cat((V_prefix, V_current), dim=1).float()\n positions = torch.arange(keys.shape[1], device=Q.device)\n query_positions = positions[nprefix:]\n query_images = image_ids[nprefix:]\n same_image = (query_images[:, None] == image_ids[None, :]) & (query_images[:, None] >= 0)\n allowed = (positions[None, :] <= query_positions[:, None]) | same_image\n allowed = allowed[None, :, :] & key_valid[:, None, :]\n assert bool(allowed.any(dim=-1).all()), \"Each query needs a visible key\"\n scores = torch.einsum(\"bqhd,bkhd->bhqk\", Q.float(), keys) * float(sm_scale)\n scores = scores.masked_fill(~allowed[:, None], -torch.inf)\n return torch.einsum(\"bhqk,bkhd->bqhd\", scores.softmax(-1), values).to(torch.bfloat16)\n"
120
  }
 
1
  {
2
  "name": "prefix_cached_block_causal_h32_d128_prefix0",
3
  "op_type": "block_causal_attention",
4
+ "description": "Prefix-cached block-causal attention: allow j <= Np+i or matching nonnegative image IDs, then intersect key_valid. Text and different image blocks are causal; same-image tokens are bidirectional. Np=0 covers initial full evaluation. Prefix K/V are already computed; changed target-image K/V must be supplied as current inputs. Empty-prefix specialization: Np is a constant zero. Empty prefix tensors, the all-visible key-valid input and the fixed scale are omitted. image_ids still represents the engine segment list, so this remains a composed operator contract.",
5
  "tags": [
6
  "model:qwen-image-2.1-turbo",
7
  "status:draft",
 
16
  "type": "var",
17
  "description": "Runtime current query/token count."
18
  },
 
 
 
 
 
 
 
 
19
  "H": {
20
  "type": "const",
21
  "value": 32
 
53
  ],
54
  "dtype": "bfloat16"
55
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  "image_ids": {
57
  "shape": [
58
+ "Nq"
59
  ],
60
  "dtype": "int32",
61
  "description": "Text=-1; nonnegative IDs identify distinct contiguous image blocks. Shared batch layout."
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  }
63
  },
64
  "outputs": {
 
74
  },
75
  "constraints": [
76
  "B >= 1",
77
+ "Nq >= 1"
 
78
  ],
79
+ "reference": "import torch\n\n@torch.no_grad()\ndef run(Q, K_current, V_current, image_ids):\n \"\"\"The uncached prefix's segmented text/image visibility, without empty state inputs.\"\"\"\n positions = torch.arange(Q.shape[1], device=Q.device)\n same_image = (image_ids[:, None] == image_ids[None, :]) & (image_ids[:, None] >= 0)\n allowed = (positions[None, :] <= positions[:, None]) | same_image\n scores = torch.einsum(\"bqhd,bkhd->bhqk\", Q.float(), K_current.float()) * (128 ** -0.5)\n scores = scores.masked_fill(~allowed[None, None], -torch.inf)\n return torch.einsum(\"bhqk,bkhd->bqhd\", scores.softmax(-1), V_current.float()).to(torch.bfloat16)\n"
80
  }
definitions/dense_attention/noncausal_dense_attention_h32_d128.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "noncausal_dense_attention_h32_d128",
3
  "op_type": "dense_attention",
4
- "description": "Noncausal self/cross attention with FP32 accumulation and BF16 output. Self attention uses Nq=Nk; cross attention allows unequal lengths. No dropout. Projection, normalization, rotary embeddings and output gates are outside the definition. No mask: every captured call's expanded visibility mask was all True (on one GPU the engine passes no mask, or an all-visible prompt mask), so KDA drops the dataset's mask input.",
5
  "tags": [
6
  "model:ltx-2.5",
7
  "status:draft",
@@ -56,11 +56,6 @@
56
  "D"
57
  ],
58
  "dtype": "bfloat16"
59
- },
60
- "sm_scale": {
61
- "shape": null,
62
- "dtype": "float32",
63
- "description": "Model default 1/sqrt(128)."
64
  }
65
  },
66
  "outputs": {
@@ -79,5 +74,5 @@
79
  "Nq >= 1",
80
  "Nk >= 1"
81
  ],
82
- "reference": "import math\nimport torch\n\n@torch.no_grad()\ndef run(Q, K, V, sm_scale):\n \"\"\"Noncausal attention without a mask.\"\"\"\n scores = torch.einsum(\"bqhd,bkhd->bhqk\", Q.float(), K.float())\n scores = scores * float(sm_scale)\n probabilities = torch.softmax(scores, dim=-1)\n return torch.einsum(\"bhqk,bkhd->bqhd\", probabilities, V.float()).to(torch.bfloat16)\n"
83
  }
 
1
  {
2
  "name": "noncausal_dense_attention_h32_d128",
3
  "op_type": "dense_attention",
4
+ "description": "Noncausal self/cross attention with FP32 accumulation and BF16 output. Self attention uses Nq=Nk; cross attention allows unequal lengths. No dropout. Projection, normalization, rotary embeddings and output gates are outside the definition. No mask: every captured call's expanded visibility mask was all True (on one GPU the engine passes no mask, or an all-visible prompt mask), so KDA drops the dataset's mask input. The SGLang call fixes scale to head_dim**-0.5; no runtime scale argument is exposed.",
5
  "tags": [
6
  "model:ltx-2.5",
7
  "status:draft",
 
56
  "D"
57
  ],
58
  "dtype": "bfloat16"
 
 
 
 
 
59
  }
60
  },
61
  "outputs": {
 
74
  "Nq >= 1",
75
  "Nk >= 1"
76
  ],
77
+ "reference": "import math\nimport torch\n\n@torch.no_grad()\ndef run(Q, K, V):\n \"\"\"Noncausal attention without a mask.\"\"\"\n scores = torch.einsum(\"bqhd,bkhd->bhqk\", Q.float(), K.float())\n scores = scores * (128 ** -0.5)\n probabilities = torch.softmax(scores, dim=-1)\n return torch.einsum(\"bhqk,bkhd->bqhd\", probabilities, V.float()).to(torch.bfloat16)\n"
78
  }
definitions/dense_attention/noncausal_dense_attention_h32_d64.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "noncausal_dense_attention_h32_d64",
3
  "op_type": "dense_attention",
4
- "description": "Noncausal self/cross attention with FP32 accumulation and BF16 output. Self attention uses Nq=Nk; cross attention allows unequal lengths. No dropout. Projection, normalization, rotary embeddings and output gates are outside the definition. No mask: every captured call's expanded visibility mask was all True (on one GPU the engine passes no mask, or an all-visible prompt mask), so KDA drops the dataset's mask input.",
5
  "tags": [
6
  "model:ltx-2.5",
7
  "status:draft",
@@ -56,11 +56,6 @@
56
  "D"
57
  ],
58
  "dtype": "bfloat16"
59
- },
60
- "sm_scale": {
61
- "shape": null,
62
- "dtype": "float32",
63
- "description": "Model default 1/sqrt(64)."
64
  }
65
  },
66
  "outputs": {
@@ -79,5 +74,5 @@
79
  "Nq >= 1",
80
  "Nk >= 1"
81
  ],
82
- "reference": "import math\nimport torch\n\n@torch.no_grad()\ndef run(Q, K, V, sm_scale):\n \"\"\"Noncausal attention without a mask.\"\"\"\n scores = torch.einsum(\"bqhd,bkhd->bhqk\", Q.float(), K.float())\n scores = scores * float(sm_scale)\n probabilities = torch.softmax(scores, dim=-1)\n return torch.einsum(\"bhqk,bkhd->bqhd\", probabilities, V.float()).to(torch.bfloat16)\n"
83
  }
 
1
  {
2
  "name": "noncausal_dense_attention_h32_d64",
3
  "op_type": "dense_attention",
4
+ "description": "Noncausal self/cross attention with FP32 accumulation and BF16 output. Self attention uses Nq=Nk; cross attention allows unequal lengths. No dropout. Projection, normalization, rotary embeddings and output gates are outside the definition. No mask: every captured call's expanded visibility mask was all True (on one GPU the engine passes no mask, or an all-visible prompt mask), so KDA drops the dataset's mask input. The SGLang call fixes scale to head_dim**-0.5; no runtime scale argument is exposed.",
5
  "tags": [
6
  "model:ltx-2.5",
7
  "status:draft",
 
56
  "D"
57
  ],
58
  "dtype": "bfloat16"
 
 
 
 
 
59
  }
60
  },
61
  "outputs": {
 
74
  "Nq >= 1",
75
  "Nk >= 1"
76
  ],
77
+ "reference": "import math\nimport torch\n\n@torch.no_grad()\ndef run(Q, K, V):\n \"\"\"Noncausal attention without a mask.\"\"\"\n scores = torch.einsum(\"bqhd,bkhd->bhqk\", Q.float(), K.float())\n scores = scores * (64 ** -0.5)\n probabilities = torch.softmax(scores, dim=-1)\n return torch.einsum(\"bhqk,bkhd->bqhd\", probabilities, V.float()).to(torch.bfloat16)\n"
78
  }
docs/gdn-prefill-numerics.md CHANGED
@@ -1,4 +1,4 @@
1
- # GDN prefill numerical analysis
2
 
3
  The imported contest baseline returns an FP32 state but performs several state-update matrix products with BF16 intermediate operands. Returning FP32 does not make those intermediate operations FP32-accurate. The independent reference instead updates the recurrence one token at a time in FP32.
4
 
@@ -25,4 +25,27 @@ The earlier standalone package had no explicit GDN task configuration. It applie
25
 
26
  The [contest evaluation commands](https://github.com/flashinfer-ai/flashinfer-bench-starter-kit/blob/75ccd05cafceb0fd1f86be4cd0f2117249463c66/EVALUATION.md) do not override GDN error tolerances. The pinned [FlashInfer-Bench defaults](https://github.com/flashinfer-ai/flashinfer-bench/blob/15618a67e8d7b7f49ca61b5ba3b9f26a876d0bee/flashinfer_bench/bench/config.py) use `atol=rtol=0.01` and require all elements. Its [error test](https://github.com/flashinfer-ai/flashinfer-bench/blob/15618a67e8d7b7f49ca61b5ba3b9f26a876d0bee/flashinfer_bench/bench/utils.py) accepts an element when the absolute error is within `atol` or the relative error, divided by `abs(reference)+1e-8`, is within `rtol`. Nonfinite outputs fail.
27
 
28
- Both GDN definitions now have explicit configs in `tasks/` with that policy and pinned source links. The 19 existing SGLang task tolerances are unchanged. Definitions, references, imported baseline implementations and workload tensors are unchanged. The six-token reproduction passes the configured contest bound while continuing to fail the separately retained strict FP32 diagnostic.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Historical GDN prefill numerical analysis
2
 
3
  The imported contest baseline returns an FP32 state but performs several state-update matrix products with BF16 intermediate operands. Returning FP32 does not make those intermediate operations FP32-accurate. The independent reference instead updates the recurrence one token at a time in FP32.
4
 
 
25
 
26
  The [contest evaluation commands](https://github.com/flashinfer-ai/flashinfer-bench-starter-kit/blob/75ccd05cafceb0fd1f86be4cd0f2117249463c66/EVALUATION.md) do not override GDN error tolerances. The pinned [FlashInfer-Bench defaults](https://github.com/flashinfer-ai/flashinfer-bench/blob/15618a67e8d7b7f49ca61b5ba3b9f26a876d0bee/flashinfer_bench/bench/config.py) use `atol=rtol=0.01` and require all elements. Its [error test](https://github.com/flashinfer-ai/flashinfer-bench/blob/15618a67e8d7b7f49ca61b5ba3b9f26a876d0bee/flashinfer_bench/bench/utils.py) accepts an element when the absolute error is within `atol` or the relative error, divided by `abs(reference)+1e-8`, is within `rtol`. Nonfinite outputs fail.
27
 
28
+ Both GDN definitions now have explicit configs in `tasks/` with that policy and pinned source links. The 19 existing SGLang task tolerances are unchanged. The audit preserves the definitions, independent references, workload tensors and tolerance policies, while replacing the legacy imported baseline implementation with maintained FlashInfer calls. The historical measurements above describe the original imported kernel. The six-token reproduction passes the configured contest bound while continuing to fail the separately retained strict FP32 diagnostic.
29
+
30
+ ## Maintained FlashInfer baseline in the interface audit
31
+
32
+ The replacement baseline uses FlashInfer 0.7.2 with CUTLASS DSL 4.8.0. All 100
33
+ prefill and 54 decode workloads pass the existing explicit contest policy, and
34
+ inputs remain byte-identical. Prefill forwards the requested runtime scale;
35
+ decode clones state before calling the maintained in-place API so the task's
36
+ input state is not mutated.
37
+
38
+ This does not make FP32 prefill state fully FP32-accurate. On the same six-token
39
+ workload, the maintained baseline has maximum state error
40
+ `0.0012151896953582764`; **3,909 / 131,072** elements still fail the historical
41
+ `rtol=1e-4, atol=2e-5` diagnostic. All ten tested prefill dev workloads fail that
42
+ strict diagnostic while passing the unchanged contest bound. The earlier
43
+ 4,143-element failure and its original measurements above remain historical
44
+ evidence for the original imported implementation.
45
+
46
+ The current FlashInfer development snapshot's raw-gate API was also evaluated
47
+ on all ten prefill dev workloads, including a nondefault scale probe. It passed
48
+ the contest policy but did not improve measured graph latency over the release
49
+ API in this environment, and still failed the strict FP32 state diagnostic.
50
+ The baseline therefore keeps the tested release API. No tolerance, reference or
51
+ input data was changed to obtain these passes.
docs/interface-audit/README.md ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SGLang interface and implementation audit — 2026-10-19
2
+
3
+ The 21 definitions are **not all direct replacements for current SGLang calls**.
4
+ Seven have tensor operands matching a specialized attention leaf, three dense
5
+ GEMMs flatten the engine's leading dimensions, and eleven retain structural
6
+ adapters. No full serving run with substituted candidate kernels has been
7
+ performed. Saved inputs are materialized contiguous tensors: original storage
8
+ offsets, aliasing and arbitrary engine strides are not retained by safetensors.
9
+ A matching shape/dimension order therefore does not prove storage-ABI parity.
10
+ Standalone correctness and native tensor-layout correspondence are
11
+ reported separately from integration.
12
+
13
+ The complete, per-definition record is [interfaces.json](interfaces.json). It
14
+ lists every native call, pinned source link, remaining adapter and required
15
+ integration work. It covers all 21 definitions, including both GDN variants.
16
+
17
+ ## Sources and scope
18
+
19
+ The capture used SGLang `684fea8af3b11a5b51ec9966c02959a32ad3421c`.
20
+ Current calls were inspected at
21
+ [`0025f939`](https://github.com/sgl-project/sglang/tree/0025f9394421451aa09ec192a4a6e7928e14736b),
22
+ with the [0.5.22 release](https://github.com/sgl-project/sglang/releases/tag/v0.5.22)
23
+ checked separately. New SGLang-based solutions pin the inspected commit;
24
+ capture baselines intentionally retain their original commit. A final
25
+ [head recheck](upstream-head-recheck.json) at 11:43 UTC found SGLang one commit
26
+ ahead (`ed0b8f43`); its [examined diff](sglang-head-recheck-diff.json) changes
27
+ an NPU output-gate guard and the Ascend MoE runner, not these NVIDIA operator
28
+ boundaries. The other five upstream heads were unchanged. The tested commit
29
+ remains pinned rather than silently replacing it with untested code.
30
+
31
+ The current DeepGEMM `1fc9c669`, FlashMLA `0f11e178`, NATTEN 0.21.7 and FA4
32
+ 4.0.0b35 already match the inspected upstream snapshots/releases. FlashInfer
33
+ 0.7.2 is the current stable release. Its current development snapshot
34
+ `f64b4ba8` was also tested for raw-gate GDN prefill; it did not beat the release
35
+ path on the ten dev workloads. CUTLASS DSL 4.8.0 matches the tested SGLang
36
+ runtime; this audit does not infer a speed advantage from the newer 4.8.1
37
+ version number. Exact source metadata is in [upstreams.json](upstreams.json). The explicit
38
+ [preferred solution list](preferred-solutions.json) identifies one measured
39
+ choice per definition; serving baselines remain separate.
40
+
41
+ These are current maintained implementations and scoped comparisons among the
42
+ tested alternatives. This is not evidence of global optimality across all
43
+ possible implementations, devices or serving configurations. In particular,
44
+ the newer FlashMLA MegaAttention fusion needs pre-RoPE/normalization inputs,
45
+ positions and weight preparation absent from the existing MLA definitions.
46
+ It cannot be applied faithfully by changing only the packaged function.
47
+
48
+ ## Feasible changes
49
+
50
+ - Dense attention now accepts only Q/K/V. The scale was fixed by head dimension
51
+ in all 162 workloads. The SGLang wrapper returns the native output view
52
+ without a gratuitous contiguous copy.
53
+ - Cached-prefix attention now accepts Q, prefix K/V and current K/V in native
54
+ positional order. All 28 calls have full visibility; artificial image IDs,
55
+ the all-true key mask and fixed scale are removed. Its FA4 implementation
56
+ consequently needs no custom mask.
57
+ - The twelve prefix-zero workloads drop empty prefix K/V tensors, the all-true
58
+ key mask and fixed scale. Their image IDs still encode a composed sequence of
59
+ native text/image segment calls; this remaining difference is explicit.
60
+ - All 202 changed attention contracts were replayed against their original
61
+ saved engine outputs, without relaxing the replay tolerance. Workload UUIDs,
62
+ surviving tensor values and saved outputs are preserved. Thirteen unused
63
+ tensor files are removed; previous replay records remain in provenance.
64
+ - Audio attention removes the FP16 conversions and uses BF16 FA4, with native
65
+ SDPA for self-attention tiles up to 64 tokens. Both paths pass all 108 current
66
+ workloads under the pre-existing 99.99% matched-element requirement.
67
+ - GDN uses maintained FlashInfer calls instead of the vendored wrappers.
68
+ Decode copies the input state before invoking the mutating API. Both paths
69
+ honor runtime scale, preserve the contest's disabled Q/K normalization, and
70
+ pass all 154 workloads without input mutation. See the separate
71
+ [precision report](../gdn-prefill-numerics.md): strict FP32 prefill state
72
+ accuracy remains unresolved.
73
+ - QSA index uses current SGLang scoring and native fast Top-K only to discover
74
+ the threshold. Deterministic Triton compaction restores lower-ID ties and
75
+ ascending IDs, independent of the native unordered selection. Capacities at
76
+ most 512 skip scoring altogether. All 192 actual workloads pass exactly;
77
+ all-tied, empty, short and padded rows are checked separately.
78
+ - The router uses native FP32-output projection and fused sqrt-softplus,
79
+ modality selection, Top-6, normalization and routed scale. One Triton kernel
80
+ performs the required output ordering/int64 conversion. All 50 workloads
81
+ retain exact selected IDs and the original strict FP32 weight tolerance.
82
+ - A current native TRT-LLM sparse-GQA solution is added alongside FA4; its 192
83
+ workloads pass. Its cache/layout preparation is explicit rather than being
84
+ described as a direct replacement for the serving backend.
85
+ - The four SGLang neighborhood wrappers now honor the engine's NATTEN branch
86
+ when available, retaining the existing FlexAttention fallback. All 45 actual
87
+ workloads pass both the default NATTEN and SGLang/NATTEN paths.
88
+ - The BF16 N=12288/K=4096 solution uses native linear on the three measured
89
+ large-M B300 shapes where it beat DeepGEMM; other shapes and B200 retain
90
+ DeepGEMM.
91
+ - The retained dense GEMM cannot enter the old M<=4/M=32 branch, so the branch
92
+ and its conflicting CUTLASS dependency are removed. FA4 dependencies are
93
+ aligned with the tested CUTLASS DSL 4.8.0 environment.
94
+
95
+ ## Remaining interface differences
96
+
97
+ | Definitions | Native boundary still missing or adapted |
98
+ |---|---|
99
+ | GDN decode | Mutable state pool and slot indices, Q/K L2 normalization, actual serving model/head configuration |
100
+ | GDN prefill | Normalized Q/K, prepared alpha/beta, output buffers/checkpoints and serving model configuration. The native FlashInfer prefill leaf already gets gathered per-batch state; claiming it always takes a full pool would be incorrect. |
101
+ | Two grouped GEMMs | Four global expert shards combined into one task, padding removed, logical scale bytes and row order replacing per-rank physical buffers/m_indices |
102
+ | Two sparse MLA and mixed MLA | Four ranks' real heads combined; native per-rank zero padding/output slices, original cache pools, explicit lengths and scheduling metadata reconstructed |
103
+ | QSA index | Zero query heads removed, live-page compaction, ordered task IDs versus native unordered IDs |
104
+ | Sparse GQA | Snapshot after current-token KV write, compact pools, request maps and physical packing reconstructed |
105
+ | Router | Projection plus routing combined; boolean modality replaces token IDs; int64 sorted IDs and applied scaling differ from native outputs |
106
+ | Prefix-zero attention | Several text/image leaf calls combined into one block-causal operation |
107
+ | Three dense GEMMs | Original batch/sequence dimensions flattened into M |
108
+
109
+ Changing these definitions to the full native contracts requires new native
110
+ captures or an explicit integration API, especially for pool side effects and
111
+ per-rank operands. Identity indices, invented padding or fabricated missing
112
+ inputs would not prove interface parity. The current inputs and references are
113
+ preserved instead of silently changing the task's mathematical meaning.
114
+
115
+ ## Validation and timing
116
+
117
+ All task tolerances, dev UUIDs, timing parameters and reference mathematical
118
+ operations are preserved. The four attention references only specialize inputs
119
+ whose invariants were checked for every affected workload. Both validation
120
+ runners read the explicit task tolerance, including the GDN absolute-or-relative
121
+ rule. Matched-element fractions use integer counts, and nonfinite outputs fail.
122
+ The historical strict GDN diagnostic is reported separately and is not marked
123
+ as passing.
124
+
125
+ The native input checker verifies all 21 definitions, 1,104 workloads and 5,493
126
+ tensor paths: shape, dtype, content hash, constraints, provenance and absence of
127
+ unreferenced files. The dataset has 5,111 unique snapshots. The complete changed
128
+ attention replay covers 202 workloads. Per-workload validation and scoped
129
+ comparisons are summarized in [performance.md](performance.md) and recorded in
130
+ [results.jsonl](results.jsonl) and
131
+ [summary.json](summary.json); source hashes identify earlier and final variants.
132
+
133
+ GPU measurements use B300, PyTorch 2.14.1+cu130 and the dependencies recorded in
134
+ the summary. Eager timings and prepared-launch graph timings are separate.
135
+ Graph timings include GPU conversions/padding/gathers within launch; only
136
+ explicit prepare work is excluded. In particular a prepared serving baseline
137
+ is not compared silently with an untimed preparation of the candidate.
138
+ Compilation, reference execution and input loading occur outside timing.
139
+ Measurements are standalone; they do not establish end-to-end serving speedups.
140
+
141
+ The initial QSA compatibility experiment used TileLang 0.1.12, as required by
142
+ current SGLang, and the old custom implementation mismatched 45 workloads.
143
+ Rechecking its declared TileLang 0.1.15 produced **192/192 exact passes**.
144
+ Therefore those failures are a dependency-version incompatibility, not evidence
145
+ that the old implementation fails with its declared environment. The final
146
+ implementation uses the current native scoring path on 0.1.12 and is compared
147
+ with the old implementation on its actual declared 0.1.15 dependency.
148
+
149
+ ## Reproduce
150
+
151
+ Install the selected solution's pinned dependencies and materialize the dataset
152
+ with Git LFS. Different historical solutions can require separate environments.
153
+ Run the audit from the repository root:
154
+
155
+ ```bash
156
+ python scripts/audit_solutions.py \
157
+ --gpu GPU-UUID --lock-directory /path/to/locks \
158
+ --suite all --reference-cache --graph-timing \
159
+ --report results/audit.jsonl
160
+
161
+ # Inspect GDN's historical strict bound in addition to formal acceptance.
162
+ python scripts/audit_solutions.py \
163
+ --gpu GPU-UUID --lock-directory /path/to/locks \
164
+ --definition gdn_prefill_qk4_v8_d128_k_last \
165
+ --suite dev --strict-diagnostic --scale-probe \
166
+ --report results/gdn-diagnostics.jsonl
167
+
168
+ python scripts/check_workload_inputs.py
169
+ python -m unittest discover -s tests
170
+ ```
171
+
172
+ `--data-root` can point to separately materialized tensors; `--cache-directory`
173
+ selects a writable reference/module cache. `--solution` and `--definition` are
174
+ repeatable. `--validation-only` skips timing. `--candidate /path/to/main.py`
175
+ compares an extra implementation on one selected definition. The script exits
176
+ nonzero on load or correctness failure; graph-capture failures are reported
177
+ separately from numerical correctness.
178
+
179
+ ## Build details
180
+
181
+ NATTEN 0.21.7 was built for SM103 with `CXX_STD=20` in its CMake cache:
182
+ PyTorch 2.14 headers require C++20, while the upstream build defaults to C++17.
183
+ The kernel sources were unchanged. `NATTEN_BUILD_DIR` must name an existing
184
+ directory for that cache setting to be used.
185
+
186
+ FlashMLA was built at the recorded commit and its CUTLASS submodule
187
+ `4faf1a1568cf1e4ad8ff71846a13e16f2a6a6f6b`. CUDA 13.0 cannot compile that source;
188
+ the upstream minimum is 13.1. Both isolated 13.1.115 and 13.3.73 compiler builds
189
+ were evaluated on all 72 workloads. The 13.3 build triggered upstream's
190
+ register-spill performance guard for sparse FP8 decode; its documented
191
+ `FLASH_MLA_SKIP_REG_SPILL_CHECK=1` build option was used for the additional
192
+ comparison. This skips a compiler performance guard, not output validation.
193
+ All 72 numerical/input-immutability checks passed for both builds. The 13.3
194
+ build gives about 3.3% geometric-mean improvement for the 42 mixed-decode
195
+ workloads and about 0.6% for the two sparse-prefill groups in this measurement.
196
+ These are compiler-specific results, not an algorithm or interface change.
docs/interface-audit/interfaces.json ADDED
@@ -0,0 +1,345 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "date": "2026-10-19",
3
+ "sglang_capture_commit": "684fea8af3b11a5b51ec9966c02959a32ad3421c",
4
+ "sglang_audit_commit": "0025f9394421451aa09ec192a4a6e7928e14736b",
5
+ "all_drop_in": false,
6
+ "full_engine_substitution_tested": false,
7
+ "counts": {
8
+ "reshaped_tensor_operands": 3,
9
+ "specialized_leaf_operands": 7,
10
+ "structural_adapter_required": 11
11
+ },
12
+ "definitions": [
13
+ {
14
+ "definition": "prefix_cached_block_causal_h32_d128",
15
+ "inputs": [
16
+ "Q",
17
+ "K_prefix",
18
+ "V_prefix",
19
+ "K_current",
20
+ "V_current"
21
+ ],
22
+ "integration_verified": false,
23
+ "boundary": "specialized_leaf_operands",
24
+ "native_call": "forward_with_replicated_kv_prefix(q, k_prefix, v_prefix, k_suffix, v_suffix)",
25
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/multimodal_gen/runtime/layers/attention/layer.py#L2134",
26
+ "adaptation": "After this PR all five tensor operands occur in native positional order. All 28 captured target-image calls have full visibility. The fixed scale, all-valid keys and artificial image IDs are removed. The serving method additionally obtains attention context and supports sequence parallelism; captures use one GPU.",
27
+ "next_step": "Integrate at this specialized single-GPU boundary and test the serving context; distributed prefix attention remains outside these captures."
28
+ },
29
+ {
30
+ "definition": "prefix_cached_block_causal_h32_d128_prefix0",
31
+ "inputs": [
32
+ "Q",
33
+ "K_current",
34
+ "V_current",
35
+ "image_ids"
36
+ ],
37
+ "integration_verified": false,
38
+ "boundary": "structural_adapter_required",
39
+ "native_call": "QwenImage21Attention.attend_sample: several local_attn calls followed by cat_outputs",
40
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/multimodal_gen/runtime/models/dits/qwen_image21.py#L719",
41
+ "adaptation": "The dataset combines the entire prefix into one block-causal operation. The engine calls attention once per text/image segment with different Q/K ranges and text causal masks. image_ids encodes the segment list. Empty prefix tensors, the all-true key mask and fixed scale are removed, but the composed call boundary remains.",
42
+ "next_step": "Recapture individual segment calls or introduce explicit segment metadata and a composed-operator integration API; do not label the existing definition a direct leaf replacement."
43
+ },
44
+ {
45
+ "definition": "noncausal_dense_attention_h32_d128",
46
+ "inputs": [
47
+ "Q",
48
+ "K",
49
+ "V"
50
+ ],
51
+ "integration_verified": false,
52
+ "boundary": "specialized_leaf_operands",
53
+ "native_call": "SDPAImpl.forward(query, key, value, attn_metadata)",
54
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/multimodal_gen/runtime/layers/attention/backends/sdpa.py#L89",
55
+ "adaptation": "The three tensor operands and their [B,N,H,D] layouts match the noncausal no-mask leaf. Head-dependent scale, dropout=0 and causal=False are fixed configuration; the engine passes its own context metadata. This PR removes the redundant runtime scale.",
56
+ "next_step": "Integrate the candidate through the existing attention backend/context dispatch; no full-engine replacement has been tested."
57
+ },
58
+ {
59
+ "definition": "noncausal_dense_attention_h32_d64",
60
+ "inputs": [
61
+ "Q",
62
+ "K",
63
+ "V"
64
+ ],
65
+ "integration_verified": false,
66
+ "boundary": "specialized_leaf_operands",
67
+ "native_call": "SDPAImpl.forward(query, key, value, attn_metadata)",
68
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/multimodal_gen/runtime/layers/attention/backends/sdpa.py#L89",
69
+ "adaptation": "The three tensor operands and their [B,N,H,D] layouts match the noncausal no-mask leaf. Head-dependent scale, dropout=0 and causal=False are fixed configuration; the engine passes its own context metadata. This PR removes the redundant runtime scale.",
70
+ "next_step": "Integrate the candidate through the existing attention backend/context dispatch; no full-engine replacement has been tested."
71
+ },
72
+ {
73
+ "definition": "gdn_decode_qk4_v8_d128_k_last",
74
+ "inputs": [
75
+ "q",
76
+ "k",
77
+ "v",
78
+ "state",
79
+ "A_log",
80
+ "a",
81
+ "dt_bias",
82
+ "b",
83
+ "scale"
84
+ ],
85
+ "integration_verified": false,
86
+ "boundary": "structural_adapter_required",
87
+ "native_call": "FlashInferGDNKernel.decode",
88
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/srt/layers/attention/linear/kernels/gdn_flashinfer.py#L387",
89
+ "adaptation": "The contest decode reads per-batch K-last state and returns a separate new_state, with Q/K normalization disabled. SM100 SGLang instead passes the complete mutable state pool plus slot indices, enables Q/K L2 normalization and writes the pool. The contest model TP/head configuration also differs.",
90
+ "next_step": "Capture the real current SGLang boundary, retaining normalization, pool/state-index side effects where present, prefill output buffers/checkpoints and the actual model configuration. Adding identity slot indices to contest tensors would not prove native parity."
91
+ },
92
+ {
93
+ "definition": "gdn_prefill_qk4_v8_d128_k_last",
94
+ "inputs": [
95
+ "q",
96
+ "k",
97
+ "v",
98
+ "state",
99
+ "A_log",
100
+ "a",
101
+ "dt_bias",
102
+ "b",
103
+ "cu_seqlens",
104
+ "scale"
105
+ ],
106
+ "integration_verified": false,
107
+ "boundary": "structural_adapter_required",
108
+ "native_call": "FlashInferGDNKernel.extend",
109
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/srt/layers/attention/linear/kernels/gdn_flashinfer.py#L481",
110
+ "adaptation": "K-last layout matches. Importantly, the actual SGLang FlashInfer prefill leaf already receives a gathered per-batch state, not the whole pool. However SGLang prepares normalized Q/K and linear decay alpha, passes preallocated output/state buffers and optional checkpoint metadata, and scatters states back. The contest definition instead accepts raw A_log/a/dt_bias/b and unnormalized Q/K, with a different model/head configuration.",
111
+ "next_step": "Capture the real current SGLang boundary, retaining normalization, pool/state-index side effects where present, prefill output buffers/checkpoints and the actual model configuration. Adding identity slot indices to contest tensors would not prove native parity."
112
+ },
113
+ {
114
+ "definition": "dense_gemm_bf16_nt_n12288_k4096",
115
+ "inputs": [
116
+ "A",
117
+ "W"
118
+ ],
119
+ "integration_verified": false,
120
+ "boundary": "reshaped_tensor_operands",
121
+ "native_call": "torch.nn.functional.linear(input, weight, bias=None)",
122
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/multimodal_gen/runtime/models/dits/qwen_image21.py",
123
+ "adaptation": "Capture flattens batch/sequence dimensions into M; restore the original leading dimensions at the model boundary. Two-dimensional GEMM operands and BF16 output match the bias-free linear leaf.",
124
+ "next_step": "Retain original leading shapes in per-call captures for direct high-level F.linear replacement."
125
+ },
126
+ {
127
+ "definition": "dense_gemm_bf16_nt_n4096_k12288",
128
+ "inputs": [
129
+ "A",
130
+ "W"
131
+ ],
132
+ "integration_verified": false,
133
+ "boundary": "reshaped_tensor_operands",
134
+ "native_call": "torch.nn.functional.linear(input, weight, bias=None)",
135
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/multimodal_gen/runtime/models/dits/qwen_image21.py",
136
+ "adaptation": "Capture flattens batch/sequence dimensions into M; restore the original leading dimensions at the model boundary. Two-dimensional GEMM operands and BF16 output match the bias-free linear leaf.",
137
+ "next_step": "Retain original leading shapes in per-call captures for direct high-level F.linear replacement."
138
+ },
139
+ {
140
+ "definition": "dense_gemm_bf16_nt_n4096_k4096",
141
+ "inputs": [
142
+ "A",
143
+ "W"
144
+ ],
145
+ "integration_verified": false,
146
+ "boundary": "reshaped_tensor_operands",
147
+ "native_call": "torch.nn.functional.linear(input, weight, bias=None)",
148
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/multimodal_gen/runtime/models/dits/qwen_image21.py",
149
+ "adaptation": "Capture flattens batch/sequence dimensions into M; restore the original leading dimensions at the model boundary. Two-dimensional GEMM operands and BF16 output match the bias-free linear leaf.",
150
+ "next_step": "Retain original leading shapes in per-call captures for direct high-level F.linear replacement."
151
+ },
152
+ {
153
+ "definition": "grouped_gemm_fp8_fp4_e384_n4608_k5120_g32",
154
+ "inputs": [
155
+ "Aq",
156
+ "Wq_packed",
157
+ "scale_A",
158
+ "scale_W",
159
+ "expert_id"
160
+ ],
161
+ "integration_verified": false,
162
+ "boundary": "structural_adapter_required",
163
+ "native_call": "deep_gemm_wrapper.grouped_gemm_nt_f8f8bf16_contig(lhs, rhs, out, m_indices, recipe_a, recipe_b)",
164
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/srt/layers/deep_gemm_wrapper/entrypoint.py#L132",
165
+ "adaptation": "Capture gathers four EP ranks (96 experts each) into a global 384-expert task, removes -1 padded rows, sorts valid rows by expert and serializes UE8M0 scale bytes. The native kernel consumes per-rank padded buffers, packed physical scale layouts, m_indices and a destination buffer. The packaged SGLang baseline reconstructs all four calls.",
166
+ "next_step": "Recapture per-rank padded operands, physical scales, output buffers and row maps. Complete logical MoE projection is preserved; the removed half-gate task is not restored.",
167
+ "capture_recipe_note": "The capture can expand group-128 activation scales into four identical logical group-32 scale bytes. Original physical scale layout and original group-size metadata are not native task arguments; the packaged baseline reconstructs a group-32 path."
168
+ },
169
+ {
170
+ "definition": "grouped_gemm_fp8_fp4_e384_n5120_k2304_g32",
171
+ "inputs": [
172
+ "Aq",
173
+ "Wq_packed",
174
+ "scale_A",
175
+ "scale_W",
176
+ "expert_id"
177
+ ],
178
+ "integration_verified": false,
179
+ "boundary": "structural_adapter_required",
180
+ "native_call": "deep_gemm_wrapper.grouped_gemm_nt_f8f8bf16_contig(lhs, rhs, out, m_indices, recipe_a, recipe_b)",
181
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/srt/layers/deep_gemm_wrapper/entrypoint.py#L132",
182
+ "adaptation": "Capture gathers four EP ranks (96 experts each) into a global 384-expert task, removes -1 padded rows, sorts valid rows by expert and serializes UE8M0 scale bytes. The native kernel consumes per-rank padded buffers, packed physical scale layouts, m_indices and a destination buffer. The packaged SGLang baseline reconstructs all four calls.",
183
+ "next_step": "Recapture per-rank padded operands, physical scales, output buffers and row maps. Complete logical MoE projection is preserved; the removed half-gate task is not restored.",
184
+ "capture_recipe_note": "The capture can expand group-128 activation scales into four identical logical group-32 scale bytes. Original physical scale layout and original group-size metadata are not native task arguments; the packaged baseline reconstructs a group-32 path."
185
+ },
186
+ {
187
+ "definition": "mixed_mla_decode_deepseek41_h64_d512_k8128_k4512",
188
+ "inputs": [
189
+ "Q",
190
+ "KV8",
191
+ "KV4",
192
+ "indices8",
193
+ "indices4",
194
+ "attn_sink",
195
+ "sm_scale"
196
+ ],
197
+ "integration_verified": false,
198
+ "boundary": "structural_adapter_required",
199
+ "native_call": "sgl_kernel.flash_mla.flash_mla_with_kvcache",
200
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/srt/layers/attention/deepseek_v4_backend.py",
201
+ "adaptation": "The four-rank real-head gather differs from native per-rank zero padding. Only reachable physical KV pages are retained; topk lengths and scheduler metadata are reconstructed. Upstream FlashMLA and the serving fork use different FP8 page byte layouts, requiring the packaged conversion. The engine also has mutable scheduling/workspace state.",
202
+ "next_step": "Recapture per-rank Q/sink, original cache pools, explicit valid lengths and scheduler metadata. The newer optional MegaAttention path needs missing pre-RoPE/normalization inputs and positions."
203
+ },
204
+ {
205
+ "definition": "moe_router_gemm_topk_deepseek41_d5120_e384_topk6",
206
+ "inputs": [
207
+ "X",
208
+ "W",
209
+ "bias_text",
210
+ "bias_image",
211
+ "is_image_token",
212
+ "routed_scale"
213
+ ],
214
+ "integration_verified": false,
215
+ "boundary": "structural_adapter_required",
216
+ "native_call": "MoEGate.forward followed by vision_topk / moe_fused_gate",
217
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/srt/multimodal/dsv41/vl_routing.py",
218
+ "adaptation": "One task combines projection and routing. A boolean image selector replaces original token IDs; output IDs are sorted int64 rather than native unordered int32, and deferred routed scaling is applied. The new solution uses the native projection and fused gate, accepts the boolean directly and combines output ordering in one Triton launch.",
219
+ "next_step": "Either integrate this composed operation with its explicit output adapter, or split projection/routing captures and retain native token IDs and output dtypes/ordering."
220
+ },
221
+ {
222
+ "definition": "neighborhood_attention_3d_h16_d64_kt3_ky7_kx7",
223
+ "inputs": [
224
+ "Q",
225
+ "K",
226
+ "V"
227
+ ],
228
+ "integration_verified": false,
229
+ "boundary": "specialized_leaf_operands",
230
+ "native_call": "natten.functional.na3d(query, key, value, kernel_size=self.kernel_size, scale=1.0)",
231
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/multimodal_gen/runtime/models/decoders/ltx_2_5_diffusion_decoder.py#L421",
232
+ "adaptation": "Tensor layout [B,T,Y,X,H,D] already matches na3d. Q includes the model scale. Kernel size and scale=1 are fixed configuration. The SGLang wrapper now selects NATTEN when installed and otherwise uses the original FlexAttention fallback.",
233
+ "next_step": "Bind the fixed keyword configuration and test within the VAE block; no full model substitution is claimed."
234
+ },
235
+ {
236
+ "definition": "neighborhood_attention_3d_h32_d64_kt3_ky7_kx7",
237
+ "inputs": [
238
+ "Q",
239
+ "K",
240
+ "V"
241
+ ],
242
+ "integration_verified": false,
243
+ "boundary": "specialized_leaf_operands",
244
+ "native_call": "natten.functional.na3d(query, key, value, kernel_size=self.kernel_size, scale=1.0)",
245
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/multimodal_gen/runtime/models/decoders/ltx_2_5_diffusion_decoder.py#L421",
246
+ "adaptation": "Tensor layout [B,T,Y,X,H,D] already matches na3d. Q includes the model scale. Kernel size and scale=1 are fixed configuration. The SGLang wrapper now selects NATTEN when installed and otherwise uses the original FlexAttention fallback.",
247
+ "next_step": "Bind the fixed keyword configuration and test within the VAE block; no full model substitution is claimed."
248
+ },
249
+ {
250
+ "definition": "neighborhood_attention_3d_h4_d64_kt11_ky11_kx11",
251
+ "inputs": [
252
+ "Q",
253
+ "K",
254
+ "V"
255
+ ],
256
+ "integration_verified": false,
257
+ "boundary": "specialized_leaf_operands",
258
+ "native_call": "natten.functional.na3d(query, key, value, kernel_size=self.kernel_size, scale=1.0)",
259
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/multimodal_gen/runtime/models/decoders/ltx_2_5_diffusion_decoder.py#L421",
260
+ "adaptation": "Tensor layout [B,T,Y,X,H,D] already matches na3d. Q includes the model scale. Kernel size and scale=1 are fixed configuration. The SGLang wrapper now selects NATTEN when installed and otherwise uses the original FlexAttention fallback.",
261
+ "next_step": "Bind the fixed keyword configuration and test within the VAE block; no full model substitution is claimed."
262
+ },
263
+ {
264
+ "definition": "neighborhood_attention_3d_h8_d64_kt3_ky5_kx5",
265
+ "inputs": [
266
+ "Q",
267
+ "K",
268
+ "V"
269
+ ],
270
+ "integration_verified": false,
271
+ "boundary": "specialized_leaf_operands",
272
+ "native_call": "natten.functional.na3d(query, key, value, kernel_size=self.kernel_size, scale=1.0)",
273
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/multimodal_gen/runtime/models/decoders/ltx_2_5_diffusion_decoder.py#L421",
274
+ "adaptation": "Tensor layout [B,T,Y,X,H,D] already matches na3d. Q includes the model scale. Kernel size and scale=1 are fixed configuration. The SGLang wrapper now selects NATTEN when installed and otherwise uses the original FlexAttention fallback.",
275
+ "next_step": "Bind the fixed keyword configuration and test within the VAE block; no full model substitution is claimed."
276
+ },
277
+ {
278
+ "definition": "qsa_index_topk_decode_qwen38_h4_d128_topk512_c4",
279
+ "inputs": [
280
+ "Q_idx",
281
+ "Kc_pages",
282
+ "page_table",
283
+ "num_complete_blocks"
284
+ ],
285
+ "integration_verified": false,
286
+ "boundary": "structural_adapter_required",
287
+ "native_call": "QSAIndexer.select_decode_tokens -> qsa_mqa_decode + fast_topk",
288
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/srt/layers/attention/qsa/qsa_indexer.py#L491",
289
+ "adaptation": "Capture removes four zero-padded query heads (8 to 4), compacts live cache pages and changes unordered native IDs to ascending logical IDs with -1 suffix. The new default reuses maintained scoring and exact stable compaction; its score-free short path preserves the task's output contract.",
290
+ "next_step": "Capture the native padded query/cache/page-table boundary and explicitly support the engine's output ordering, or keep the documented adapters. Do not weaken exact selected-set or lower-ID-tie semantics."
291
+ },
292
+ {
293
+ "definition": "qsa_sparse_gqa_decode_qwen38_h24_kv2_d256_topk512_c4",
294
+ "inputs": [
295
+ "Q",
296
+ "K_pages",
297
+ "V_pages",
298
+ "page_table",
299
+ "block_ids",
300
+ "context_lens"
301
+ ],
302
+ "integration_verified": false,
303
+ "boundary": "structural_adapter_required",
304
+ "native_call": "QwenSparseAttnBackend.forward_decode -> TRT-LLM paged attention",
305
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/srt/layers/attention/qwen_sparse_attn_backend.py",
306
+ "adaptation": "Inputs are compacted page snapshots after the current-token KV write. The engine receives the original pool, request-to-token metadata and current KV, and fuses sparse block expansion/cache packing. The standalone adapter reconstructs that metadata and physical packing.",
307
+ "next_step": "Retain the original pools, request maps, current-token KV writes and the exact fused-call metadata in new captures. The native TRT-LLM solution is provided as a faster measured alternative to FA4, with adapters still explicit."
308
+ },
309
+ {
310
+ "definition": "sparse_mla_prefill_h64_d512_k128",
311
+ "inputs": [
312
+ "Q",
313
+ "KV",
314
+ "indices",
315
+ "topk_length",
316
+ "attn_sink",
317
+ "sm_scale"
318
+ ],
319
+ "integration_verified": false,
320
+ "boundary": "structural_adapter_required",
321
+ "native_call": "sgl_kernel.flash_mla.flash_mla_sparse_fwd",
322
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/srt/layers/attention/deepseek_v4_backend.py",
323
+ "adaptation": "Capture gathers 16 real query heads from each of four TP ranks into 64 real heads. The engine passes each rank's 16 heads in a zero-padded 64-head buffer and keeps its first 16 outputs. The SGLang adapter repeats four native calls and concatenates their outputs.",
324
+ "next_step": "Recapture per-rank padded Q/sink and output slices. Current optional MegaAttention further fuses normalization/RoPE and needs pre-transform inputs not present in this definition."
325
+ },
326
+ {
327
+ "definition": "sparse_mla_prefill_h64_d512_k640",
328
+ "inputs": [
329
+ "Q",
330
+ "KV",
331
+ "indices",
332
+ "topk_length",
333
+ "attn_sink",
334
+ "sm_scale"
335
+ ],
336
+ "integration_verified": false,
337
+ "boundary": "structural_adapter_required",
338
+ "native_call": "sgl_kernel.flash_mla.flash_mla_sparse_fwd",
339
+ "source": "https://github.com/sgl-project/sglang/blob/0025f9394421451aa09ec192a4a6e7928e14736b/python/sglang/srt/layers/attention/deepseek_v4_backend.py",
340
+ "adaptation": "Capture gathers 16 real query heads from each of four TP ranks into 64 real heads. The engine passes each rank's 16 heads in a zero-padded 64-head buffer and keeps its first 16 outputs. The SGLang adapter repeats four native calls and concatenates their outputs.",
341
+ "next_step": "Recapture per-rank padded Q/sink and output slices. Current optional MegaAttention further fuses normalization/RoPE and needs pre-transform inputs not present in this definition."
342
+ }
343
+ ],
344
+ "snapshot_limit": "CaptureWriter materializes contiguous CPU tensors; original storage offsets, aliasing and arbitrary engine strides are not represented by the safetensors inputs. Tensor-dimension correspondence does not prove storage-ABI parity."
345
+ }
docs/interface-audit/performance.md ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Recorded B300 comparisons
2
+
3
+ Ratios are paired geometric-mean speedups in the recorded standalone CUDA Graph scope. Prepared launch is used where available; eager timings remain in the raw results. These are not end-to-end serving speedups or proofs of global optimality.
4
+
5
+ | Comparison | Paired workloads | Speedup |
6
+ |---|---:|---:|
7
+ | B300 GEMM large-M native-linear dispatch versus DeepGEMM-only | 31 | 0.44× |
8
+ | Audio final versus original FP16-conversion solution | 108 | 4.03× |
9
+ | Current fused router versus original CUTLASS/torch solution | 50 | 5.00× |
10
+ | Cached-prefix FA4 versus serving implementation adapter | 28 | 3.81× |
11
+ | QSA index final versus original on its declared TileLang 0.1.15 | 10 | 2.28× |
12
+ | Native paged sparse GQA versus FA4 sparse gather | 10 | 1.90× |
13
+ | FlashMLA CUDA 13.3 versus CUDA 13.1 compiler build | 10 | 1.01× |
14
+ | FlashMLA CUDA 13.3 versus CUDA 13.1 compiler build | 20 | 1.01× |
15
+ | FlashMLA CUDA 13.3 versus CUDA 13.1 compiler build | 42 | 1.03× |
16
+
17
+ The old QSA implementation is measured with its declared TileLang 0.1.15, rather than the incompatible 0.1.12 experiment. Current SGLang-based solutions use 0.1.12. See [summary.json](summary.json) for ranges, source run identifiers and coverage; [results.jsonl](results.jsonl) retains separate eager and prepared timings.
docs/interface-audit/preferred-solutions.json ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "date": "2026-10-19",
3
+ "hardware": "NVIDIA_B300",
4
+ "definitions": [
5
+ {
6
+ "definition": "prefix_cached_block_causal_h32_d128",
7
+ "solution": "fa4_prefix_h32_d128",
8
+ "path": "solutions/block_causal_attention/fa4_prefix_h32_d128.json",
9
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
10
+ },
11
+ {
12
+ "definition": "prefix_cached_block_causal_h32_d128_prefix0",
13
+ "solution": "fa4_prefix0_h32_d128",
14
+ "path": "solutions/block_causal_attention/fa4_prefix0_h32_d128.json",
15
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
16
+ },
17
+ {
18
+ "definition": "noncausal_dense_attention_h32_d128",
19
+ "solution": "fa4_noncausal_h32_d128",
20
+ "path": "solutions/dense_attention/fa4_noncausal_h32_d128.json",
21
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
22
+ },
23
+ {
24
+ "definition": "noncausal_dense_attention_h32_d64",
25
+ "solution": "fa4_noncausal_h32_d64",
26
+ "path": "solutions/dense_attention/fa4_noncausal_h32_d64.json",
27
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
28
+ },
29
+ {
30
+ "definition": "gdn_decode_qk4_v8_d128_k_last",
31
+ "solution": "flashinfer_gdn_decode",
32
+ "path": "solutions/gdn/flashinfer_gdn_decode.json",
33
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
34
+ },
35
+ {
36
+ "definition": "gdn_prefill_qk4_v8_d128_k_last",
37
+ "solution": "flashinfer_gdn_prefill",
38
+ "path": "solutions/gdn/flashinfer_gdn_prefill.json",
39
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
40
+ },
41
+ {
42
+ "definition": "dense_gemm_bf16_nt_n12288_k4096",
43
+ "solution": "deepgemm_bf16_n12288_k4096",
44
+ "path": "solutions/gemm/deepgemm_bf16_n12288_k4096.json",
45
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
46
+ },
47
+ {
48
+ "definition": "dense_gemm_bf16_nt_n4096_k12288",
49
+ "solution": "deepgemm_bf16_n4096_k12288",
50
+ "path": "solutions/gemm/deepgemm_bf16_n4096_k12288.json",
51
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
52
+ },
53
+ {
54
+ "definition": "dense_gemm_bf16_nt_n4096_k4096",
55
+ "solution": "hybrid_bf16_n4096_k4096",
56
+ "path": "solutions/gemm/hybrid_bf16_n4096_k4096.json",
57
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
58
+ },
59
+ {
60
+ "definition": "grouped_gemm_fp8_fp4_e384_n4608_k5120_g32",
61
+ "solution": "deepgemm_n4608_k5120",
62
+ "path": "solutions/grouped_gemm/deepgemm_n4608_k5120.json",
63
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
64
+ },
65
+ {
66
+ "definition": "grouped_gemm_fp8_fp4_e384_n5120_k2304_g32",
67
+ "solution": "deepgemm_n5120_k2304",
68
+ "path": "solutions/grouped_gemm/deepgemm_n5120_k2304.json",
69
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
70
+ },
71
+ {
72
+ "definition": "mixed_mla_decode_deepseek41_h64_d512_k8128_k4512",
73
+ "solution": "flashmla_v41",
74
+ "path": "solutions/mixed_mla/flashmla_v41.json",
75
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
76
+ },
77
+ {
78
+ "definition": "moe_router_gemm_topk_deepseek41_d5120_e384_topk6",
79
+ "solution": "fused_router",
80
+ "path": "solutions/moe_router/fused_router.json",
81
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
82
+ },
83
+ {
84
+ "definition": "neighborhood_attention_3d_h16_d64_kt3_ky7_kx7",
85
+ "solution": "natten_blackwell_h16_3x7x7",
86
+ "path": "solutions/neighborhood_attention/natten_blackwell_h16_3x7x7.json",
87
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
88
+ },
89
+ {
90
+ "definition": "neighborhood_attention_3d_h32_d64_kt3_ky7_kx7",
91
+ "solution": "natten_blackwell_h32_3x7x7",
92
+ "path": "solutions/neighborhood_attention/natten_blackwell_h32_3x7x7.json",
93
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
94
+ },
95
+ {
96
+ "definition": "neighborhood_attention_3d_h4_d64_kt11_ky11_kx11",
97
+ "solution": "natten_blackwell_h4_11x11x11",
98
+ "path": "solutions/neighborhood_attention/natten_blackwell_h4_11x11x11.json",
99
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
100
+ },
101
+ {
102
+ "definition": "neighborhood_attention_3d_h8_d64_kt3_ky5_kx5",
103
+ "solution": "natten_blackwell_h8_3x5x5",
104
+ "path": "solutions/neighborhood_attention/natten_blackwell_h8_3x5x5.json",
105
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
106
+ },
107
+ {
108
+ "definition": "qsa_index_topk_decode_qwen38_h4_d128_topk512_c4",
109
+ "solution": "sglang_tilelang_index",
110
+ "path": "solutions/qsa_index/sglang_tilelang_index.json",
111
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
112
+ },
113
+ {
114
+ "definition": "qsa_sparse_gqa_decode_qwen38_h24_kv2_d256_topk512_c4",
115
+ "solution": "trtllm_sparse_gqa",
116
+ "path": "solutions/qsa_attention/trtllm_sparse_gqa.json",
117
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
118
+ },
119
+ {
120
+ "definition": "sparse_mla_prefill_h64_d512_k128",
121
+ "solution": "flashmla_prefill_k128",
122
+ "path": "solutions/sparse_mla/flashmla_prefill_k128.json",
123
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
124
+ },
125
+ {
126
+ "definition": "sparse_mla_prefill_h64_d512_k640",
127
+ "solution": "flashmla_prefill_k640",
128
+ "path": "solutions/sparse_mla/flashmla_prefill_k640.json",
129
+ "scope": "B300 current captured workloads; selected maintained path after scoped comparisons, not a fastest-for-every-shape or global-optimality claim"
130
+ }
131
+ ]
132
+ }
docs/interface-audit/qsa-tie-edge-cases.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "checks": [
3
+ {
4
+ "capacity": 32,
5
+ "lengths": [
6
+ 0,
7
+ 1,
8
+ 32
9
+ ],
10
+ "all_scores_equal": true,
11
+ "lower_ids_exact": true,
12
+ "status": "passed"
13
+ },
14
+ {
15
+ "capacity": 640,
16
+ "lengths": [
17
+ 0,
18
+ 511,
19
+ 512,
20
+ 513,
21
+ 640
22
+ ],
23
+ "all_scores_equal": true,
24
+ "lower_ids_exact": true,
25
+ "status": "passed"
26
+ },
27
+ {
28
+ "capacity": 65536,
29
+ "lengths": [
30
+ 0,
31
+ 511,
32
+ 512,
33
+ 513,
34
+ 65536
35
+ ],
36
+ "all_scores_equal": true,
37
+ "lower_ids_exact": true,
38
+ "status": "passed"
39
+ }
40
+ ],
41
+ "status": "passed"
42
+ }
docs/interface-audit/results.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
docs/interface-audit/sglang-head-recheck-diff.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base": "0025f9394421451aa09ec192a4a6e7928e14736b",
3
+ "head": "ed0b8f433f887995b1ce361b15aaf9f6ca93483f",
4
+ "ahead_by": 1,
5
+ "files": [
6
+ {
7
+ "path": "python/sglang/kernels/ops/attention/mla_output_gate.py",
8
+ "status": "modified"
9
+ },
10
+ {
11
+ "path": "python/sglang/srt/layers/moe/moe_runner/ascend.py",
12
+ "status": "modified"
13
+ }
14
+ ],
15
+ "commits": [
16
+ {
17
+ "sha": "ed0b8f433f887995b1ce361b15aaf9f6ca93483f",
18
+ "title": "[Fix] [NPU] kimi-k3: skip fused gmm1 for situ activation in Ascend runner (#43837)"
19
+ }
20
+ ]
21
+ }
docs/interface-audit/summary.json ADDED
@@ -0,0 +1,493 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "date": "2026-10-19",
3
+ "status": "passed",
4
+ "secondary_baseline_cases_remaining": 0,
5
+ "scope": "One current preferred solution per definition, all captured workloads; not full serving integration or proof of global optimality",
6
+ "gpu": "NVIDIA B300",
7
+ "torch": "2.14.1+cu130",
8
+ "cutlass_dsl": "4.8.0",
9
+ "flashinfer_release": "0.7.2",
10
+ "tilelang_current_sglang": "0.1.12",
11
+ "tilelang_original_declared": "0.1.15",
12
+ "sglang_current_commit": "0025f9394421451aa09ec192a4a6e7928e14736b",
13
+ "solutions": 41,
14
+ "preferred_definitions": 21,
15
+ "preferred_workloads": 1104,
16
+ "tolerance_dev_and_timing_unchanged": true,
17
+ "native_input_check": {
18
+ "definitions": 21,
19
+ "workloads": 1104,
20
+ "tensors": 5493,
21
+ "missing_capture_definitions": [],
22
+ "errors": []
23
+ },
24
+ "changed_attention_engine_output_replay": {
25
+ "workloads": 202,
26
+ "passed": 202
27
+ },
28
+ "coverage": [
29
+ {
30
+ "definition": "prefix_cached_block_causal_h32_d128",
31
+ "solution": "fa4_prefix_h32_d128",
32
+ "workloads": 28,
33
+ "status": "passed",
34
+ "main_source_sha256": "ea9b3c887ea916e45144176d5efc9689f67e0f2c358b6550878ef474d534cf6c",
35
+ "source_bundle_sha256": "1b5b733b6a5f88dacc0f7ccd4c6b1680ae56e811349344778107f9e63ee03c97",
36
+ "runs": [
37
+ "attention-final-contracts"
38
+ ]
39
+ },
40
+ {
41
+ "definition": "prefix_cached_block_causal_h32_d128_prefix0",
42
+ "solution": "fa4_prefix0_h32_d128",
43
+ "workloads": 12,
44
+ "status": "passed",
45
+ "main_source_sha256": "c5742cde113a0e610300650857ae0221928e7242d8710efbb28d53bab066e9a0",
46
+ "source_bundle_sha256": "b781309fee9fc3fa9f4e73770754b79465b48f148fc4acaea8668704690fe360",
47
+ "runs": [
48
+ "attention-all"
49
+ ]
50
+ },
51
+ {
52
+ "definition": "noncausal_dense_attention_h32_d128",
53
+ "solution": "fa4_noncausal_h32_d128",
54
+ "workloads": 54,
55
+ "status": "passed",
56
+ "main_source_sha256": "67ed48f66216ccd570fa047fcf6c46dc2c7113387c972bf35788c5235c327f95",
57
+ "source_bundle_sha256": "dac275c646d983cc090a1427ddcad9972899893be035e5390d36d540cd87b1d4",
58
+ "runs": [
59
+ "attention-all"
60
+ ]
61
+ },
62
+ {
63
+ "definition": "noncausal_dense_attention_h32_d64",
64
+ "solution": "fa4_noncausal_h32_d64",
65
+ "workloads": 108,
66
+ "status": "passed",
67
+ "main_source_sha256": "7d5c98b3052f60560e52eb49d5802ac386c1da61009ec7faf723d0b055bfd85f",
68
+ "source_bundle_sha256": "ab47824774752abebf2fca278f38fd3506cbd76f45e74eb9027b7655f12f3978",
69
+ "runs": [
70
+ "attention-final-contracts"
71
+ ]
72
+ },
73
+ {
74
+ "definition": "gdn_decode_qk4_v8_d128_k_last",
75
+ "solution": "flashinfer_gdn_decode",
76
+ "workloads": 54,
77
+ "status": "passed",
78
+ "main_source_sha256": "e17286beadf7d1cec3c41cdacc7ab1a0f0f426847d7bfe7ec35369498c6393bf",
79
+ "source_bundle_sha256": "23a710cfbf848aaedb0f58d5313f9ff8e987342f2a1500a1705adfdc34d93f74",
80
+ "runs": [
81
+ "gdn-all-counted"
82
+ ]
83
+ },
84
+ {
85
+ "definition": "gdn_prefill_qk4_v8_d128_k_last",
86
+ "solution": "flashinfer_gdn_prefill",
87
+ "workloads": 100,
88
+ "status": "passed",
89
+ "main_source_sha256": "63a37b167c6496eee8519318a73177a1d2df07df3da6a9c0debd3c871f0c7b09",
90
+ "source_bundle_sha256": "a64843eee16239a2cce37dc1f3bfe4feca66e05f3bf3b2c0f2499105e4182378",
91
+ "runs": [
92
+ "gdn-all-counted"
93
+ ]
94
+ },
95
+ {
96
+ "definition": "dense_gemm_bf16_nt_n12288_k4096",
97
+ "solution": "deepgemm_bf16_n12288_k4096",
98
+ "workloads": 31,
99
+ "status": "passed",
100
+ "main_source_sha256": "ec62fd82b2cfb65dde71e19b1ffc890dfa90c946de4161fb1fdd1729fc5b33fd",
101
+ "source_bundle_sha256": "59154b578176ddc58f865e55bfa2e061ae48b3f89b2f44a9ec14b963782374a8",
102
+ "runs": [
103
+ "dense-n12288-final-all"
104
+ ]
105
+ },
106
+ {
107
+ "definition": "dense_gemm_bf16_nt_n4096_k12288",
108
+ "solution": "deepgemm_bf16_n4096_k12288",
109
+ "workloads": 31,
110
+ "status": "passed",
111
+ "main_source_sha256": "8b190e1905d9f7b4b0b14fa7303d4a08e227cf7760f1de5801b3f890ba9c8081",
112
+ "source_bundle_sha256": "d4ef0c9bb1a051e3d7f654e14646db349173a970100dedf179acc648d16b0533",
113
+ "runs": [
114
+ "gemm-all"
115
+ ]
116
+ },
117
+ {
118
+ "definition": "dense_gemm_bf16_nt_n4096_k4096",
119
+ "solution": "hybrid_bf16_n4096_k4096",
120
+ "workloads": 31,
121
+ "status": "passed",
122
+ "main_source_sha256": "8e1358895cda9eaa10258759ae3fe3a57c93731c731f73e7772b46b90c26e6b6",
123
+ "source_bundle_sha256": "ae030e7438d6664b7f4cad3e3244949c237f08de098a5ff452906edfb1eca3be",
124
+ "runs": [
125
+ "gemm-all"
126
+ ]
127
+ },
128
+ {
129
+ "definition": "grouped_gemm_fp8_fp4_e384_n4608_k5120_g32",
130
+ "solution": "deepgemm_n4608_k5120",
131
+ "workloads": 52,
132
+ "status": "passed",
133
+ "main_source_sha256": "d9814eacc8b50a38371ca250faf9a2c751bf66ac09b32b487c98117a8106ba21",
134
+ "source_bundle_sha256": "6b1a58f383b9682ae06b21b4feadc7c1c9ec82ea15a464de1b9f4b72f6fce978",
135
+ "runs": [
136
+ "gemm-all"
137
+ ]
138
+ },
139
+ {
140
+ "definition": "grouped_gemm_fp8_fp4_e384_n5120_k2304_g32",
141
+ "solution": "deepgemm_n5120_k2304",
142
+ "workloads": 52,
143
+ "status": "passed",
144
+ "main_source_sha256": "d9814eacc8b50a38371ca250faf9a2c751bf66ac09b32b487c98117a8106ba21",
145
+ "source_bundle_sha256": "6b1a58f383b9682ae06b21b4feadc7c1c9ec82ea15a464de1b9f4b72f6fce978",
146
+ "runs": [
147
+ "gemm-all"
148
+ ]
149
+ },
150
+ {
151
+ "definition": "mixed_mla_decode_deepseek41_h64_d512_k8128_k4512",
152
+ "solution": "flashmla_v41",
153
+ "workloads": 42,
154
+ "status": "passed",
155
+ "main_source_sha256": "05b199f80930fd87851c1b45d18248bc9a51943ceee9554af3dead121af80cea",
156
+ "source_bundle_sha256": "354ab160017c821ee197ae5741cb263ecb75fb0ad1d53d8fc427e26c0c63a8a6",
157
+ "runs": [
158
+ "mla-cu133-all"
159
+ ]
160
+ },
161
+ {
162
+ "definition": "moe_router_gemm_topk_deepseek41_d5120_e384_topk6",
163
+ "solution": "fused_router",
164
+ "workloads": 50,
165
+ "status": "passed",
166
+ "main_source_sha256": "278e9e41c9dd4d35607fbc760fbaaac583c7d4f75cbf0fe1353903b7ddd0d890",
167
+ "source_bundle_sha256": "41251abb5f27fbb587d28c2dbce5280775b403156f4f04cc1d2e85e1bef0018d",
168
+ "runs": [
169
+ "router-latest-all"
170
+ ]
171
+ },
172
+ {
173
+ "definition": "neighborhood_attention_3d_h16_d64_kt3_ky7_kx7",
174
+ "solution": "natten_blackwell_h16_3x7x7",
175
+ "workloads": 9,
176
+ "status": "passed",
177
+ "main_source_sha256": "1e37321ed835300fa3550a6fe29506bd28412d019581dbc9fbc10ccc8fff4a4c",
178
+ "source_bundle_sha256": "a8718b4b8210c509699cf4a17a4158a6f0f569236fa3c26aa3dd81278e71e376",
179
+ "runs": [
180
+ "na-all"
181
+ ]
182
+ },
183
+ {
184
+ "definition": "neighborhood_attention_3d_h32_d64_kt3_ky7_kx7",
185
+ "solution": "natten_blackwell_h32_3x7x7",
186
+ "workloads": 9,
187
+ "status": "passed",
188
+ "main_source_sha256": "1e37321ed835300fa3550a6fe29506bd28412d019581dbc9fbc10ccc8fff4a4c",
189
+ "source_bundle_sha256": "a8718b4b8210c509699cf4a17a4158a6f0f569236fa3c26aa3dd81278e71e376",
190
+ "runs": [
191
+ "na-all"
192
+ ]
193
+ },
194
+ {
195
+ "definition": "neighborhood_attention_3d_h4_d64_kt11_ky11_kx11",
196
+ "solution": "natten_blackwell_h4_11x11x11",
197
+ "workloads": 9,
198
+ "status": "passed",
199
+ "main_source_sha256": "c85ab6b43433432b5371920884c95ae14aeef6ead1354d4e60f7080195d0136f",
200
+ "source_bundle_sha256": "ee62e513b334c9e6dd2cf33cba16b1a615d52c2a5b619d0cf89c19a047b47a95",
201
+ "runs": [
202
+ "na-all"
203
+ ]
204
+ },
205
+ {
206
+ "definition": "neighborhood_attention_3d_h8_d64_kt3_ky5_kx5",
207
+ "solution": "natten_blackwell_h8_3x5x5",
208
+ "workloads": 18,
209
+ "status": "passed",
210
+ "main_source_sha256": "21d8e807c408bb8a5027ab6154e83bfb2ba06591f13b3cc8c454cc50000c937c",
211
+ "source_bundle_sha256": "161df7053b7218c4cadbb657165152edd38a897efa768c64a51332c0ee97c06f",
212
+ "runs": [
213
+ "na-all"
214
+ ]
215
+ },
216
+ {
217
+ "definition": "qsa_index_topk_decode_qwen38_h4_d128_topk512_c4",
218
+ "solution": "sglang_tilelang_index",
219
+ "workloads": 192,
220
+ "status": "passed",
221
+ "main_source_sha256": "ab3dd97e9595fbcb16e57423b8bac278f46dcb2b30472cdcf0d40f72c3e81561",
222
+ "source_bundle_sha256": "ab7d4df3cdefdaf1dc506f714ce3146c85927b8f58bbe3e964be15b7af8a6098",
223
+ "runs": [
224
+ "qsa-index-final-all"
225
+ ]
226
+ },
227
+ {
228
+ "definition": "qsa_sparse_gqa_decode_qwen38_h24_kv2_d256_topk512_c4",
229
+ "solution": "trtllm_sparse_gqa",
230
+ "workloads": 192,
231
+ "status": "passed",
232
+ "main_source_sha256": "517707b2c5fbf0e2eca4d038ff27704187ed97d3ff989e0270c887d8727200fc",
233
+ "source_bundle_sha256": "94954a8fc35eb4f5afa451ddb19f7eea4666d6d490d2ef43c95798ab12dbeddc",
234
+ "runs": [
235
+ "qsa-attention-native-all"
236
+ ]
237
+ },
238
+ {
239
+ "definition": "sparse_mla_prefill_h64_d512_k128",
240
+ "solution": "flashmla_prefill_k128",
241
+ "workloads": 10,
242
+ "status": "passed",
243
+ "main_source_sha256": "a4b0d38ef8c7f9c663d42dbb7423252c16052b0ad27ea390edd7c63bb9c71114",
244
+ "source_bundle_sha256": "bd8060d017ae6f67ab1e8f5ce6537b43b93827c612961fa0345dbfd5d4447904",
245
+ "runs": [
246
+ "mla-cu133-all"
247
+ ]
248
+ },
249
+ {
250
+ "definition": "sparse_mla_prefill_h64_d512_k640",
251
+ "solution": "flashmla_prefill_k640",
252
+ "workloads": 20,
253
+ "status": "passed",
254
+ "main_source_sha256": "a4b0d38ef8c7f9c663d42dbb7423252c16052b0ad27ea390edd7c63bb9c71114",
255
+ "source_bundle_sha256": "bd8060d017ae6f67ab1e8f5ce6537b43b93827c612961fa0345dbfd5d4447904",
256
+ "runs": [
257
+ "mla-cu133-all"
258
+ ]
259
+ }
260
+ ],
261
+ "comparisons": [
262
+ {
263
+ "comparison": "B300 GEMM large-M native-linear dispatch versus DeepGEMM-only",
264
+ "new_run": "dense-n12288-final-all",
265
+ "new_solution": "deepgemm_bf16_n12288_k4096",
266
+ "old_run": "gemm-all",
267
+ "old_solution": "deepgemm_bf16_n12288_k4096",
268
+ "paired_workloads": 31,
269
+ "method": "prepared launch where available; CUDA graph, iters calls per replay",
270
+ "geometric_mean_speedup": 0.44233388346472824,
271
+ "range": [
272
+ 0.41260917322780855,
273
+ 0.5396676753908549
274
+ ],
275
+ "faster_workloads": 0
276
+ },
277
+ {
278
+ "comparison": "Audio final versus original FP16-conversion solution",
279
+ "new_run": "attention-final-contracts",
280
+ "new_solution": "fa4_noncausal_h32_d64",
281
+ "old_run": "attention-all",
282
+ "old_solution": "fa4_noncausal_h32_d64",
283
+ "paired_workloads": 108,
284
+ "method": "prepared launch where available; CUDA graph, iters calls per replay",
285
+ "geometric_mean_speedup": 4.03364484223459,
286
+ "range": [
287
+ 2.590577260426724,
288
+ 7.552192866046962
289
+ ],
290
+ "faster_workloads": 108
291
+ },
292
+ {
293
+ "comparison": "Current fused router versus original CUTLASS/torch solution",
294
+ "new_run": "router-latest-all",
295
+ "new_solution": "fused_router",
296
+ "old_run": "router-alternatives-all",
297
+ "old_solution": "cutlass_router",
298
+ "paired_workloads": 50,
299
+ "method": "prepared launch where available; CUDA graph, iters calls per replay",
300
+ "geometric_mean_speedup": 4.99596423102129,
301
+ "range": [
302
+ 2.119331801220748,
303
+ 17.49934384645274
304
+ ],
305
+ "faster_workloads": 50
306
+ },
307
+ {
308
+ "comparison": "Cached-prefix FA4 versus serving implementation adapter",
309
+ "new_run": "attention-final-contracts",
310
+ "new_solution": "fa4_prefix_h32_d128",
311
+ "old_run": "attention-all",
312
+ "old_solution": "sglang_prefix_cached_block_causal_h32_d128",
313
+ "paired_workloads": 28,
314
+ "method": "prepared launch where available; CUDA graph, iters calls per replay",
315
+ "geometric_mean_speedup": 3.80843131648756,
316
+ "range": [
317
+ 3.659472837569554,
318
+ 4.082322533722384
319
+ ],
320
+ "faster_workloads": 28
321
+ },
322
+ {
323
+ "comparison": "QSA index final versus original on its declared TileLang 0.1.15",
324
+ "new_run": "qsa-index-final-all",
325
+ "new_solution": "sglang_tilelang_index",
326
+ "old_run": "qsa-original-declared-015-dev-timing",
327
+ "old_solution": "main",
328
+ "paired_workloads": 10,
329
+ "method": "prepared launch where available; CUDA graph, iters calls per replay",
330
+ "geometric_mean_speedup": 2.2821630132329918,
331
+ "range": [
332
+ 1.2873084348823565,
333
+ 11.095388935436509
334
+ ],
335
+ "faster_workloads": 10
336
+ },
337
+ {
338
+ "comparison": "Native paged sparse GQA versus FA4 sparse gather",
339
+ "new_run": "qsa-attention-native-all",
340
+ "new_solution": "trtllm_sparse_gqa",
341
+ "old_run": "gemm-qsa-dev",
342
+ "old_solution": "fa4_sparse_gqa",
343
+ "paired_workloads": 10,
344
+ "method": "prepared launch where available; CUDA graph, iters calls per replay",
345
+ "geometric_mean_speedup": 1.900678441525543,
346
+ "range": [
347
+ 1.4198588236687533,
348
+ 2.403390206583776
349
+ ],
350
+ "faster_workloads": 10
351
+ },
352
+ {
353
+ "comparison": "FlashMLA CUDA 13.3 versus CUDA 13.1 compiler build",
354
+ "new_run": "mla-cu133-all",
355
+ "new_solution": "flashmla_prefill_k128",
356
+ "old_run": "mla-all",
357
+ "old_solution": "flashmla_prefill_k128",
358
+ "paired_workloads": 10,
359
+ "method": "prepared launch where available; CUDA graph, iters calls per replay",
360
+ "geometric_mean_speedup": 1.005949932930726,
361
+ "range": [
362
+ 0.9976997846493691,
363
+ 1.012003306272232
364
+ ],
365
+ "faster_workloads": 8
366
+ },
367
+ {
368
+ "comparison": "FlashMLA CUDA 13.3 versus CUDA 13.1 compiler build",
369
+ "new_run": "mla-cu133-all",
370
+ "new_solution": "flashmla_prefill_k640",
371
+ "old_run": "mla-all",
372
+ "old_solution": "flashmla_prefill_k640",
373
+ "paired_workloads": 20,
374
+ "method": "prepared launch where available; CUDA graph, iters calls per replay",
375
+ "geometric_mean_speedup": 1.0059326934459807,
376
+ "range": [
377
+ 0.9992565830555092,
378
+ 1.0361743300418496
379
+ ],
380
+ "faster_workloads": 19
381
+ },
382
+ {
383
+ "comparison": "FlashMLA CUDA 13.3 versus CUDA 13.1 compiler build",
384
+ "new_run": "mla-cu133-all",
385
+ "new_solution": "flashmla_v41",
386
+ "old_run": "mla-all",
387
+ "old_solution": "flashmla_v41",
388
+ "paired_workloads": 42,
389
+ "method": "prepared launch where available; CUDA graph, iters calls per replay",
390
+ "geometric_mean_speedup": 1.0325320877320159,
391
+ "range": [
392
+ 1.0117352165524782,
393
+ 1.0690543144366038
394
+ ],
395
+ "faster_workloads": 42
396
+ }
397
+ ],
398
+ "strict_gdn_diagnostic": {
399
+ "reference_unchanged": true,
400
+ "acceptance_unchanged": true,
401
+ "modern_six_token_new_state_max_abs_error": 0.0012151896953582764,
402
+ "modern_six_token_failing_elements": 3909,
403
+ "elements": 131072,
404
+ "rtol": 0.0001,
405
+ "atol": 2e-05,
406
+ "prefill_dev_strict_failures": 10,
407
+ "prefill_dev_checked": 10
408
+ },
409
+ "known_diagnostic_failures": {
410
+ "old_qsa_on_undeclared_tilelang_0_1_12": 45,
411
+ "old_qsa_on_declared_tilelang_0_1_15": 0,
412
+ "explanation": "The old custom scorer is dependency-sensitive, not proven incorrect in its declared environment. Final current scorer passes all 192 on SGLang-required 0.1.12."
413
+ },
414
+ "run_counts": {
415
+ "dense-n12288-final-all": {
416
+ "environment": 1,
417
+ "passed": 31
418
+ },
419
+ "gdn-all-counted": {
420
+ "environment": 1,
421
+ "passed": 154
422
+ },
423
+ "attention-all": {
424
+ "environment": 1,
425
+ "passed": 404
426
+ },
427
+ "attention-final-contracts": {
428
+ "environment": 1,
429
+ "passed": 136
430
+ },
431
+ "router-alternatives-all": {
432
+ "environment": 1,
433
+ "passed": 150
434
+ },
435
+ "router-latest-all": {
436
+ "environment": 1,
437
+ "passed": 50
438
+ },
439
+ "qsa-index-all": {
440
+ "environment": 1,
441
+ "passed": 339,
442
+ "failed": 45
443
+ },
444
+ "qsa-original-declared-015-all": {
445
+ "environment": 1,
446
+ "passed": 192
447
+ },
448
+ "qsa-original-declared-015-dev-timing": {
449
+ "environment": 1,
450
+ "passed": 10
451
+ },
452
+ "qsa-index-final-all": {
453
+ "environment": 1,
454
+ "passed": 192
455
+ },
456
+ "qsa-attention-native-all": {
457
+ "environment": 1,
458
+ "passed": 192
459
+ },
460
+ "gemm-qsa-dev": {
461
+ "environment": 1,
462
+ "passed": 100
463
+ },
464
+ "gemm-all": {
465
+ "environment": 1,
466
+ "passed": 394
467
+ },
468
+ "na-all": {
469
+ "environment": 1,
470
+ "passed": 90
471
+ },
472
+ "mla-all": {
473
+ "environment": 1,
474
+ "passed": 144
475
+ },
476
+ "mla-cu133-all": {
477
+ "environment": 1,
478
+ "passed": 72
479
+ },
480
+ "gdn-stable-dev-timing": {
481
+ "environment": 1,
482
+ "passed": 17
483
+ },
484
+ "gdn-prefill-current-dev": {
485
+ "environment": 1,
486
+ "passed": 20
487
+ },
488
+ "native-builder-gdn-first": {
489
+ "environment": 1,
490
+ "passed": 2
491
+ }
492
+ }
493
+ }
docs/interface-audit/upstream-head-recheck.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "checked_at": "2026-10-19T11:43:24.213060+00:00",
3
+ "repositories": [
4
+ {
5
+ "repository": "sgl-project/sglang",
6
+ "audited_commit": "0025f9394421451aa09ec192a4a6e7928e14736b",
7
+ "current_commit": "ed0b8f433f887995b1ce361b15aaf9f6ca93483f",
8
+ "unchanged": false
9
+ },
10
+ {
11
+ "repository": "flashinfer-ai/flashinfer",
12
+ "audited_commit": "f64b4ba8762ded12a4f4b9a2092974c9a395e7ca",
13
+ "current_commit": "f64b4ba8762ded12a4f4b9a2092974c9a395e7ca",
14
+ "unchanged": true
15
+ },
16
+ {
17
+ "repository": "Dao-AILab/flash-attention",
18
+ "audited_commit": "e7a6402a9ff099de5eb628ce207a88a3f0aa5378",
19
+ "current_commit": "e7a6402a9ff099de5eb628ce207a88a3f0aa5378",
20
+ "unchanged": true
21
+ },
22
+ {
23
+ "repository": "deepseek-ai/DeepGEMM",
24
+ "audited_commit": "1fc9c66975ee322d628b3288534ca0e9ce12a64d",
25
+ "current_commit": "1fc9c66975ee322d628b3288534ca0e9ce12a64d",
26
+ "unchanged": true
27
+ },
28
+ {
29
+ "repository": "deepseek-ai/FlashMLA",
30
+ "audited_commit": "0f11e178da1f67becb087a324b400854931ec3e3",
31
+ "current_commit": "0f11e178da1f67becb087a324b400854931ec3e3",
32
+ "unchanged": true
33
+ },
34
+ {
35
+ "repository": "SHI-Labs/NATTEN",
36
+ "audited_commit": "39375ea1d2f3b1bb284315fa5f79f6ecbebb6382",
37
+ "current_commit": "39375ea1d2f3b1bb284315fa5f79f6ecbebb6382",
38
+ "unchanged": true
39
+ }
40
+ ]
41
+ }
docs/interface-audit/upstreams.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "repositories": [
3
+ {
4
+ "repository": "sgl-project/sglang",
5
+ "commit": "0025f9394421451aa09ec192a4a6e7928e14736b",
6
+ "date": "2026-10-19T10:24:17Z",
7
+ "title": "[Fix] sgl-router: Refuse prefill workers that cannot compute before bootstrap under --decode-dispatch-limit (#45120)",
8
+ "latest_release": {
9
+ "tag": "v0.5.22",
10
+ "date": "2026-10-19T02:55:19Z",
11
+ "url": "https://github.com/sgl-project/sglang/releases/tag/v0.5.22"
12
+ }
13
+ },
14
+ {
15
+ "repository": "flashinfer-ai/flashinfer",
16
+ "commit": "f64b4ba8762ded12a4f4b9a2092974c9a395e7ca",
17
+ "date": "2026-10-19T10:50:33Z",
18
+ "title": "perf(cake_all_gather_matmul): SM103a CTA-pair main kernel for two measured gate/up shapes (region table with column ranges) (#6566)",
19
+ "latest_release": {
20
+ "tag": "v0.7.2",
21
+ "date": "2026-10-15T20:36:26Z",
22
+ "url": "https://github.com/flashinfer-ai/flashinfer/releases/tag/v0.7.2"
23
+ }
24
+ },
25
+ {
26
+ "repository": "Dao-AILab/flash-attention",
27
+ "commit": "e7a6402a9ff099de5eb628ce207a88a3f0aa5378",
28
+ "date": "2026-10-19T02:35:33Z",
29
+ "title": "[CuTe] Add typed forward configurations (#2732)",
30
+ "latest_release": {
31
+ "tag": "v2.8.3.post2",
32
+ "date": "2026-10-13T05:41:17Z",
33
+ "url": "https://github.com/Dao-AILab/flash-attention/releases/tag/v2.8.3.post2"
34
+ }
35
+ },
36
+ {
37
+ "repository": "deepseek-ai/DeepGEMM",
38
+ "commit": "1fc9c66975ee322d628b3288534ca0e9ce12a64d",
39
+ "date": "2026-10-14T05:35:55Z",
40
+ "title": "Update FP8 epilogues and paged sparse MQA alignment (#471)",
41
+ "latest_release": {
42
+ "tag": "v2.1.1.post3",
43
+ "date": "2025-10-15T14:30:54Z",
44
+ "url": "https://github.com/deepseek-ai/DeepGEMM/releases/tag/v2.1.1.post3"
45
+ }
46
+ },
47
+ {
48
+ "repository": "deepseek-ai/FlashMLA",
49
+ "commit": "0f11e178da1f67becb087a324b400854931ec3e3",
50
+ "date": "2026-10-15T13:47:29Z",
51
+ "title": "Make FlashMLA CPython and LibTorch ABI stable (#230)"
52
+ },
53
+ {
54
+ "repository": "SHI-Labs/NATTEN",
55
+ "commit": "39375ea1d2f3b1bb284315fa5f79f6ecbebb6382",
56
+ "date": "2026-07-26T18:07:00Z",
57
+ "title": "0.21.7 release (#344)",
58
+ "latest_release": {
59
+ "tag": "v0.21.7",
60
+ "date": "2026-07-26T18:35:17Z",
61
+ "url": "https://github.com/SHI-Labs/NATTEN/releases/tag/v0.21.7"
62
+ }
63
+ }
64
+ ],
65
+ "packages": {
66
+ "flash-attn-4": {
67
+ "latest": "4.0.0b35",
68
+ "project_urls": {
69
+ "Homepage": "https://github.com/Dao-AILab/flash-attention",
70
+ "Repository": "https://github.com/Dao-AILab/flash-attention"
71
+ }
72
+ },
73
+ "flashinfer-python": {
74
+ "latest": "0.7.2",
75
+ "project_urls": {
76
+ "Homepage": "https://github.com/flashinfer-ai/flashinfer"
77
+ }
78
+ },
79
+ "nvidia-cutlass-dsl": {
80
+ "latest": "4.8.1",
81
+ "project_urls": {
82
+ "Documentation": "https://github.com/NVIDIA/cutlass",
83
+ "Issues": "https://github.com/NVIDIA/cutlass/issues",
84
+ "License": "https://docs.nvidia.com/cutlass/latest/media/docs/pythonDSL/license.html",
85
+ "Repository": "https://github.com/NVIDIA/cutlass"
86
+ }
87
+ },
88
+ "quack-kernels": {
89
+ "latest": "0.6.5",
90
+ "project_urls": null
91
+ },
92
+ "natten": {
93
+ "latest": "0.21.7",
94
+ "project_urls": {
95
+ "Changelog": "https://github.com/SHI-Labs/NATTEN/blob/main/CHANGELOG.md",
96
+ "Documentation": "https://natten.org",
97
+ "Homepage": "https://natten.org",
98
+ "Repository": "https://github.com/SHI-Labs/NATTEN.git"
99
+ }
100
+ },
101
+ "torch": {
102
+ "latest": "2.14.1",
103
+ "project_urls": {
104
+ "Documentation": "https://pytorch.org/docs",
105
+ "Forum": "https://discuss.pytorch.org",
106
+ "Homepage": "https://pytorch.org",
107
+ "Issue Tracker": "https://github.com/pytorch/pytorch/issues",
108
+ "Repository": "https://github.com/pytorch/pytorch"
109
+ }
110
+ }
111
+ }
112
+ }
scripts/audit_solutions.py ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Validate and time actual solutions against independent task references."""
2
+
3
+ import argparse
4
+ import contextlib
5
+ import fcntl
6
+ import hashlib
7
+ import importlib.util
8
+ import json
9
+ import os
10
+ from pathlib import Path
11
+ import statistics
12
+ import sys
13
+ import time
14
+ import traceback
15
+
16
+ from task_acceptance import compare_output
17
+
18
+ parser = argparse.ArgumentParser(description=__doc__)
19
+ parser.add_argument("--root", type=Path, default=Path(__file__).resolve().parents[1])
20
+ parser.add_argument(
21
+ "--data-root", type=Path, help="Optional materialized dataset with the same paths"
22
+ )
23
+ parser.add_argument("--lock-directory", type=Path, required=True)
24
+ parser.add_argument(
25
+ "--cache-directory", type=Path, help="Writable module and reference cache"
26
+ )
27
+ parser.add_argument("--definition", action="append")
28
+ parser.add_argument("--suite", choices=["first", "dev", "all"], default="first")
29
+ parser.add_argument("--only-default", action="store_true")
30
+ parser.add_argument("--report", required=True, type=Path)
31
+ parser.add_argument("--validation-only", action="store_true")
32
+ parser.add_argument("--scale-probe", action="store_true")
33
+ parser.add_argument("--gpu", required=True)
34
+ parser.add_argument("--workload", action="append")
35
+ parser.add_argument("--solution", action="append")
36
+ parser.add_argument(
37
+ "--candidate",
38
+ action="append",
39
+ default=[],
40
+ help="Extra run() module for comparing a candidate on one selected definition",
41
+ )
42
+ parser.add_argument("--reference-cache", action="store_true")
43
+ parser.add_argument("--graph-timing", action="store_true")
44
+ parser.add_argument(
45
+ "--strict-diagnostic",
46
+ action="store_true",
47
+ help="Also report the historical FP32 bound for GDN; does not affect task acceptance",
48
+ )
49
+ args = parser.parse_args()
50
+ SOURCE = args.root.resolve()
51
+ DATA = args.data_root.resolve() if args.data_root else SOURCE
52
+ CACHE = (
53
+ args.cache_directory.resolve()
54
+ if args.cache_directory
55
+ else SOURCE / "results/audit-cache"
56
+ )
57
+ GPU = args.gpu
58
+ LOCKS = args.lock_directory
59
+ LOCKS.mkdir(exist_ok=True, parents=True)
60
+ os.environ["CUDA_VISIBLE_DEVICES"] = GPU
61
+ stack = contextlib.ExitStack()
62
+ for suffix in ["", ".lock"]:
63
+ handle = stack.enter_context((LOCKS / (GPU + suffix)).open("a+"))
64
+ fcntl.flock(handle.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
65
+
66
+ import torch
67
+ from safetensors.torch import load_file
68
+
69
+ torch.set_num_threads(8)
70
+ torch.backends.cuda.matmul.allow_tf32 = False
71
+ torch._inductor.config.compile_threads = 1
72
+
73
+
74
+ def load_function(name, path):
75
+ identifier = "_audit_" + hashlib.sha256(name.encode()).hexdigest()[:20]
76
+ package = path.parent
77
+ spec = importlib.util.spec_from_file_location(
78
+ identifier, package / "__init__.py", submodule_search_locations=[str(package)]
79
+ )
80
+ if path.name != "main.py":
81
+ spec = importlib.util.spec_from_file_location(identifier, path)
82
+ module = importlib.util.module_from_spec(spec)
83
+ sys.modules[identifier] = module
84
+ spec.loader.exec_module(module)
85
+ if path.name == "main.py":
86
+ spec = importlib.util.spec_from_file_location(identifier + ".main", path)
87
+ child = importlib.util.module_from_spec(spec)
88
+ sys.modules[spec.name] = child
89
+ spec.loader.exec_module(child)
90
+ module = child
91
+ return module.run, getattr(module, "prepare", None)
92
+
93
+
94
+ def normalize(result, definition):
95
+ return (
96
+ list(result.values())
97
+ if isinstance(result, dict)
98
+ else list(result)
99
+ if isinstance(result, (tuple, list))
100
+ else [result]
101
+ )
102
+
103
+
104
+ def compare(actual, expected, definition, config):
105
+ values = normalize(actual, definition)
106
+ assert len(values) == len(expected)
107
+ metrics = {}
108
+ for name, value, reference in zip(definition["outputs"], values, expected):
109
+ metrics[name] = compare_output(value, reference, config["tolerance"])
110
+ return metrics
111
+
112
+
113
+ def measure(function, inputs, timing):
114
+ for _ in range(timing["warmup"]):
115
+ _result = function(*inputs)
116
+ torch.cuda.synchronize()
117
+ samples = []
118
+ for _ in range(timing["iters"] * timing["trials"]):
119
+ start = torch.cuda.Event(enable_timing=True)
120
+ end = torch.cuda.Event(enable_timing=True)
121
+ start.record()
122
+ _result = function(*inputs)
123
+ end.record()
124
+ end.synchronize()
125
+ samples.append(start.elapsed_time(end) * 1000)
126
+ return {
127
+ "median_us": statistics.median(samples),
128
+ "samples_us": samples,
129
+ "method": "CUDA events over eager calls",
130
+ }
131
+
132
+
133
+ def measure_graph(function, inputs, timing, definition, config, expected):
134
+ for _ in range(max(3, timing["warmup"])):
135
+ result = function(*inputs)
136
+ torch.cuda.synchronize()
137
+ graph = torch.cuda.CUDAGraph()
138
+ with torch.cuda.graph(graph):
139
+ for _ in range(timing["iters"]):
140
+ result = function(*inputs)
141
+ graph.replay()
142
+ torch.cuda.synchronize()
143
+ compare(result, expected, definition, config)
144
+ samples = []
145
+ for _ in range(timing["trials"]):
146
+ start = torch.cuda.Event(enable_timing=True)
147
+ end = torch.cuda.Event(enable_timing=True)
148
+ start.record()
149
+ graph.replay()
150
+ end.record()
151
+ end.synchronize()
152
+ samples.append(start.elapsed_time(end) * 1000 / timing["iters"])
153
+ return {
154
+ "median_us": statistics.median(samples),
155
+ "samples_us": samples,
156
+ "method": "CUDA graph, iters calls per replay",
157
+ "calls_per_replay": timing["iters"],
158
+ }
159
+
160
+
161
+ definitions = {
162
+ json.loads(f.read_text())["name"]: json.loads(f.read_text())
163
+ for f in (SOURCE / "definitions").rglob("*.json")
164
+ }
165
+ solutions = {}
166
+ for f in (SOURCE / "solutions").rglob("*.json"):
167
+ s = json.loads(f.read_text())
168
+ solutions.setdefault(s["definition"], []).append(s)
169
+ rows_by_name = {
170
+ f.stem: [json.loads(l)["workload"] for l in f.read_text().splitlines()]
171
+ for f in (SOURCE / "workloads").rglob("*.jsonl")
172
+ }
173
+ args.report.parent.mkdir(exist_ok=True, parents=True)
174
+ failures = 0
175
+ with args.report.open("w") as report, torch.inference_mode():
176
+
177
+ def emit(row):
178
+ report.write(json.dumps(row) + "\n")
179
+ report.flush()
180
+
181
+ emit(
182
+ {
183
+ "type": "environment",
184
+ "gpu": torch.cuda.get_device_name(),
185
+ "torch": torch.__version__,
186
+ "suite": args.suite,
187
+ "pythonpath": os.environ.get("PYTHONPATH"),
188
+ "started_at": time.time(),
189
+ }
190
+ )
191
+ for name, definition in definitions.items():
192
+ if args.definition and name not in args.definition:
193
+ continue
194
+ config = json.loads((SOURCE / "tasks" / f"{name}.json").read_text())
195
+ rows = rows_by_name[name]
196
+ if args.suite == "dev":
197
+ rows = [row for row in rows if row["uuid"] in config["dev"]]
198
+ if args.suite == "first":
199
+ rows = rows[:1]
200
+ if args.workload:
201
+ rows = [row for row in rows if row["uuid"] in args.workload]
202
+ candidates = []
203
+ for solution in solutions[name]:
204
+ if args.only_default and solution["name"] == "sglang_" + name:
205
+ continue
206
+ digest = hashlib.sha256(
207
+ json.dumps(solution, sort_keys=True).encode()
208
+ ).hexdigest()
209
+ package = CACHE / "modules" / digest
210
+ for source in solution["sources"]:
211
+ target = package / source["path"]
212
+ if not target.resolve().is_relative_to(package.resolve()):
213
+ raise ValueError("Source path escapes package")
214
+ target.parent.mkdir(parents=True, exist_ok=True)
215
+ target.write_text(source["content"])
216
+ (package / "__init__.py").touch()
217
+ entry = solution["spec"]["entry_point"].split("::")[0]
218
+ candidates.append((solution["name"], package / entry))
219
+ if args.candidate:
220
+ assert args.definition and len(args.definition) == 1
221
+ candidates.extend((Path(p).stem, Path(p)) for p in args.candidate)
222
+ if args.solution:
223
+ candidates = [(s, p) for s, p in candidates if s in args.solution]
224
+ ns = {}
225
+ exec(definition["reference"], ns)
226
+ reference = ns["run"]
227
+ for solution, path in candidates:
228
+ try:
229
+ function, prepare = load_function(solution, path)
230
+ except Exception:
231
+ failures += 1
232
+ emit(
233
+ {
234
+ "type": "load",
235
+ "definition": name,
236
+ "solution": solution,
237
+ "status": "failed",
238
+ "error": traceback.format_exc(),
239
+ }
240
+ )
241
+ print("LOAD FAILED", name, solution, flush=True)
242
+ continue
243
+ for row in rows:
244
+ inputs = []
245
+ saved = []
246
+ expected = []
247
+ result = {
248
+ "type": "workload",
249
+ "definition": name,
250
+ "solution": solution,
251
+ "uuid": row["uuid"],
252
+ "axes": row["axes"],
253
+ "solution_sha256": hashlib.sha256(path.read_bytes()).hexdigest(),
254
+ "definition_sha256": hashlib.sha256(
255
+ json.dumps(definition, sort_keys=True).encode()
256
+ ).hexdigest(),
257
+ "task_sha256": hashlib.sha256(
258
+ json.dumps(config, sort_keys=True).encode()
259
+ ).hexdigest(),
260
+ }
261
+ try:
262
+ for key in definition["inputs"]:
263
+ desc = row["inputs"][key]
264
+ value = (
265
+ desc["value"]
266
+ if desc["type"] == "scalar"
267
+ else load_file(str(DATA / desc["path"]), device="cuda")[
268
+ desc["tensor_key"]
269
+ ]
270
+ )
271
+ inputs.append(value)
272
+ saved.append(
273
+ value.clone() if isinstance(value, torch.Tensor) else value
274
+ )
275
+ cache_key = hashlib.sha256(
276
+ json.dumps(
277
+ {
278
+ "reference": definition["reference"],
279
+ "row": row,
280
+ "torch": torch.__version__,
281
+ },
282
+ sort_keys=True,
283
+ ).encode()
284
+ ).hexdigest()
285
+ cache = CACHE / "references" / (cache_key + ".pt")
286
+ if args.reference_cache and cache.exists():
287
+ expected = [
288
+ value.to("cuda")
289
+ for value in torch.load(cache, weights_only=True)
290
+ ]
291
+ else:
292
+ expected = [
293
+ value.clone()
294
+ for value in normalize(reference(*inputs), definition)
295
+ ]
296
+ if args.reference_cache:
297
+ cache.parent.mkdir(exist_ok=True, parents=True)
298
+ torch.save([value.cpu() for value in expected], cache)
299
+ actual_result = function(*inputs)
300
+ result["errors"] = compare(
301
+ actual_result, expected, definition, config
302
+ )
303
+ if args.strict_diagnostic and name.startswith("gdn_"):
304
+ result["strict_fp32_diagnostic"] = {}
305
+ for key, value, target in zip(
306
+ definition["outputs"],
307
+ normalize(actual_result, definition),
308
+ expected,
309
+ ):
310
+ if value.dtype == torch.float32:
311
+ close = torch.isclose(
312
+ value, target, rtol=1e-4, atol=2e-5
313
+ )
314
+ result["strict_fp32_diagnostic"][key] = {
315
+ "rtol": 1e-4,
316
+ "atol": 2e-5,
317
+ "mismatched_elements": int((~close).sum()),
318
+ "elements": close.numel(),
319
+ "passes": bool(close.all()),
320
+ }
321
+ for key, value, original in zip(
322
+ definition["inputs"], inputs, saved
323
+ ):
324
+ if isinstance(value, torch.Tensor):
325
+ assert torch.equal(
326
+ value.contiguous().view(torch.uint8),
327
+ original.contiguous().view(torch.uint8),
328
+ ), key + " input mutated"
329
+ if args.scale_probe and "scale" in definition["inputs"]:
330
+ index = list(definition["inputs"]).index("scale")
331
+ original = inputs[index]
332
+ inputs[index] = (
333
+ definition["axes"]["head_size"]["value"] ** -0.5
334
+ if original is None or original == 0
335
+ else original
336
+ ) * 0.5
337
+ target = [
338
+ value.clone()
339
+ for value in normalize(reference(*inputs), definition)
340
+ ]
341
+ result["scale_probe"] = compare(
342
+ function(*inputs), target, definition, config
343
+ )
344
+ inputs[index] = original
345
+ if not args.validation_only:
346
+ result["run_timing"] = measure(
347
+ function, inputs, config["timing"]
348
+ )
349
+ if prepare:
350
+ launch = prepare(*inputs)
351
+ result["prepared_timing"] = measure(
352
+ lambda *unused: launch(), inputs, config["timing"]
353
+ )
354
+ if args.graph_timing:
355
+ try:
356
+ launch_function = (
357
+ (lambda *unused: launch()) if prepare else function
358
+ )
359
+ result["graph_timing"] = measure_graph(
360
+ launch_function,
361
+ inputs,
362
+ config["timing"],
363
+ definition,
364
+ config,
365
+ expected,
366
+ )
367
+ except Exception:
368
+ result["graph_error"] = traceback.format_exc()
369
+ for key, value, original in zip(
370
+ definition["inputs"], inputs, saved
371
+ ):
372
+ if isinstance(value, torch.Tensor):
373
+ assert torch.equal(
374
+ value.contiguous().view(torch.uint8),
375
+ original.contiguous().view(torch.uint8),
376
+ ), key + " input mutated during timing"
377
+ result["inputs_unchanged"] = True
378
+ result["status"] = "passed"
379
+ except Exception:
380
+ failures += 1
381
+ result.update(status="failed", error=traceback.format_exc())
382
+ emit(result)
383
+ print(
384
+ result["status"],
385
+ name,
386
+ solution,
387
+ row["axes"],
388
+ result.get("run_timing", {}).get("median_us"),
389
+ flush=True,
390
+ )
391
+ inputs = saved = expected = actual_result = None
392
+ function = prepare = None
393
+
394
+ if failures:
395
+ raise SystemExit(f"{failures} failed cases; see {args.report}")
scripts/benchmark_solutions.py CHANGED
@@ -10,6 +10,8 @@ import statistics
10
  import time
11
  import traceback
12
 
 
 
13
 
14
  def main():
15
  parser = argparse.ArgumentParser(description=__doc__)
@@ -85,30 +87,8 @@ def main():
85
  return load_file(str(data_root / descriptor["path"]), device="cuda")[descriptor["tensor_key"]]
86
 
87
  def compare(actual, expected, definition, output_name):
88
- if actual.shape != expected.shape or actual.dtype != expected.dtype:
89
- raise AssertionError(f"{output_name}: output shape or dtype differs")
90
- if not actual.is_floating_point():
91
- torch.testing.assert_close(actual, expected, rtol=0, atol=0)
92
- return {"comparison": "exact"}
93
- if not torch.isfinite(actual).all() or not torch.isfinite(expected).all():
94
- raise AssertionError(f"{output_name}: nonfinite output")
95
- difference = actual.float() - expected.float()
96
- metrics = {"max_absolute_error": difference.abs().max().item() if actual.numel() else 0.0}
97
- if definition.startswith("gated_delta_rule_prefill_") and output_name == "S_final":
98
- metrics.update(
99
- relative_rms=(difference.norm() / expected.norm().clamp_min(1e-12)).item(),
100
- relative_max=(difference.abs().max() / expected.abs().max().clamp_min(1e-12)).item(),
101
- max_head_relative_rms=(difference.norm(dim=(-2, -1)) /
102
- expected.norm(dim=(-2, -1)).clamp_min(1e-12)).max().item(),
103
- )
104
- for key, bound in {"relative_rms": .01, "relative_max": .015,
105
- "max_head_relative_rms": .02}.items():
106
- if metrics[key] > bound:
107
- raise AssertionError(f"{output_name}: {key}={metrics[key]} > {bound}")
108
- else:
109
- rtol, atol = (.016, .005) if actual.dtype == torch.bfloat16 else (1e-4, 2e-5)
110
- torch.testing.assert_close(actual, expected, rtol=rtol, atol=atol)
111
- return metrics
112
 
113
  def measure(function):
114
  for _ in range(3):
@@ -170,8 +150,10 @@ def main():
170
  inputs = [load(workload["inputs"][key]) for key in definition.inputs]
171
  actual = runnable(*inputs)
172
  outputs = list(actual) if isinstance(actual, (tuple, list)) else [actual]
173
- descriptors = receipts[workload["uuid"]]["expected_output"]
174
- if "type" in descriptors:
 
 
175
  descriptors = {next(iter(definition.outputs)): descriptors}
176
  if len(outputs) != len(definition.outputs):
177
  raise AssertionError("Output count differs")
 
10
  import time
11
  import traceback
12
 
13
+ from task_acceptance import compare_output
14
+
15
 
16
  def main():
17
  parser = argparse.ArgumentParser(description=__doc__)
 
87
  return load_file(str(data_root / descriptor["path"]), device="cuda")[descriptor["tensor_key"]]
88
 
89
  def compare(actual, expected, definition, output_name):
90
+ config = json.loads((root / 'tasks' / f'{definition}.json').read_text())
91
+ return compare_output(actual, expected, config['tolerance'])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
 
93
  def measure(function):
94
  for _ in range(3):
 
150
  inputs = [load(workload["inputs"][key]) for key in definition.inputs]
151
  actual = runnable(*inputs)
152
  outputs = list(actual) if isinstance(actual, (tuple, list)) else [actual]
153
+ descriptors = receipts[workload["uuid"]].get("expected_output")
154
+ if reference is None and descriptors is None:
155
+ raise ValueError("This imported workload has no saved engine output; compare to reference")
156
+ if descriptors is not None and "type" in descriptors:
157
  descriptors = {next(iter(definition.outputs)): descriptors}
158
  if len(outputs) != len(definition.outputs):
159
  raise AssertionError("Output count differs")
scripts/capture_inputs.py CHANGED
@@ -138,14 +138,13 @@ def _gemm(a, weight, output, operation):
138
 
139
 
140
  def _block_attention(q, k, v, prefix_length, segments, output, context, operation):
141
- import math
142
  import torch
143
 
144
  name = "prefix_cached_block_causal_h32_d128"
145
  if not prefix_length:
146
  name += "_prefix0"
147
  provenance = _provenance(context, operation, prefix_segments=segments,
148
- adapter="Preserve post-normalization/RoPE tensors; materialize the engine's segment visibility.")
149
  if not _WRITER.wants(name, provenance):
150
  return
151
  image_ids = torch.full((k.shape[1],), -1, dtype=torch.int32, device=q.device)
@@ -156,11 +155,15 @@ def _block_attention(q, k, v, prefix_length, segments, output, context, operatio
156
  next_image += 1
157
  if prefix_length:
158
  image_ids[prefix_length:] = next_image
159
- inputs = dict(Q=q, K_current=k[:, prefix_length:], V_current=v[:, prefix_length:],
160
- K_prefix=k[:, :prefix_length], V_prefix=v[:, :prefix_length],
161
- image_ids=image_ids,
162
- key_valid=torch.ones((q.shape[0], k.shape[1]), dtype=torch.bool, device=q.device),
163
- sm_scale=1 / math.sqrt(q.shape[-1]))
 
 
 
 
164
  _WRITER.write(name, inputs, output, provenance)
165
 
166
 
@@ -340,7 +343,7 @@ def install():
340
  install_deepseek(_WRITER)
341
 
342
 
343
- def replay(dataset_root, device):
344
  """Compare full reference outputs against the captured serving outputs."""
345
  import time
346
  import traceback
@@ -374,6 +377,8 @@ def replay(dataset_root, device):
374
  for line in path.read_text().splitlines():
375
  trace = json.loads(line)
376
  name, workload = trace["definition"], trace["workload"]
 
 
377
  if "expected_output" not in receipts[workload["uuid"]]:
378
  continue # Imported workloads (the MLSys 2026 GDN) have no engine output.
379
  started = time.monotonic()
@@ -488,6 +493,7 @@ def main():
488
  parser.add_argument("--model-path", type=Path)
489
  parser.add_argument("--output-root", type=Path)
490
  parser.add_argument("--replay-root", type=Path)
 
491
  parser.add_argument("--import-capture", type=Path)
492
  parser.add_argument("--device", default="cuda")
493
  parser.add_argument("--port", type=int, default=30000)
@@ -501,7 +507,7 @@ def main():
501
  parser.error("Import requires --output-root")
502
  return import_capture(args.import_capture, args.output_root)
503
  if args.replay_root:
504
- return replay(args.replay_root, args.device)
505
  if args.model_path is None or args.output_root is None:
506
  parser.error("Serving capture requires --model-path and --output-root")
507
  root = args.output_root.resolve()
 
138
 
139
 
140
  def _block_attention(q, k, v, prefix_length, segments, output, context, operation):
 
141
  import torch
142
 
143
  name = "prefix_cached_block_causal_h32_d128"
144
  if not prefix_length:
145
  name += "_prefix0"
146
  provenance = _provenance(context, operation, prefix_segments=segments,
147
+ adapter="Preserve post-normalization/RoPE tensors; specialize fully visible target attention or encode prefix segment visibility.")
148
  if not _WRITER.wants(name, provenance):
149
  return
150
  image_ids = torch.full((k.shape[1],), -1, dtype=torch.int32, device=q.device)
 
155
  next_image += 1
156
  if prefix_length:
157
  image_ids[prefix_length:] = next_image
158
+ if q.shape[-1] != 128:
159
+ raise ValueError("The image attention contract fixes head dimension and scale")
160
+ inputs = dict(Q=q, K_current=k[:, prefix_length:], V_current=v[:, prefix_length:])
161
+ if prefix_length:
162
+ if not bool((image_ids[prefix_length:] == next_image).all()):
163
+ raise ValueError("Target-image attention must expose one fully visible image block")
164
+ inputs.update(K_prefix=k[:, :prefix_length], V_prefix=v[:, :prefix_length])
165
+ else:
166
+ inputs["image_ids"] = image_ids
167
  _WRITER.write(name, inputs, output, provenance)
168
 
169
 
 
343
  install_deepseek(_WRITER)
344
 
345
 
346
+ def replay(dataset_root, device, selected_definitions=None):
347
  """Compare full reference outputs against the captured serving outputs."""
348
  import time
349
  import traceback
 
377
  for line in path.read_text().splitlines():
378
  trace = json.loads(line)
379
  name, workload = trace["definition"], trace["workload"]
380
+ if selected_definitions and name not in selected_definitions:
381
+ continue
382
  if "expected_output" not in receipts[workload["uuid"]]:
383
  continue # Imported workloads (the MLSys 2026 GDN) have no engine output.
384
  started = time.monotonic()
 
493
  parser.add_argument("--model-path", type=Path)
494
  parser.add_argument("--output-root", type=Path)
495
  parser.add_argument("--replay-root", type=Path)
496
+ parser.add_argument("--replay-definition", action="append", help="Replay only these definitions; repeatable")
497
  parser.add_argument("--import-capture", type=Path)
498
  parser.add_argument("--device", default="cuda")
499
  parser.add_argument("--port", type=int, default=30000)
 
507
  parser.error("Import requires --output-root")
508
  return import_capture(args.import_capture, args.output_root)
509
  if args.replay_root:
510
+ return replay(args.replay_root, args.device, args.replay_definition)
511
  if args.model_path is None or args.output_root is None:
512
  parser.error("Serving capture requires --model-path and --output-root")
513
  root = args.output_root.resolve()
scripts/capture_ltx.py CHANGED
@@ -82,7 +82,7 @@ def install(writer):
82
  visible = mask == 0 if mask.is_floating_point() else mask.bool()
83
  if not bool(visible.all()):
84
  raise ValueError("Mask-free attention capture requires an all-visible engine mask")
85
- writer.write(name, dict(Q=q, K=k, V=v, sm_scale=q.shape[-1] ** -0.5),
86
  output.reshape_as(q), provenance)
87
  return output
88
 
 
82
  visible = mask == 0 if mask.is_floating_point() else mask.bool()
83
  if not bool(visible.all()):
84
  raise ValueError("Mask-free attention capture requires an all-visible engine mask")
85
+ writer.write(name, dict(Q=q, K=k, V=v),
86
  output.reshape_as(q), provenance)
87
  return output
88
 
scripts/task_acceptance.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Evaluate one output using the task's explicit, unchanged acceptance policy."""
2
+
3
+
4
+ def compare_output(actual, expected, tolerance):
5
+ import torch
6
+
7
+ if (
8
+ actual.shape != expected.shape
9
+ or actual.dtype != expected.dtype
10
+ or actual.device != expected.device
11
+ ):
12
+ raise AssertionError("Output shape, dtype or device differs")
13
+ if not actual.is_floating_point():
14
+ if not torch.equal(actual, expected):
15
+ raise AssertionError("Integer output differs")
16
+ return {"exact": True}
17
+ if not bool(torch.isfinite(actual).all()) or not bool(
18
+ torch.isfinite(expected).all()
19
+ ):
20
+ raise AssertionError("Nonfinite output")
21
+ error = (actual.float() - expected.float()).abs()
22
+ if tolerance.get("comparison") == "absolute_or_relative":
23
+ close = (error <= tolerance["atol"]) | (
24
+ error / (expected.float().abs() + 1e-8) <= tolerance["rtol"]
25
+ )
26
+ else:
27
+ close = error <= tolerance["atol"] + tolerance["rtol"] * expected.float().abs()
28
+ # Count in integer arithmetic; a floating-point mean can round below 1
29
+ # even when every element passes.
30
+ matched = int(close.sum())
31
+ ratio = matched / close.numel() if close.numel() else 1.0
32
+ required = tolerance.get("required_matched_ratio")
33
+ if ratio < (1.0 if required is None else required):
34
+ raise AssertionError(
35
+ f"Matched {matched}/{close.numel()} output elements ({ratio})"
36
+ )
37
+ return {
38
+ "max_absolute_error": error.max().item() if error.numel() else 0.0,
39
+ "matched_ratio": ratio,
40
+ "mismatched_elements": close.numel() - matched,
41
+ }
solutions/block_causal_attention/fa4_prefix0_h32_d128.json CHANGED
@@ -3,6 +3,25 @@
3
  "definition": "prefix_cached_block_causal_h32_d128_prefix0",
4
  "author": "inference-kernels",
5
  "description": "FlashAttention 4 with causal-or-same-image visibility and runtime key validity. Upstream: https://github.com/Dao-AILab/flash-attention (BSD-3-Clause).",
6
- "spec": {"language": "python", "target_hardware": ["NVIDIA_B200"], "entry_point": "main.py::run", "dependencies": ["torch>=2.11", "flash-attn-4==4.0.0b35", "nvidia-cutlass-dsl[cu13]==4.7.1", "quack-kernels==0.6.5"], "destination_passing_style": false},
7
- "sources": [{"path": "main.py", "content": "import cutlass\nimport cutlass.cute as cute\nfrom flash_attn.cute import utils\nfrom flash_attn.cute.interface import flash_attn_func\n\n@cute.jit\ndef visible(batch, head, m_idx, n_idx, seqlen_info, aux_tensors):\n m = cutlass.min(m_idx[0], seqlen_info.seqlen_q - 1)\n n = cutlass.min(n_idx[0], seqlen_info.seqlen_k - 1)\n image_q = aux_tensors[0][m]\n image_k = aux_tensors[0][n]\n same_image = (image_q >= 0) & (image_q == image_k)\n allowed = ((n_idx[0] <= m_idx[0]) | same_image) & aux_tensors[1][batch[0], n]\n return utils.scalar_to_ssa(allowed, cutlass.Boolean)\n\ndef run(Q, K_current, V_current, K_prefix, V_prefix, image_ids, key_valid, sm_scale):\n return flash_attn_func(Q, K_current, V_current, softmax_scale=sm_scale, mask_mod=visible, aux_tensors=[image_ids, key_valid])[0]\n"}]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
 
3
  "definition": "prefix_cached_block_causal_h32_d128_prefix0",
4
  "author": "inference-kernels",
5
  "description": "FlashAttention 4 with causal-or-same-image visibility and runtime key validity. Upstream: https://github.com/Dao-AILab/flash-attention (BSD-3-Clause).",
6
+ "spec": {
7
+ "language": "python",
8
+ "target_hardware": [
9
+ "NVIDIA_B200",
10
+ "NVIDIA_B300"
11
+ ],
12
+ "entry_point": "main.py::run",
13
+ "dependencies": [
14
+ "torch>=2.11",
15
+ "flash-attn-4==4.0.0b35",
16
+ "nvidia-cutlass-dsl[cu13]==4.8.0",
17
+ "quack-kernels==0.6.5"
18
+ ],
19
+ "destination_passing_style": false
20
+ },
21
+ "sources": [
22
+ {
23
+ "path": "main.py",
24
+ "content": "import cutlass\nimport cutlass.cute as cute\nfrom flash_attn.cute import utils\nfrom flash_attn.cute.interface import flash_attn_func\n\n@cute.jit\ndef visible(batch, head, m_idx, n_idx, seqlen_info, aux_tensors):\n m = cutlass.min(m_idx[0], seqlen_info.seqlen_q - 1)\n n = cutlass.min(n_idx[0], seqlen_info.seqlen_k - 1)\n image_q = aux_tensors[0][m]\n image_k = aux_tensors[0][n]\n same_image = (image_q >= 0) & (image_q == image_k)\n allowed = ((n_idx[0] <= m_idx[0]) | same_image) & (n_idx[0] < seqlen_info.seqlen_k)\n return utils.scalar_to_ssa(allowed, cutlass.Boolean)\n\ndef run(Q, K_current, V_current, image_ids):\n return flash_attn_func(Q, K_current, V_current, softmax_scale=128 ** -0.5, mask_mod=visible, aux_tensors=[image_ids])[0]\n"
25
+ }
26
+ ]
27
  }
solutions/block_causal_attention/fa4_prefix_h32_d128.json CHANGED
@@ -2,7 +2,26 @@
2
  "name": "fa4_prefix_h32_d128",
3
  "definition": "prefix_cached_block_causal_h32_d128",
4
  "author": "inference-kernels",
5
- "description": "FlashAttention 4 with causal-or-same-image visibility and runtime key validity. Prefix concatenation is part of the solution call. Upstream: https://github.com/Dao-AILab/flash-attention (BSD-3-Clause).",
6
- "spec": {"language": "python", "target_hardware": ["NVIDIA_B200"], "entry_point": "main.py::run", "dependencies": ["torch>=2.11", "flash-attn-4==4.0.0b35", "nvidia-cutlass-dsl[cu13]==4.7.1", "quack-kernels==0.6.5"], "destination_passing_style": false},
7
- "sources": [{"path": "main.py", "content": "import torch\nimport cutlass\nimport cutlass.cute as cute\nfrom flash_attn.cute import utils\nfrom flash_attn.cute.interface import flash_attn_func\n\n@cute.jit\ndef visible(batch, head, m_idx, n_idx, seqlen_info, aux_tensors):\n offset = seqlen_info.seqlen_k - seqlen_info.seqlen_q\n m = cutlass.min(m_idx[0] + offset, seqlen_info.seqlen_k - 1)\n n = cutlass.min(n_idx[0], seqlen_info.seqlen_k - 1)\n image_q = aux_tensors[0][m]\n image_k = aux_tensors[0][n]\n same_image = (image_q >= 0) & (image_q == image_k)\n allowed = ((n_idx[0] <= m_idx[0] + offset) | same_image) & aux_tensors[1][batch[0], n]\n return utils.scalar_to_ssa(allowed, cutlass.Boolean)\n\ndef run(Q, K_current, V_current, K_prefix, V_prefix, image_ids, key_valid, sm_scale):\n K = torch.cat((K_prefix, K_current), dim=1) if K_prefix.shape[1] else K_current\n V = torch.cat((V_prefix, V_current), dim=1) if V_prefix.shape[1] else V_current\n return flash_attn_func(Q, K, V, softmax_scale=sm_scale, mask_mod=visible, aux_tensors=[image_ids, key_valid])[0]\n"}]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
 
2
  "name": "fa4_prefix_h32_d128",
3
  "definition": "prefix_cached_block_causal_h32_d128",
4
  "author": "inference-kernels",
5
+ "description": "FlashAttention 4 for the engine target-image call, with its replicated KV prefix. All keys are visible; concatenation is included in run. Upstream: https://github.com/Dao-AILab/flash-attention (BSD-3-Clause).",
6
+ "spec": {
7
+ "language": "python",
8
+ "target_hardware": [
9
+ "NVIDIA_B200",
10
+ "NVIDIA_B300"
11
+ ],
12
+ "entry_point": "main.py::run",
13
+ "dependencies": [
14
+ "torch>=2.11",
15
+ "flash-attn-4==4.0.0b35",
16
+ "nvidia-cutlass-dsl[cu13]==4.8.0",
17
+ "quack-kernels==0.6.5"
18
+ ],
19
+ "destination_passing_style": false
20
+ },
21
+ "sources": [
22
+ {
23
+ "path": "main.py",
24
+ "content": "import torch\nfrom flash_attn.cute.interface import flash_attn_func\n\ndef run(Q, K_prefix, V_prefix, K_current, V_current):\n keys = torch.cat((K_prefix, K_current), dim=1)\n values = torch.cat((V_prefix, V_current), dim=1)\n return flash_attn_func(Q, keys, values, softmax_scale=128 ** -0.5)[0]\n"
25
+ }
26
+ ]
27
  }
solutions/block_causal_attention/sglang_prefix_cached_block_causal_h32_d128.json CHANGED
@@ -17,7 +17,7 @@
17
  "sources": [
18
  {
19
  "path": "main.py",
20
- "content": "# Copyright 2026 Co-developed by KDA (Kernel Design Agents)\n\"\"\"SGLang 684fea8a: Qwen-Image 2.1 ``target_attn`` under ``--attention-backend torch_sdpa``.\n\nCall path (``python/sglang/multimodal_gen/runtime/``):\n``models/dits/qwen_image21.py:703`` ``target_attn.forward_with_replicated_kv_prefix``\n(or ``qwen_image21.py:629-631`` ``attend_target`` -> ``target_attn(q, k, v)`` with the\nsame packed K/V) -> on one rank, ``layers/attention/layer.py:2116-2119``: concatenate\nthe prefix and current K/V, then ``attn_impl.forward`` -> ``SDPAImpl.forward``\n(``layers/attention/backends/sdpa.py:76-114``): torch SDPA, no mask, scale\n``head_dim**-0.5``.\n\nAdapters: ``USPAttention`` needs SGLang's global server args and parallel groups, so\nthe ``SDPAImpl`` it builds (``layer.py:849-850, 874-886``) is built here with the same\narguments. ``image_ids``, ``key_valid`` and ``sm_scale`` are not arguments of SGLang's\ncall: on every captured row each query sees every key and ``sm_scale`` is\n1/sqrt(128). The transposed SDPA output is copied into an owned dense tensor.\n\"\"\"\n\nimport torch\nfrom sglang.multimodal_gen.runtime.layers.attention.backends.sdpa import SDPAImpl\n\nHEADS, HEAD_DIM = 32, 128\nTARGET_IMPL = SDPAImpl(\n num_heads=HEADS,\n head_size=HEAD_DIM,\n causal=False,\n softmax_scale=HEAD_DIM**-0.5,\n num_kv_heads=HEADS,\n)\n\n\ndef run(Q, K_current, V_current, K_prefix, V_prefix, image_ids, key_valid, sm_scale):\n # layer.py:2117-2119\n k = torch.cat([K_prefix, K_current], dim=1)\n v = torch.cat([V_prefix, V_current], dim=1)\n out = TARGET_IMPL.forward(Q, k, v, None)\n return out.clone(memory_format=torch.contiguous_format)\n"
21
  }
22
  ]
23
  }
 
17
  "sources": [
18
  {
19
  "path": "main.py",
20
+ "content": "# Copyright 2026 Co-developed by KDA (Kernel Design Agents)\n\"\"\"SGLang 684fea8a: Qwen-Image 2.1 ``target_attn`` under ``--attention-backend torch_sdpa``.\n\nCall path (``python/sglang/multimodal_gen/runtime/``):\n``models/dits/qwen_image21.py:703`` ``target_attn.forward_with_replicated_kv_prefix``\n(or ``qwen_image21.py:629-631`` ``attend_target`` -> ``target_attn(q, k, v)`` with the\nsame packed K/V) -> on one rank, ``layers/attention/layer.py:2116-2119``: concatenate\nthe prefix and current K/V, then ``attn_impl.forward`` -> ``SDPAImpl.forward``\n(``layers/attention/backends/sdpa.py:76-114``): torch SDPA, no mask, scale\n``head_dim**-0.5``.\n\nAdapters: ``USPAttention`` needs SGLang's global server args and parallel groups, so\nthe ``SDPAImpl`` it builds (``layer.py:849-850, 874-886``) is built here with the same\narguments. Each captured target query sees every prefix/current key. The fixed scale is\n1/sqrt(128); redundant visibility/scale metadata is omitted. The native SDPA\noutput view is returned without an extra layout copy.\n\"\"\"\n\nimport torch\nfrom sglang.multimodal_gen.runtime.layers.attention.backends.sdpa import SDPAImpl\n\nHEADS, HEAD_DIM = 32, 128\nTARGET_IMPL = SDPAImpl(\n num_heads=HEADS,\n head_size=HEAD_DIM,\n causal=False,\n softmax_scale=HEAD_DIM**-0.5,\n num_kv_heads=HEADS,\n)\n\n\ndef run(Q, K_prefix, V_prefix, K_current, V_current):\n # layer.py:2117-2119\n k = torch.cat([K_prefix, K_current], dim=1)\n v = torch.cat([V_prefix, V_current], dim=1)\n out = TARGET_IMPL.forward(Q, k, v, None)\n return out.detach()\n"
21
  }
22
  ]
23
  }
solutions/block_causal_attention/sglang_prefix_cached_block_causal_h32_d128_prefix0.json CHANGED
@@ -17,7 +17,7 @@
17
  "sources": [
18
  {
19
  "path": "main.py",
20
- "content": "# Copyright 2026 Co-developed by KDA (Kernel Design Agents)\n\"\"\"SGLang 684fea8a: Qwen-Image 2.1 prefix attention under ``--attention-backend torch_sdpa``.\n\nCall path (``python/sglang/multimodal_gen/runtime/``):\n``models/dits/qwen_image21.py:651-667`` ``attend_sample`` without a cache: per prefix\nsegment, ``local_attn(qp[:, start:end], kp[:, :end], vp[:, :end], attn_mask=mask)``\nwith a causal bool mask for text runs and none for image blocks, joined by\n``cat_outputs`` (``qwen_image21.py:253-255``). ``LocalAttention.forward``\n(``layers/attention/layer.py:725-801``): with a mask, the bool mask made additive in\nbf16 and torch SDPA; without, ``SDPAImpl.forward`` (``backends/sdpa.py:76-114``).\n\nAdapters: ``local_attn`` is built as ``QwenImage21Attention.__init__`` builds it\n(``qwen_image21.py:395-398``), with the CLI backend forced through SGLang's selector,\nand run in SGLang's forward context. The engine's segments are the runs of\n``image_ids`` (text = -1); ``prepare`` derives them and their masks on the host.\n``K_prefix``/``V_prefix`` are empty (Np = 0), so ``kp, vp`` are the current K/V.\n``torch.cat`` replaces ``cat_outputs``, whose one-segment shortcut would return the\ntransposed SDPA view, so the output is an owned dense tensor. ``key_valid`` and\n``sm_scale`` are not arguments of SGLang's call: every captured key is valid and\n``sm_scale`` is 1/sqrt(128).\n\"\"\"\n\nimport torch\nfrom sglang.multimodal_gen.runtime.layers.attention import LocalAttention\nfrom sglang.multimodal_gen.runtime.layers.attention.selector import (\n global_force_attn_backend_context_manager,\n)\nfrom sglang.multimodal_gen.runtime.managers.forward_context import set_forward_context\nfrom sglang.multimodal_gen.runtime.models.dits.qwen_image21 import (\n QwenImage21Transformer2DModel,\n)\nfrom sglang.multimodal_gen.runtime.platforms import AttentionBackendEnum\n\nHEADS, HEAD_DIM = 32, 128\nwith global_force_attn_backend_context_manager(AttentionBackendEnum.TORCH_SDPA):\n LOCAL_ATTN = LocalAttention(\n HEADS,\n HEAD_DIM,\n supported_attention_backends=QwenImage21Transformer2DModel._supported_attention_backends,\n )\n\n\ndef prepare(\n Q, K_current, V_current, K_prefix, V_prefix, image_ids, key_valid, sm_scale\n):\n ids = image_ids.cpu()\n ends = torch.cumsum(torch.unique_consecutive(ids, return_counts=True)[1], 0)\n segments = []\n for start, end in zip([0, *ends[:-1].tolist()], ends.tolist()):\n mask = None\n if ids[start] < 0:\n # qwen_image21.py:657-661\n mask = (\n torch.arange(end, device=Q.device)[None, :]\n <= torch.arange(start, end, device=Q.device)[:, None]\n )\n mask = mask[None, None]\n segments.append((start, end, mask))\n\n def launch():\n with set_forward_context(current_timestep=0, attn_metadata=None):\n # qwen_image21.py:654-665\n outputs = [\n LOCAL_ATTN(\n Q[:, start:end],\n K_current[:, :end],\n V_current[:, :end],\n attn_mask=mask,\n )\n for start, end, mask in segments\n ]\n return torch.cat(outputs, dim=1)\n\n return launch\n\n\ndef run(*inputs):\n return prepare(*inputs)()\n"
21
  }
22
  ]
23
  }
 
17
  "sources": [
18
  {
19
  "path": "main.py",
20
+ "content": "# Copyright 2026 Co-developed by KDA (Kernel Design Agents)\n\"\"\"SGLang 684fea8a: Qwen-Image 2.1 prefix attention under ``--attention-backend torch_sdpa``.\n\nCall path (``python/sglang/multimodal_gen/runtime/``):\n``models/dits/qwen_image21.py:651-667`` ``attend_sample`` without a cache: per prefix\nsegment, ``local_attn(qp[:, start:end], kp[:, :end], vp[:, :end], attn_mask=mask)``\nwith a causal bool mask for text runs and none for image blocks, joined by\n``cat_outputs`` (``qwen_image21.py:253-255``). ``LocalAttention.forward``\n(``layers/attention/layer.py:725-801``): with a mask, the bool mask made additive in\nbf16 and torch SDPA; without, ``SDPAImpl.forward`` (``backends/sdpa.py:76-114``).\n\nAdapters: ``local_attn`` is built as ``QwenImage21Attention.__init__`` builds it\n(``qwen_image21.py:395-398``), with the CLI backend forced through SGLang's selector,\nand run in SGLang's forward context. The engine's segments are the runs of\n``image_ids`` (text = -1); ``prepare`` derives them and their masks on the host.\nThe current K/V are the complete uncached prefix; empty prefix inputs are omitted.\nThe one-segment shortcut matches ``cat_outputs`` and preserves the native output view. Every captured key is valid and scale is the engine's fixed 1/sqrt(128).\n\"\"\"\n\nimport torch\nfrom sglang.multimodal_gen.runtime.layers.attention import LocalAttention\nfrom sglang.multimodal_gen.runtime.layers.attention.selector import (\n global_force_attn_backend_context_manager,\n)\nfrom sglang.multimodal_gen.runtime.managers.forward_context import set_forward_context\nfrom sglang.multimodal_gen.runtime.models.dits.qwen_image21 import (\n QwenImage21Transformer2DModel,\n)\nfrom sglang.multimodal_gen.runtime.platforms import AttentionBackendEnum\n\nHEADS, HEAD_DIM = 32, 128\nwith global_force_attn_backend_context_manager(AttentionBackendEnum.TORCH_SDPA):\n LOCAL_ATTN = LocalAttention(\n HEADS,\n HEAD_DIM,\n supported_attention_backends=QwenImage21Transformer2DModel._supported_attention_backends,\n )\n\n\ndef prepare(\n Q, K_current, V_current, image_ids\n):\n ids = image_ids.cpu()\n ends = torch.cumsum(torch.unique_consecutive(ids, return_counts=True)[1], 0)\n segments = []\n for start, end in zip([0, *ends[:-1].tolist()], ends.tolist()):\n mask = None\n if ids[start] < 0:\n # qwen_image21.py:657-661\n mask = (\n torch.arange(end, device=Q.device)[None, :]\n <= torch.arange(start, end, device=Q.device)[:, None]\n )\n mask = mask[None, None]\n segments.append((start, end, mask))\n\n def launch():\n with set_forward_context(current_timestep=0, attn_metadata=None):\n # qwen_image21.py:654-665\n outputs = [\n LOCAL_ATTN(\n Q[:, start:end],\n K_current[:, :end],\n V_current[:, :end],\n attn_mask=mask,\n )\n for start, end, mask in segments\n ]\n return outputs[0] if len(outputs) == 1 else torch.cat(outputs, dim=1)\n\n return launch\n\n\ndef run(Q, K_current, V_current, image_ids):\n return prepare(Q, K_current, V_current, image_ids)()\n"
21
  }
22
  ]
23
  }
solutions/dense_attention/fa4_noncausal_h32_d128.json CHANGED
@@ -6,13 +6,14 @@
6
  "spec": {
7
  "language": "python",
8
  "target_hardware": [
9
- "NVIDIA_B200"
 
10
  ],
11
  "entry_point": "main.py::run",
12
  "dependencies": [
13
  "torch>=2.11",
14
  "flash-attn-4==4.0.0b35",
15
- "nvidia-cutlass-dsl[cu13]==4.7.1",
16
  "quack-kernels==0.6.5"
17
  ],
18
  "destination_passing_style": false
@@ -20,7 +21,7 @@
20
  "sources": [
21
  {
22
  "path": "main.py",
23
- "content": "from flash_attn.cute.interface import flash_attn_func\n\ndef run(Q, K, V, sm_scale):\n return flash_attn_func(Q, K, V, softmax_scale=sm_scale)[0]\n"
24
  }
25
  ]
26
  }
 
6
  "spec": {
7
  "language": "python",
8
  "target_hardware": [
9
+ "NVIDIA_B200",
10
+ "NVIDIA_B300"
11
  ],
12
  "entry_point": "main.py::run",
13
  "dependencies": [
14
  "torch>=2.11",
15
  "flash-attn-4==4.0.0b35",
16
+ "nvidia-cutlass-dsl[cu13]==4.8.0",
17
  "quack-kernels==0.6.5"
18
  ],
19
  "destination_passing_style": false
 
21
  "sources": [
22
  {
23
  "path": "main.py",
24
+ "content": "from flash_attn.cute.interface import flash_attn_func\n\ndef run(Q, K, V):\n return flash_attn_func(Q, K, V, softmax_scale=128 ** -0.5)[0]\n"
25
  }
26
  ]
27
  }
solutions/dense_attention/fa4_noncausal_h32_d64.json CHANGED
@@ -2,17 +2,18 @@
2
  "name": "fa4_noncausal_h32_d64",
3
  "definition": "noncausal_dense_attention_h32_d64",
4
  "author": "inference-kernels",
5
- "description": "FlashAttention 4 CuTe DSL without a mask. Converts the captured normalized audio-attention inputs to FP16 to reduce probability-rounding error, and returns BF16. All conversions are included in the call. Upstream: https://github.com/Dao-AILab/flash-attention (BSD-3-Clause).",
6
  "spec": {
7
  "language": "python",
8
  "target_hardware": [
9
- "NVIDIA_B200"
 
10
  ],
11
  "entry_point": "main.py::run",
12
  "dependencies": [
13
  "torch>=2.11",
14
  "flash-attn-4==4.0.0b35",
15
- "nvidia-cutlass-dsl[cu13]==4.7.1",
16
  "quack-kernels==0.6.5"
17
  ],
18
  "destination_passing_style": false
@@ -20,7 +21,7 @@
20
  "sources": [
21
  {
22
  "path": "main.py",
23
- "content": "import torch\nfrom flash_attn.cute.interface import flash_attn_func\n\ndef run(Q, K, V, sm_scale):\n output = flash_attn_func(Q.to(torch.float16), K.to(torch.float16), V.to(torch.float16), softmax_scale=sm_scale)[0]\n return output.to(Q.dtype)\n"
24
  }
25
  ]
26
  }
 
2
  "name": "fa4_noncausal_h32_d64",
3
  "definition": "noncausal_dense_attention_h32_d64",
4
  "author": "inference-kernels",
5
+ "description": "BF16 FlashAttention-4 with native SDPA for self-attention tiles of at most 64 tokens. Removes the former FP16 input/output conversions. Every current workload passes the existing 99.99% element acceptance policy on B300; dispatch is based on runtime shape.",
6
  "spec": {
7
  "language": "python",
8
  "target_hardware": [
9
+ "NVIDIA_B200",
10
+ "NVIDIA_B300"
11
  ],
12
  "entry_point": "main.py::run",
13
  "dependencies": [
14
  "torch>=2.11",
15
  "flash-attn-4==4.0.0b35",
16
+ "nvidia-cutlass-dsl[cu13]==4.8.0",
17
  "quack-kernels==0.6.5"
18
  ],
19
  "destination_passing_style": false
 
21
  "sources": [
22
  {
23
  "path": "main.py",
24
+ "content": "import torch\nfrom torch.nn import functional as F\nfrom torch.nn.attention import SDPBackend, sdpa_kernel\nfrom flash_attn.cute.interface import flash_attn_func\n\n\ndef run(Q, K, V):\n # B300 measurements favor native SDPA on the tiny self-attention tile.\n if max(Q.shape[1], K.shape[1]) <= 64:\n with sdpa_kernel([SDPBackend.CUDNN_ATTENTION, SDPBackend.FLASH_ATTENTION,\n SDPBackend.EFFICIENT_ATTENTION, SDPBackend.MATH],\n set_priority=True):\n out = F.scaled_dot_product_attention(\n Q.transpose(1, 2), K.transpose(1, 2), V.transpose(1, 2),\n dropout_p=0.0, is_causal=False, scale=64 ** -0.5,\n )\n return out.transpose(1, 2)\n return flash_attn_func(Q, K, V, softmax_scale=64 ** -0.5)[0]\n"
25
  }
26
  ]
27
  }
solutions/dense_attention/sglang_noncausal_dense_attention_h32_d128.json CHANGED
@@ -17,7 +17,7 @@
17
  "sources": [
18
  {
19
  "path": "main.py",
20
- "content": "# Copyright 2026 Co-developed by KDA (Kernel Design Agents)\n\"\"\"SGLang baseline for noncausal_dense_attention_h32_d128: LTX-2.5 video attention.\n\nSGLang diffusion runtime at commit 684fea8a, paths under\npython/sglang/multimodal_gen/runtime/: LTX2Attention.forward\n(models/dits/ltx_2.py:997-1006) calls ``self.attn(q, k, v, attn_mask=mask)``\non [B, N, H, D] Q/K/V for ``attn1`` (USPAttention, :857-871) and ``attn2``\n(LocalAttention, :841-855); every layer has\nsoftmax_scale=None -> head_size**-0.5 and allow_cudnn_sdp=True. On one GPU the\nmask is None, except for ``attn2``'s all-ones prompt mask, whose additive\nmask is exactly zero; the definition has no mask.\n\nUSPAttention.forward (layers/attention/layer.py:1466-1468) or\nLocalAttention.forward (:799) -> SDPAImpl.forward\n(layers/attention/backends/sdpa.py:76-114): one SDPA call under\n``sdpa_kernel(_PYTORCH_DEFAULT_CUDA_SDP_BACKENDS, set_priority=True)``, which\ntries cuDNN, Flash and memory-efficient attention before math.\n\nSDPAImpl returns a [B, Nq, H, D] transpose of the SDPA output;\n``.contiguous().detach()`` hands it over dense, without a copy when the kernel\nwrote it sequence-major.\n\"\"\"\n\nfrom sglang.multimodal_gen.runtime.layers.attention.backends.sdpa import SDPAImpl\n\n\ndef prepare(Q, K, V, sm_scale):\n impl = SDPAImpl(\n num_heads=Q.shape[2],\n head_size=Q.shape[3],\n causal=False,\n softmax_scale=sm_scale,\n num_kv_heads=K.shape[2],\n allow_cudnn_sdp=True,\n )\n\n def launch():\n return impl.forward(Q, K, V, None).contiguous().detach()\n\n return launch\n\n\ndef run(Q, K, V, sm_scale):\n return prepare(Q, K, V, sm_scale)()\n"
21
  }
22
  ]
23
  }
 
17
  "sources": [
18
  {
19
  "path": "main.py",
20
+ "content": "# Copyright 2026 Co-developed by KDA (Kernel Design Agents)\n\"\"\"SGLang baseline for noncausal_dense_attention_h32_d128: LTX-2.5 video attention.\n\nSGLang diffusion runtime at commit 684fea8a, paths under\npython/sglang/multimodal_gen/runtime/: LTX2Attention.forward\n(models/dits/ltx_2.py:997-1006) calls ``self.attn(q, k, v, attn_mask=mask)``\non [B, N, H, D] Q/K/V for ``attn1`` (USPAttention, :857-871) and ``attn2``\n(LocalAttention, :841-855); every layer has\nsoftmax_scale=None -> head_size**-0.5 and allow_cudnn_sdp=True. On one GPU the\nmask is None, except for ``attn2``'s all-ones prompt mask, whose additive\nmask is exactly zero; the definition has no mask.\n\nUSPAttention.forward (layers/attention/layer.py:1466-1468) or\nLocalAttention.forward (:799) -> SDPAImpl.forward\n(layers/attention/backends/sdpa.py:76-114): one SDPA call under\n``sdpa_kernel(_PYTORCH_DEFAULT_CUDA_SDP_BACKENDS, set_priority=True)``, which\ntries cuDNN, Flash and memory-efficient attention before math.\n\nSDPAImpl returns a [B, Nq, H, D] transpose of the SDPA output;\n``.detach()`` returns that native output view without adding a layout copy.\n\"\"\"\n\nfrom sglang.multimodal_gen.runtime.layers.attention.backends.sdpa import SDPAImpl\n\n\ndef prepare(Q, K, V):\n impl = SDPAImpl(\n num_heads=Q.shape[2],\n head_size=Q.shape[3],\n causal=False,\n softmax_scale=128 ** -0.5,\n num_kv_heads=K.shape[2],\n allow_cudnn_sdp=True,\n )\n\n def launch():\n return impl.forward(Q, K, V, None).detach()\n\n return launch\n\n\ndef run(Q, K, V):\n return prepare(Q, K, V)()\n"
21
  }
22
  ]
23
  }
solutions/dense_attention/sglang_noncausal_dense_attention_h32_d64.json CHANGED
@@ -17,7 +17,7 @@
17
  "sources": [
18
  {
19
  "path": "main.py",
20
- "content": "# Copyright 2026 Co-developed by KDA (Kernel Design Agents)\n\"\"\"SGLang baseline for noncausal_dense_attention_h32_d64: LTX-2.5 audio attention.\n\nSGLang diffusion runtime at commit 684fea8a, paths under\npython/sglang/multimodal_gen/runtime/: LTX2Attention.forward\n(models/dits/ltx_2.py:997-1006) calls ``self.attn(q, k, v, attn_mask=mask)``\non [B, N, H, D] Q/K/V for ``audio_attn1``, ``audio_to_video_attn`` and\n``video_to_audio_attn`` (USPAttention, :857-871, or LocalAttention) and\n``audio_attn2`` (LocalAttention, :841-855); every layer has\nsoftmax_scale=None -> head_size**-0.5 and allow_cudnn_sdp=True. On one GPU the\nmask is None, except for ``audio_attn2``'s all-ones prompt mask, whose additive\nmask is exactly zero; the definition has no mask.\n\nUSPAttention.forward (layers/attention/layer.py:1466-1468) or\nLocalAttention.forward (:799) -> SDPAImpl.forward\n(layers/attention/backends/sdpa.py:76-114): one SDPA call under\n``sdpa_kernel(_PYTORCH_DEFAULT_CUDA_SDP_BACKENDS, set_priority=True)``, which\ntries cuDNN, Flash and memory-efficient attention before math.\n\nSDPAImpl returns a [B, Nq, H, D] transpose of the SDPA output;\n``.contiguous().detach()`` hands it over dense, without a copy when the kernel\nwrote it sequence-major.\n\"\"\"\n\nfrom sglang.multimodal_gen.runtime.layers.attention.backends.sdpa import SDPAImpl\n\n\ndef prepare(Q, K, V, sm_scale):\n impl = SDPAImpl(\n num_heads=Q.shape[2],\n head_size=Q.shape[3],\n causal=False,\n softmax_scale=sm_scale,\n num_kv_heads=K.shape[2],\n allow_cudnn_sdp=True,\n )\n\n def launch():\n return impl.forward(Q, K, V, None).contiguous().detach()\n\n return launch\n\n\ndef run(Q, K, V, sm_scale):\n return prepare(Q, K, V, sm_scale)()\n"
21
  }
22
  ]
23
  }
 
17
  "sources": [
18
  {
19
  "path": "main.py",
20
+ "content": "# Copyright 2026 Co-developed by KDA (Kernel Design Agents)\n\"\"\"SGLang baseline for noncausal_dense_attention_h32_d64: LTX-2.5 audio attention.\n\nSGLang diffusion runtime at commit 684fea8a, paths under\npython/sglang/multimodal_gen/runtime/: LTX2Attention.forward\n(models/dits/ltx_2.py:997-1006) calls ``self.attn(q, k, v, attn_mask=mask)``\non [B, N, H, D] Q/K/V for ``audio_attn1``, ``audio_to_video_attn`` and\n``video_to_audio_attn`` (USPAttention, :857-871, or LocalAttention) and\n``audio_attn2`` (LocalAttention, :841-855); every layer has\nsoftmax_scale=None -> head_size**-0.5 and allow_cudnn_sdp=True. On one GPU the\nmask is None, except for ``audio_attn2``'s all-ones prompt mask, whose additive\nmask is exactly zero; the definition has no mask.\n\nUSPAttention.forward (layers/attention/layer.py:1466-1468) or\nLocalAttention.forward (:799) -> SDPAImpl.forward\n(layers/attention/backends/sdpa.py:76-114): one SDPA call under\n``sdpa_kernel(_PYTORCH_DEFAULT_CUDA_SDP_BACKENDS, set_priority=True)``, which\ntries cuDNN, Flash and memory-efficient attention before math.\n\nSDPAImpl returns a [B, Nq, H, D] transpose of the SDPA output;\n``.detach()`` returns that native output view without adding a layout copy.\n\"\"\"\n\nfrom sglang.multimodal_gen.runtime.layers.attention.backends.sdpa import SDPAImpl\n\n\ndef prepare(Q, K, V):\n impl = SDPAImpl(\n num_heads=Q.shape[2],\n head_size=Q.shape[3],\n causal=False,\n softmax_scale=64 ** -0.5,\n num_kv_heads=K.shape[2],\n allow_cudnn_sdp=True,\n )\n\n def launch():\n return impl.forward(Q, K, V, None).detach()\n\n return launch\n\n\ndef run(Q, K, V):\n return prepare(Q, K, V)()\n"
21
  }
22
  ]
23
  }
solutions/gdn/flashinfer_gdn_decode.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "flashinfer_gdn_decode",
3
+ "definition": "gdn_decode_qk4_v8_d128_k_last",
4
+ "author": "inference-kernels",
5
+ "spec": {
6
+ "language": "python",
7
+ "target_hardware": [
8
+ "NVIDIA_B200",
9
+ "NVIDIA_B300"
10
+ ],
11
+ "entry_point": "main.py::run",
12
+ "dependencies": [
13
+ "torch>=2.14.1",
14
+ "flashinfer-python==0.7.2",
15
+ "nvidia-cutlass-dsl[cu13]==4.8.0"
16
+ ],
17
+ "destination_passing_style": false
18
+ },
19
+ "sources": [
20
+ {
21
+ "path": "main.py",
22
+ "content": "# SPDX-License-Identifier: Apache-2.0\nfrom flashinfer.gdn_decode import gated_delta_rule_decode_pretranspose\n\n\ndef run(q, k, v, state, A_log, a, dt_bias, b, scale):\n effective_scale = q.shape[-1] ** -0.5 if scale is None or scale == 0 else scale\n return gated_delta_rule_decode_pretranspose(\n q=q, k=k, v=v, state=state.clone(), A_log=A_log, a=a,\n dt_bias=dt_bias, b=b, scale=effective_scale, use_qk_l2norm=False,\n )\n"
23
+ }
24
+ ],
25
+ "description": "FlashInfer 0.7.2 maintained GDN decode implementation. Honors the task scale and preserves input state. The contest task keeps its Q/K normalization and per-batch-state boundary; this is not the full SGLang state-pool interface. Upstream: https://github.com/flashinfer-ai/flashinfer/tree/d84335d8c54e0c8f9f7e22faa15c7e34a58abf94 (Apache-2.0)."
26
+ }
solutions/gdn/flashinfer_gdn_prefill.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "flashinfer_gdn_prefill",
3
+ "definition": "gdn_prefill_qk4_v8_d128_k_last",
4
+ "author": "inference-kernels",
5
+ "spec": {
6
+ "language": "python",
7
+ "target_hardware": [
8
+ "NVIDIA_B200",
9
+ "NVIDIA_B300"
10
+ ],
11
+ "entry_point": "main.py::run",
12
+ "dependencies": [
13
+ "torch>=2.14.1",
14
+ "flashinfer-python==0.7.2",
15
+ "nvidia-cutlass-dsl[cu13]==4.8.0"
16
+ ],
17
+ "destination_passing_style": false
18
+ },
19
+ "sources": [
20
+ {
21
+ "path": "main.py",
22
+ "content": "# SPDX-License-Identifier: Apache-2.0\nimport torch\nimport torch.nn.functional as F\nfrom flashinfer.gdn_prefill import chunk_gated_delta_rule\n\n\ndef run(q, k, v, state, A_log, a, dt_bias, b, cu_seqlens, scale):\n alpha = torch.exp(-torch.exp(A_log.float()) * F.softplus(a.float() + dt_bias.float()))\n beta = torch.sigmoid(b.float())\n effective_scale = q.shape[-1] ** -0.5 if scale is None or scale == 0 else scale\n return chunk_gated_delta_rule(\n q=q, k=k, v=v, g=alpha, beta=beta, scale=effective_scale,\n initial_state=state, output_final_state=True, cu_seqlens=cu_seqlens,\n use_qk_l2norm_in_kernel=False,\n )\n"
23
+ }
24
+ ],
25
+ "description": "FlashInfer 0.7.2 maintained GDN prefill implementation. Honors the task scale and preserves input state. The contest task keeps its Q/K normalization and per-batch-state boundary; this is not the full SGLang state-pool interface. Upstream: https://github.com/flashinfer-ai/flashinfer/tree/d84335d8c54e0c8f9f7e22faa15c7e34a58abf94 (Apache-2.0)."
26
+ }
solutions/gdn/flashinfer_wrapper_123ca6.json DELETED
The diff for this file is too large to render. See raw diff
 
solutions/gdn/flashinfer_wrapper_9b7f1e.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "name": "flashinfer_wrapper_9b7f1e",
3
- "definition": "gdn_decode_qk4_v8_d128_k_last",
4
- "author": "flashinfer",
5
- "spec": {
6
- "language": "python",
7
- "target_hardware": [
8
- "NVIDIA H20",
9
- "NVIDIA H100",
10
- "NVIDIA H200"
11
- ],
12
- "entry_point": "main.py::run",
13
- "dependencies": [
14
- "flashinfer"
15
- ],
16
- "destination_passing_style": false
17
- },
18
- "sources": [
19
- {
20
- "path": "main.py",
21
- "content": "import math\nimport torch\nfrom flashinfer.gdn_decode import gated_delta_rule_decode_pretranspose\n\n\ndef run(q, k, v, state, A_log, a, dt_bias, b, scale):\n if isinstance(scale, torch.Tensor):\n scale = float(scale.item())\n else:\n scale = float(scale)\n if scale == 0.0:\n scale = 1.0 / math.sqrt(q.shape[-1])\n\n B, T, num_v_heads, head_size = v.shape\n output = torch.empty(B, T, num_v_heads, head_size, dtype=q.dtype, device=q.device)\n\n out, new_state = gated_delta_rule_decode_pretranspose(\n q=q,\n k=k,\n v=v,\n state=state,\n A_log=A_log,\n a=a,\n dt_bias=dt_bias,\n b=b,\n scale=scale,\n output=output,\n use_qk_l2norm=False,\n )\n\n return out, new_state\n"
22
- }
23
- ],
24
- "description": "Solution using FlashInfer gated_delta_rule_decode_pretranspose for GDN single-token decode (qk4_v8_d128, k-last state layout)."
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
solutions/gemm/deepgemm_bf16_n12288_k4096.json CHANGED
@@ -2,7 +2,24 @@
2
  "name": "deepgemm_bf16_n12288_k4096",
3
  "definition": "dense_gemm_bf16_nt_n12288_k4096",
4
  "author": "inference-kernels",
5
- "description": "DeepGEMM Blackwell BF16 GEMM with FP32 accumulation. Selected by local B200 comparison against FlashInfer CUTLASS, cuTile, and small-row CuTe DSL. Upstream: https://github.com/deepseek-ai/DeepGEMM/tree/1fc9c66975ee322d628b3288534ca0e9ce12a64d (MIT).",
6
- "spec": {"language": "python", "target_hardware": ["NVIDIA_B200"], "entry_point": "main.py::run", "dependencies": ["torch>=2.11", "deep-gemm @ git+https://github.com/deepseek-ai/DeepGEMM.git@1fc9c66975ee322d628b3288534ca0e9ce12a64d"], "destination_passing_style": false},
7
- "sources": [{"path": "main.py", "content": "import torch\nimport deep_gemm\n\ndef run(A, W):\n output = torch.empty((A.shape[0], W.shape[0]), dtype=torch.bfloat16, device=A.device)\n deep_gemm.bf16_gemm_nt(A, W, output)\n return output\n"}]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
 
2
  "name": "deepgemm_bf16_n12288_k4096",
3
  "definition": "dense_gemm_bf16_nt_n12288_k4096",
4
  "author": "inference-kernels",
5
+ "description": "DeepGEMM BF16 NT GEMM with native linear on the B300 large-row shapes M=12288/16384/24576 that won the current paired comparisons. Other shapes and B200 retain DeepGEMM. All captured workloads are validated against the unchanged reference; no tolerance change.",
6
+ "spec": {
7
+ "language": "python",
8
+ "target_hardware": [
9
+ "NVIDIA_B200",
10
+ "NVIDIA_B300"
11
+ ],
12
+ "entry_point": "main.py::run",
13
+ "dependencies": [
14
+ "torch>=2.11",
15
+ "deep-gemm @ git+https://github.com/deepseek-ai/DeepGEMM.git@1fc9c66975ee322d628b3288534ca0e9ce12a64d"
16
+ ],
17
+ "destination_passing_style": false
18
+ },
19
+ "sources": [
20
+ {
21
+ "path": "main.py",
22
+ "content": "import torch\nimport deep_gemm\nfrom torch.nn import functional as F\n\n\ndef run(A, W):\n # B300 comparisons favor native linear on these retained large-row shapes.\n if (torch.cuda.get_device_capability(A.device) == (10, 3)\n and A.shape[0] in (12288, 16384, 24576)):\n return F.linear(A, W)\n output = torch.empty((A.shape[0], W.shape[0]), dtype=torch.bfloat16, device=A.device)\n deep_gemm.bf16_gemm_nt(A, W, output)\n return output\n"
23
+ }
24
+ ]
25
  }
solutions/gemm/deepgemm_bf16_n4096_k12288.json CHANGED
@@ -3,6 +3,23 @@
3
  "definition": "dense_gemm_bf16_nt_n4096_k12288",
4
  "author": "inference-kernels",
5
  "description": "DeepGEMM Blackwell BF16 GEMM with FP32 accumulation. Selected by local B200 comparison against FlashInfer CUTLASS, cuTile, and small-row CuTe DSL. Upstream: https://github.com/deepseek-ai/DeepGEMM/tree/1fc9c66975ee322d628b3288534ca0e9ce12a64d (MIT).",
6
- "spec": {"language": "python", "target_hardware": ["NVIDIA_B200"], "entry_point": "main.py::run", "dependencies": ["torch>=2.11", "deep-gemm @ git+https://github.com/deepseek-ai/DeepGEMM.git@1fc9c66975ee322d628b3288534ca0e9ce12a64d"], "destination_passing_style": false},
7
- "sources": [{"path": "main.py", "content": "import torch\nimport deep_gemm\n\ndef run(A, W):\n output = torch.empty((A.shape[0], W.shape[0]), dtype=torch.bfloat16, device=A.device)\n deep_gemm.bf16_gemm_nt(A, W, output)\n return output\n"}]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
 
3
  "definition": "dense_gemm_bf16_nt_n4096_k12288",
4
  "author": "inference-kernels",
5
  "description": "DeepGEMM Blackwell BF16 GEMM with FP32 accumulation. Selected by local B200 comparison against FlashInfer CUTLASS, cuTile, and small-row CuTe DSL. Upstream: https://github.com/deepseek-ai/DeepGEMM/tree/1fc9c66975ee322d628b3288534ca0e9ce12a64d (MIT).",
6
+ "spec": {
7
+ "language": "python",
8
+ "target_hardware": [
9
+ "NVIDIA_B200",
10
+ "NVIDIA_B300"
11
+ ],
12
+ "entry_point": "main.py::run",
13
+ "dependencies": [
14
+ "torch>=2.11",
15
+ "deep-gemm @ git+https://github.com/deepseek-ai/DeepGEMM.git@1fc9c66975ee322d628b3288534ca0e9ce12a64d"
16
+ ],
17
+ "destination_passing_style": false
18
+ },
19
+ "sources": [
20
+ {
21
+ "path": "main.py",
22
+ "content": "import torch\nimport deep_gemm\n\ndef run(A, W):\n output = torch.empty((A.shape[0], W.shape[0]), dtype=torch.bfloat16, device=A.device)\n deep_gemm.bf16_gemm_nt(A, W, output)\n return output\n"
23
+ }
24
+ ]
25
  }
solutions/gemm/hybrid_bf16_n4096_k4096.json CHANGED
@@ -2,7 +2,24 @@
2
  "name": "hybrid_bf16_n4096_k4096",
3
  "definition": "dense_gemm_bf16_nt_n4096_k4096",
4
  "author": "inference-kernels",
5
- "description": "Shape-based B200 dispatch between FlashInfer CuTe DSL for 1-4 or 32 rows and DeepGEMM otherwise. Selected by local comparisons on actual captured shapes. Upstreams: https://github.com/flashinfer-ai/flashinfer (Apache-2.0), https://github.com/deepseek-ai/DeepGEMM/tree/1fc9c66975ee322d628b3288534ca0e9ce12a64d (MIT).",
6
- "spec": {"language": "python", "target_hardware": ["NVIDIA_B200"], "entry_point": "main.py::run", "dependencies": ["torch>=2.11", "flashinfer-python==0.7.2", "nvidia-cutlass-dsl[cu13]==4.7.1", "deep-gemm @ git+https://github.com/deepseek-ai/DeepGEMM.git@1fc9c66975ee322d628b3288534ca0e9ce12a64d"], "destination_passing_style": false},
7
- "sources": [{"path": "main.py", "content": "import torch\nimport deep_gemm\nfrom flashinfer.gemm import mm_bf16\n\ndef run(A, W):\n rows = A.shape[0]\n if rows <= 4 or rows == 32:\n return mm_bf16(A, W.T, backend='cute-dsl')\n output = torch.empty((rows, W.shape[0]), dtype=torch.bfloat16, device=A.device)\n deep_gemm.bf16_gemm_nt(A, W, output)\n return output\n"}]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
 
2
  "name": "hybrid_bf16_n4096_k4096",
3
  "definition": "dense_gemm_bf16_nt_n4096_k4096",
4
  "author": "inference-kernels",
5
+ "description": "DeepGEMM BF16 NT GEMM for the retained M >= 4096 workloads. Removed the unreachable small-M FlashInfer branch and its conflicting CUTLASS dependency. Upstream: https://github.com/deepseek-ai/DeepGEMM/tree/1fc9c66975ee322d628b3288534ca0e9ce12a64d (MIT).",
6
+ "spec": {
7
+ "language": "python",
8
+ "target_hardware": [
9
+ "NVIDIA_B200",
10
+ "NVIDIA_B300"
11
+ ],
12
+ "entry_point": "main.py::run",
13
+ "dependencies": [
14
+ "torch>=2.11",
15
+ "deep-gemm @ git+https://github.com/deepseek-ai/DeepGEMM.git@1fc9c66975ee322d628b3288534ca0e9ce12a64d"
16
+ ],
17
+ "destination_passing_style": false
18
+ },
19
+ "sources": [
20
+ {
21
+ "path": "main.py",
22
+ "content": "import torch\nimport deep_gemm\n\n\ndef run(A, W):\n output = torch.empty((A.shape[0], W.shape[0]), dtype=torch.bfloat16, device=A.device)\n deep_gemm.bf16_gemm_nt(A, W, output)\n return output\n"
23
+ }
24
+ ]
25
  }