Development record¶
Archived: a dated record. Each chapter is the state of the work when it was written: its API, its numbers and its baselines are of that time, and some baselines were weaker than the opponent's best configuration. For current documentation start at the docs home; the only numbers the project quotes are on the scorecard.
The chapters below are a record, in the order the work happened. Chapters
01-15 were written while hk lived inside the HipKittens repository: paths
such as kernels/rdna3, include/rdna3 and tools/rdna-probes are
HipKittens', now under third_party/HipKittens. They also name the API of
their time: before chapter 15 the IR was Python and
kernels were written as flat calls (hk.load(x, idx, ty, bounded=True) is now
x[idx].load(ty, bounded=True)). The kernels themselves have all been ported;
the numbers are as measured then, and the MLIR chapter
re-measures the ones that matter against the port. A later chapter can
overturn an earlier one's verdict (chapter 26 did, for the GEMM); each
chapter is kept as written.
For the results in one place, with the hardware and baseline of each, see performance.
| chapter | in brief | |
|---|---|---|
| 01 | Phases 1 and 2: Python to torch, end to end | 291 shipped kernels, every one spill-free; 13 of 15 cases faster than torch.compile and two ties; the worst Python wrapper cut to 9.9 µs. |
| 02 | Phase 3: the generated GEMM matches the handwritten one | hk.ops.matmul compiles to the same 209 VGPRs as the handwritten GEMM and runs within noise of it (75.0 and 77.9 TFLOPs); the first 2.4-3.0% gap was one instruction. |
| 03 | Phase 4: the generated attention kernel matches the handwritten one | Attention at parity with the handwritten kernel, ahead under causal, at occupancy 6 against 5; three findings moved into the library or the IR. |
| 04 | Phase 5: hk.autotune |
A two-stage search with the resource gate in front of the GPU; 4 of 16 keys clear the 1% bar, and the rest stay on the default. |
| 05 | Phase 6: torch ops, the SDPA drop-in, and vLLM's vision tower | hk.torch_op and the SDPA drop-in; what the patch can reach in vLLM; a biased bf16 conversion found and fixed; what is left is a tie. |
| 06 | Phase 7: the decoder, as a vLLM attention backend | A paged decode backend that loses to Triton (up to 1.92x slower); splitting the KV axis brings it to a flat 1.14-1.19x, which is the wrapper, not the kernel. |
| 07 | Against the engine, which is the number that matters | A profile of Qwen3-8B puts prefill attention at 39%; 1.29x end to end on the prefill-heavy shape and 0.87x on the decode-heavy one. |
| 08 | The other 57.6%: the linear layers | The DSL GEMM beats hipBLASLt on Qwen3-8B's prefill shapes; the GEMM patch; 1.37x with both patches; decode turns out to be GEMV. |
| 09 | The decode kernel | A decode GEMV at about 2x hipBLASLt per step up to 16 tokens; end to end up to 1.72x; residency and a 128 KB LDS pool, found the hard way. |
| 10 | Row-predicated loads and stores | Buffer-range predication: the GEMM takes any M and the decode GEMM stops padding (1.08-1.10x); five wrong versions, each measured. |
| 11 | A reduction across workgroups, and the decode GEMV that did not need it | hk.wg_arrive; split-K for the decode GEMV is slower everywhere (a negative result); end to end 1.10-1.84x with nothing losing. |
| 12 | Strided globals, and the two patches they were for that lost | One runtime row stride per global; the SiLU-mul and weighted RMSNorm patches were dropped because the kernels lose to Inductor. |
| 13 | gfx1201: no arch baked into hk.ops, and fp8 WMMA tiles |
Kernels resolve their arch on first use; fp8 dtypes and WMMA for gfx1201, checked by type rules, build gate and ISA, not on hardware. |
| 14 | One patch layer, and a routing table that is measured rather than written | Op, Patch and RouteTable; the measured table beats the hand rule by 7-34% where the rule fell back; the CUDA-graph check. |
| 15 | The IR as an MLIR dialect, and kernels that read like the math | The Python IR replaced by an MLIR dialect, gated three times (byte-identical C++, resources and A/B, vLLM end to end); tests, wheels, limits, what is next. |
| 16 | Typical kernels checked at full size, and the race they found | Examples and validate.py; the cross-warp combine raced at full size since there were norms -- a plain barrier after ordinary LDS stores; drained, and now refused by the pass, at no measurable cost. |
| 17 | The decode step captured whole, and where hk's decode still loses | The backend under vLLM's defaults: decode captured whole, paged prefill 3.6-7.9x Triton's; a one-layer A/B hid a 10 us a layer loss below 16 requests, which now runs Triton's kernel on hk's cache. |
| 18 | Against Triton and FlyDSL: the scoreboard, and what it moved | One process, every way to compute each op; the GEMM was one LDS buffer away from 1.03-1.08x Triton and FlyDSL; weighted norms and online softmax; small-M norms still lose, to fixed latency. |
| 19 | Rows by index, atomics and random numbers: four kernels from the Triton side | Gather, scatter, atomics, hk.rand bit for bit tl.rand; dropout at Triton's speed once an FMA stopped flipping one mask in 33.5M; the KV write 1.18-3.0x Triton; LayerNorm backward 1.12x at 1024, 0.66x at 8192, where a 16-row tile cannot hold the row. |
| 20 | The port to vLLM 0.31, and the three things that moved under it | One cache tensor per layer; a compile cache that loaded unpatched graphs into the GEMM arm; wvSplitK on gfx11 at M ≤ 5. 1.20-1.75x stock with both patches; Triton's decode kernel beats hk's at every batch, yet routing it 16+ requests slowed the captured step, so it was reverted. |
| 21 | The MoE GEMM, on vLLM's own sorted lists | gather(div=top_k) and a decode-GEMM layout on vLLM's sort: 2.77x Triton's fused_moe at one token, even at 256; OLMoE end to end 1.02-1.41x (MoE alone), 1.17-2.22x with hk's attention; prefill stays on Triton. |
| 22 | Four-bit weights: a layout of hk's own, a dequantize that was the bottleneck, and AWQ in vLLM | load_w4 and an interleaved layout; the dequantize, not the codes, bounded the kernel until it cost a third; 1.40-2.61x vLLM's AWQ kernel; Qwen3-8B-AWQ 1.07-3.80x and 14B-AWQ 1.16-4.43x per request; gptq_gemm_rdna3 still wins at 1-4 tokens. |
| 23 | Your kernel in vLLM: the registration path, the wheels, and SGLang | register.op / register.patch / HK_VLLM_USER and python -m hk.integration ab; a cookbook whose kernel loses to Inductor, recorded; 0.3.0 wheels on GitHub Releases; the SGLang attempt ended when the node ran out of disk and evicted the pod. |
| 24 | SGLang, second attempt: a volume, the right torch, and the GEMV F.linear leaves behind | A pod on a persistent volume, with the torch the prebuilt kernel links; SGLang's F.linear runs decode GEMVs at 38% of bandwidth, so a table measured against it gives M 1-64 to hk; served Qwen3-8B 1.49-1.81x through an sglang.srt.plugins entry point; vLLM 0.31 rebuilt on the volume; 0.3.1 on PyPI. |
| 25 | MoE in SGLang: the routing kernel that failed, hk's expert GEMM, and a leaner launch | What stops MoE in SGLang on gfx1100 is sgl_kernel's top-k, not Triton; with it in torch OLMoE runs, and hk's GEMM serves it 1.06-1.32x faster; the one-token loss was hk's Python launch, now 17.8 µs a call from 27.3. |
| 26 | The scoreboard again, with every baseline tuned | FlyDSL's GEMM autotuner had never searched, and Triton's ranked cold calls. Retuned, the GEMM loses to FlyDSL's dispatcher (0.95-0.98x): its sched_group_barrier hints and K rotation, one of which hk-dsl cannot express. Norm tiles moved each row twice and now move it once: folded RMSNorm and fused add +9-17%, softmax at 2048 rows 1.29x. |
| 27 | Strips: a register layout for rows, and kernel arguments read too late | hk.RS, each lane owning 16-byte runs of a row, through the dialect, the translator and HipKittens; the one-row penalty was a late kernarg line, now read at entry (3.63 to 2.59 us on the old kernel); norms and softmax on strips: RMSNorm 1.02-1.12x and softmax 1.02x the best tuned Triton or FlyDSL, the fused add a tie; non-temporal stores' 2.2x was the Infinity Cache, not the kernel. |
| 28 | The GEMM schedule: sched_group_barrier, and the s_setprio that was the fence | hk.arch.sched_group_barrier and sched_barrier's mask; the C++'s s_setprio around each WMMA group was a scheduling boundary, and without it the GEMM is 2.9-6.5% faster and ties FlyDSL at all five scoreboard shapes (from 0.95-0.98x); the hint itself added nothing on top; FlyDSL's four-wave tile, with A streamed, fits under ROCm 7.1 and spills 3 under 7.2. |
| 29 | CDNA3 and CDNA4: wave64 targets, and a race the IR caught on the first GEMM | gfx942/gfx950 as targets. A shim instead of HipKittens edits: a strided gl, bounded rows, RNE bf16. The MFMA fragment in the type, CDNA's own ds_read counts and a 15-deep lgkmcnt. The bind is load-bearing on gfx950: unbound LDS GEMMs return NaN. hk.runtime.cocheck runs hk's gates on any code object. CDNA tiles bring the norms to 0.93-1.04x torch; the occupancy model is timed. HipKittens' GQA runs 1.28-2.62x SDPA; its GEMM is routed only where hipBLASLt is slow. ROCm 7.1 miscompiles that GEMM and no static gate sees it. RDNA output is byte-identical. |
| 30 | FlyDSL on the routes, a performance gate, and the engines' contracts | FlyDSL's GEMM as an optional overlay on the linear routes, keyed by the tile it would run: a decode step at 96-128 requests 12% shorter, tile-aligned prefill steps 1-2.6%, nothing elsewhere. A gate on ratios taken within one scoreboard run, tolerances from measured noise: silent on drift, it flagged all 14 GEMM pairs when hk's GEMM was made 9-12% slower. Contract tests for every symbol the vLLM and SGLang patches rebind: vLLM 0.31 19/19, SGLang 0.5.18 8/8, vLLM 0.16.1 18/19 (no auto_awq). |
| 31 | Re-measured: the gate's baseline and the linear routes, after strips and the GEMM schedule | Against chapter 26's baseline the gate found no regression and 33 pairs better (GEMM +3.5-5.0%, 2048-row norms and softmax +10-35%); refreshed from six runs, one left out for a round faster than HBM. The one- and 32-row norms lost their gate: hk runs them in 2.4-3.9 us depending on the process, on chapter 26's tree too. vLLM's table: hk's GEMM gained 3% on vLLM's op, FlyDSL's did not, and its overlay went from 105 points to 41; decode routes as before, prefill 1.5-1.7% faster at 8192-token steps and 1.2% slower at a 1024-token one. Two runs of route_tune on one tree disagree at 2% of their points. SGLang's table: one change, at 80-96 rows. |
| 32 | Measuring the measurements: impossible rounds, margins inside the noise, a shadowed package, and launches that came too soon | The scoreboard rejects rounds that lost kernel records, beat the card at their footprint (GDDR6 past the 96 MB cache, 2.43 TB/s measured inside it) or stand alone, and reports the median; on chapter 31's reports that rejects exactly the 97.4 us round. The one- and 32-row "per-process" times were the launchers': a launch 5-16 us after the GPU went idle took ~10 us longer; queued behind a spin every arm is steady to ~1%, hk fastest at all four, and they are gated again. route_tune's runs no longer flip between runs (a biased first set, not the margins; margins above the noise are a negative result); its FlyDSL overlay still drifts, 12 of 740 points. FlyDSL imports beside HuggingFace's kernels; SGLang's table gains FlyDSL rows, 0.4-0.6% off the decode step at 32 requests. The refresh note keys on the kernels' C++, not hk's version. |
| 33 | gfx950's GEMM in hk: the DMA left in flight, two halves a barrier apart, and where the time goes | Three features -- copies into LDS left in flight with derived vmcnts, the cross-warp checks that make that safe, and a pingpong of two half-workgroups -- write HipKittens' CDNA4 GEMM in hk; the pass refused a read HipKittens' waits leave to timing. Level with HipKittens at 4096-8192³ (0.97-0.99x the best of hipBLASLt, FlyDSL, HipKittens); C's store is the gap at 8192³ and the copy path the limit everywhere. A four-warp kernel with two-launch split-K and the decode GEMV on gfx950, split-K for both kernels as two launches, routed by a measured table: 108 of 122 Llama/Qwen linear points at 0.9x or better. |
| 34 | gfx950's attention in hk: P read in place, masks the register allocator copied, and a division per element | The CDNA pybind entry point takes torch's stream, so graphs capture gfx950's ops. A 32x32 accumulator read as a stride-4 operand (Tile.as_operand), register subtiles, a wave vote and pins write HipKittens' CDNA4 GQA forward in hk: 0.98-1.08x the stronger of HipKittens and FlyDSL at ten points, 1.30-3.13x SDPA, and hk.attention/SDPA run it on gfx950 (GPU tier 615/170 to 658/127). What it took: a hazard inside inline asm, work LLVM sank across phase barriers, causal masks that cost a register copy every step, an IEEE division per output element, a 64-bit compare per copy; the copy fix made the GEMM 1.2% faster. What is left is 2% a step, and paged attention. |
| 35 | Any model: the routes measured where the model runs | The route tuner as a library, this machine's measured shapes as records over the shipped table, and vLLM's linear patch measuring the shapes its table lacks when the model loads, within 60 s by default (python -m hk.integration tune beforehand). Qwen2.5-7B, in no table: 1.19-1.32x per request at 16-32 requests, 1.17x / 1.31x at 96 / 128, 1.04-1.15x at 1-4, greedy tokens identical; the first start 60 s longer, the second 43 s. DeepSeek-R1-Distill-Llama-8B: 1.18-1.41x at 16-32 requests, one shape's first token flipped where the top two logits are neighbouring bf16 values. Qwen3-8B routes exactly as the shipped table. A rule for unmeasured shapes failed two held-out sets (140 shapes), where K's factors starve the GEMV of warps; none ships. |
| 36 | The agent loop: where a step's time goes, whether a kernel helped, and a new op on the rails | headroom profiles a decode step and a prefill in the engine, attributes device time to kernel families from the chrome trace, sets each against what hk has and ranks by upper bound x ceiling (a ratio measured in the run, the routing table's, the record's, or the roofline). On Qwen3-8B at 16 x 4096, stock vLLM 0.31's decode step is 56% linear and 40% attention, both of which hk's arms measured at 2.00x and 1.71x; from TRITON_ATTN it reproduces the record: prefill attention 51.5% of a request against decode attention 1.1%, hk's decode kernel 0.87x. ab --json gives each shape, metric and arm a verdict, win, loss, tie or noise, against a band the rounds measured; on the gemm arm it reproduces chapter 35's 1.444x and 1.205x wins at 16 requests and ties for the one-request decode step, and an arm that patches nothing ties at 0.993-0.999x. new-op writes a working op with an exact-answer test and a scoreboard row; on its random inputs it differs from torch at 10.7% of elements, every one an exact bf16 tie HipKittens rounds away from zero. |
| 37 | gfx950's rows: strips on wave64, and what each op still pays | The scoreboard on gfx950 at LLM shapes, every arm checked and tuned arms recorded: hk lost 0.40-0.92x past 2048 rows on main. kittens::rs ported to wave64 in hk's shim (a DPP and permlane-swap butterfly), and the norms, softmax, quantize (any row count), the elementwise ops (bit for bit torch's), silu_mul on a gate/up output's halves in place and hk.ops.rotary (vLLM's RoPE, Tile.swap_halves) on it; 99 of 132 cases tie or win against the fastest of torch, Inductor, Triton and FlyDSL each tuned, the rest 0.90-0.98x. What moved them: the plan at 32 a lane, an occupancy cap from the 256 MiB cache, silu_mul's grid along a row (229 against 264 us), RoPE's loads hoisted above its stores (53.4 to 39.2 us), one v_med3 for the int8 clamp, LDS pointers for the combine. Not: reading the kernel arguments at entry; elementwise plans inside the cache, which move with where the buffers sit. RDNA output unchanged. |
| 38 | The RDNA losses: a transpose that was most of a page, stores rounded as torch rounds, and LayerNorm's backward on strips | About 2,900 of the paged decode's 3,350 instructions a page were V's register transposes: three of four stages on whole 32-bit words (the fork's rdna3 tree) cut the loop to 1,425, and a split plan for 256 workgroups instead of 1,024 made the walk 1.04-1.54x faster. Against triton-rocm 3.7.1, the record's Triton, it is 0.86-1.12x (from 0.83-0.95x); against the Triton 3.8.0 installed over it in the pod, 1.03-1.30x at 16, 32 and 64 requests; neither the cache's layout nor the blocks' order moved Triton. In a captured step Triton's kernel runs 3.7x slower than on the bench (chapter 20's paradox, reproduced, cause open), so batches stay on hk; end to end on Qwen3-8B the decode step is 4-9% shorter at every shape, outputs identical, and headroom's decode attention ratio went from 1.71x to 2.02x. RDNA's bf16 stores round to nearest even: a residual add is torch's at every element (89.3% before), within about 1%; the GEMM keeps ties away. LayerNorm backward on register strips: 1.90x, 1.69x, 1.15x and 1.15x the Triton tutorial at 1024-8192 wide. The MoE GEMM above 256 tokens and W4A16 at 1-4 tokens never reach hk (routing counts, end-to-end ties); the W4A16 GEMV is left. |
| 39 | gfx950's paged attention: the decode on the matrix core, the copies' runs, and a merge a query row | The gfx950 GPU tier's 55 "no native path" skips -- paged decode and prefill, the 4-bit GEMM, two RDNA-only tests -- run there (729/121 to 784/66, 0 failed), and the rule that hid them is gone. The decode in hk.ops.paged_cdna: one warp a split, Pᵀ read in place, pages by DMA bounded to the sequence, the table through the scalar cache (load_scalar(invariant=True)); copies laid out for whole-line runs and non-temporal (6.15 to 6.9 TB/s); a merge a strip a query row (7.5 to 4.7 us at 32 splits). Against what vLLM runs on an MI355X: 0.90-1.05x aiter's gluon kernel and 1.04-1.27x ROCM_ATTN at 8-128 requests, 0.71-0.88x at one or two requests past 2048 tokens; the prefill 1.10-1.24x aiter at batches. hk segfaulted in a vLLM process on ROCm 10 until its libraries were linked -Bsymbolic. |
| 40 | The GPU tier on GitHub Actions, and the finding it had been built around | The polling GPU CI rested on a finding that was wrong: the cluster does reach GitHub's Actions service -- directly from the jump host and the vLLM pod, by IP from the dev pod, whose DNS resolves no GitHub name -- and only github.com had been tried. The tier is now gpu.yml on two ephemeral self-hosted runners on the workstation, running scripts/ci/ from the checkout, on pushes to main and by hand, never on pull requests; gfx950 and gfx1100 are main's required checks. Side by side on three main commits the two CIs agreed in state and every count (gfx950 729/121, 784/66, 781/69 passed/skipped; gfx1100 659/95); cron, the daemon and scripts/gpu_ci/ are retired. |
| 41 | gfx950's leftovers: the weights streamed past the caches, a RoPE inside one DPP row, and plans that hold wherever the buffers sit | hk's own GEMM at 0.9x or better of the best of hipBLASLt, FlyDSL and HipKittens at all 122 Llama-3-8B/Qwen3-8B points, checked as shipped in three processes (chapter 33: 108): weights copied whole-line and non-temporal, blocks that fill the 256 CUs, the pingpong split at whole waves, its tail split along K, and a harness that takes the median of queued rounds. hk.rotate_half (a DPP row_ror:8 inside a 16-lane row) and hk.load {period} make a 16-byte RoPE; per-lane norm targets by width and placement-proof elementwise plans take the rows to 120 of 132 tie-or-win (chapter 37: 99). The 12 left are 0.95-0.98x: five at the launch floor, the 2048-row fused add, two 8192-row layernorms, a quantize, RoPE at 64 and 40 heads. |
| 42 | An MI355X in the engine: where vLLM's time goes there, and what hk's patches buy | Is there 1.05x end to end on gfx950 against vLLM with aiter on? Yes, from two patches. hk's attention backend makes Qwen3-8B 1.126x faster at 16 requests and 1.209x at 64 (1.055x past vLLM's own aiter FA backend at 64). The 4-bit patch makes Qwen3-8B-AWQ 1.87x faster at one request and 1.35x at 16, after a fix: the first run lost at 64 (0.92x) because stock's compiled graph runs a dequantize and a hipBLASLt GEMM rather than Triton's awq_gemm, so on gfx950 hk now takes up to 16 tokens. Greedy tokens identical. Measured peaks: 2.48 PFLOP/s of bf16 MFMA and 6.6 TB/s past the Infinity Cache. The bf16 linear layers run at 68-86% of the roofline on aiter's tuned GEMMs. hk's GEMMs, after chapter 41, are 0.79-1.21x aiter's; a table of the points where they win adds 1% on top of the backend, all in prefill (1.15x to 1.20x). hk's norms are 0.74-1.05x aiter's and its MoE 0.66-0.94x CK's, so those patches have no headroom. |
| 43 | gfx950's last rows: arguments the compiler could not see through, a floor that follows the buffer, and a RoPE of eight-byte runs | The rows go from 117 of 132 tie-or-win (re-measured on chapter 41's tree) to 131 and 128 in two runs. At one row every kernel is the card's empty-kernel 3.80 us plus 0.05-0.1, and which arm gets the 0.1 follows its output buffer (at add 32x8192 hk 3.900 us on its own, 3.793 on torch's): scoreboard.py --rotate-buffers passes the buffers along each round. On CDNA a noalias kernel -- every strip kernel in hk.ops -- takes its globals' fields as scalar __restrict__ arguments rather than a struct LLVM could neither preload nor see through (the 128-a-lane fused add 230 -> 164 VGPRs, 19.5-19.8 -> 19.35 us), and past 32 MB moved launches a twin with its arguments preloaded into SGPRs (0.4-7% faster; 0.2 us slower at the floor, where Triton pays it). The 2048-row fused add holds a row in one warp (19.17 against tuned Triton's 19.40 us), RoPE at 40 heads runs eight-byte runs on two warps a group (24.53 against 24.29). What still loses, run to run, is one- and 32-row cases at 0.978-0.979x (exp 1x5120 was 1.015-0.979x over four runs) and once RoPE 8192x40 at 0.977x; unrotated, 126, every loss at 1-32 rows. RDNA output unchanged. |
| 44 | The matched stack: the vLLM 0.31 record on triton-rocm 3.7.1, and the allocation that slows Triton's decode | From October 15 the engines' vLLM venv imported upstream Triton 3.8.0 (xgrammar's unpinned triton) over the triton-rocm 3.7.1 torch 2.13.0+rocm7.2 pins, so chapters 24 and 30-38 measured stock on it. A copy with 3.7.1 restored, and main's hk (c35a5e7): stock is chapter 20's to 0.9%, and nothing published shrinks -- Qwen3-8B with both patches 1.215-1.855x per request at 1-32 requests (published 1.20-1.75x) and 1.557-1.855x at 16-64 (chapter 38: 1.530-1.862x), AWQ 3.78x and 4.47x at one request (3.80x, 4.43x), OLMoE's MoE patch within 0.01 of chapter 21, Qwen2.5-7B's measured-at-load routes 1.18-1.32x at 16-128 requests (1.17-1.32x); greedy tokens identical everywhere. Interleaved, stock under 3.8.0 is 0-2.5% slower per request (prefill slower, decode step 2-12% faster). Chapter 20's paradox is the allocation: vLLM's cache is one 26.75 GiB allocation, and from 2 GiB up Triton's decode kernel reads the same pages 2.5x slower (3.4x under 3.8.0) while hk's walk does not; hk keeps 16+ requests (the step 6-51% shorter). Recommendation: restore 3.7.1 in the original venv and refresh the gfx1100 gate baseline. |
| 45 | gfx950's grids: wide blocks, a persistent stream-K pingpong, and why the scoreboard did not move | hk.tune's gfx950 misses were grids the pingpong's 128/256 blocks could not fill. The pingpong now takes 160-, 192- and 320-wide blocks (whole copies a warp, not a thread) and a persistent stream-K form whose cut blocks' fp32 shares meet in one XCD's L2 (wg_arrive(scope="xcd"), no device fence: 5-50x) and are summed in a fixed order. hk gets 4-12% faster at the four mid-M grids where the tuner picks wide blocks, stream-K wins at 1 of 25; the acceptance split stays at 13/25 (median 0.950) as TunableOp's baselines moved too. Stream-K's share epilogue is 15% of a wave's cycles at 8192x5120x5120, what the empty half round cost; the gap left is the main loop -- hipBLASLt 0.58 instructions a matrix instruction, the pingpong 1.56. |
| 46 | Qwen-Image 2.1 on a W7900D: hk's attention and GEMM inside SGLang-Diffusion, 1.50x a 1024^2 image | SGLang 0.5.18 runs Qwen-Image 2.1 through its diffusers fallback (79-80 s an image); main's native pipeline does not run on ROCm until its CUDA-only fused kernels are switched off (42.2 s). hk.integration.sglang_diffusion reaches SGLang-Diffusion's worker processes through a .pth boot and HK_SGLD: hk's attention (4.4 ms a DiT call against AOTriton's 13.6) makes it 34.8 s, 1.21x, and hk's GEMM on the DiT projections (1.27-1.28x hipBLASLt at all four shapes) 29.1 s, and attention reading SGLang's (B, N, H, D) memory in place (no copies) 28.2 s, 1.50x. Images deterministic, visually identical, and closer to an fp32-softmax reference than stock's (MAE 1.37 against 1.83). Found and fixed: the SDPA drop-in's fallback recursed once patched. |
| 47 | gfx1201 on hardware: an accumulator that was not gfx11's, a tree brought up to RDNA3, and the waits gfx12 spells differently | On a Radeon AI PRO R9700: the gfx12 operand layout had been inferred right and the accumulator wrong (row r + 8·(l/16), not gfx11's 2r + l/16; every mma unit test failed), so every gfx12 fragment has one shape and fp32 -> bf16 is pointwise. HipKittens' rdna4 tree, 32 commits behind rdna3, merged and re-derived (every global<->register transfer one run a lane); a waited LDS load that did not bind its tile, a register array promote-alloca put in LDS. hk counted gfx1100's two LDS reads a tile (too-shallow waits on gfx1201) and read gfx12's hex waits as drains. LDS 128 KB a WGP, granule 24, a register model fitted on gfx1201's builds. The rdna4 unit tests pass in every section and hk's GPU tier runs there; nothing tuned yet. |
| 48 | gfx1201's ceilings, and where hk stands there out of the box | The R9700 measured: 197 TFLOP/s bf16 WMMA (twice gfx1100 a CU), 372 fp8, 374 iu8; 1.81 TB/s cache-resident, 0.62 past the 64 MB cache. The ceiling tables had no gfx1201 and fell back to gfx1100's 122.6 TFLOP/s, which would have rejected hk's own GEMM rounds; copy_ is a DMA there. Out of the box, gfx1100's plans and schedules: GEMM 1.06-1.08x the best of hipBLASLt and Triton (144 TFLOP/s at 4096³), 1.05-2.9x either BLAS in the linear layer's layout; attention 3.33x / 1.87x AOTriton; norms tie or win but the fused add at 32 and 8192 rows (0.88x, 0.93x); a BLAS given its best layout beats hk below 256 rows. |
| 49 | gfx1201's first tuning: attention against AITER's FlyDSL kernel, an fp8 GEMM, and FlyDSL from source | AITER's gfx1201 FlyDSL attention beat hk's by 21% causal; a 256-row Q tile, a head-first grid (longest-first across every head) and warps skipping KV blocks they precede tie it (1.40 vs 1.41 ms causal, 2.65 vs 2.69 full). hk's GEMM on gfx1201's fp8 WMMA, right on its first run: scaled_mm, 240 TFLOP/s at 4096³, 1.4x hipBLASLt's rowwise path, decode batches on decode_gemm's kernel. FlyDSL main built from source (100 RDNA4 tests pass) for its INT4 GEMM. fp8 wins every row, decode with W read from GDDR6 (a cache-resident W had made FlyDSL's 32-row kernel look faster). The norms' strip plans measured for gfx1201 turn the last two losses into a win and a tie: no row of the gfx1201 scoreboard is a loss. Left: int8 a tie, int4. |
| 50 | gfx1201 in vLLM: a nightly toolchain, two compilers that spill in opposite places, and the linear layers on hk | hk in the R9700 vLLM image (TheRock ROCm 7.14, clang 23, torch 2.13 nightly, Debian 12): bindings rebuilt for glibc 2.36, the torch-op shim for TheRock's hipify spelling, a decode schedule that builds under both compilers (each spills where the other does not), vLLM's platform needing the image's PYTHONPATH. The GPU tier passes there; vllm_gemm with a gfx1201 table passes Gate C on Qwen3-1.7B and Qwen3.5-9B (tokens identical, counts equal), prefill 1.12-1.16x on the 9B, and is on by default on gfx1201; so is the AWQ route (decode 2.5-4.5x); the bf16 MoE route is right but 0.90-0.93x at 16 tokens and stays off. |
| 51 | gfx1201's small-M GEMM: a loss that was half the cache, and schedules shipped for 32-512 rows | Chapter 48's 0.57-0.88x below 256 rows against a library free to transpose the weight read one W back to back from the Infinity Cache; with W from GDDR6 it was 0.73-0.81x, hk's 128x128 tile leaving 64 CUs half idle. hk.tune under both compilers (clang 22 and the vLLM image's clang 23) found 32/64-row, 64-column tiles; each compiler's champion is within 1% under the other at 13 of 15 shapes, so one table of 18 ships (routes_gemm_gfx1201.json, read behind a machine's own records): 1.03-1.40x the default, 0.94-1.09x the library's best layout and 1.28-5.7x its NT. The gfx1201 vLLM table now routes most of M 33-256 to hk; Gate C on Qwen3.5-9B at 32-128 requests: tokens identical, requests 1.08-1.11x stock (the old table 1.01-1.08x), the decode step's own gain below the box's noise. |
| 52 | gfx1201's MoE GEMM at the roofline: hk wins only where vLLM skips the sort | With weights read from GDDR6, hk's and Triton's MoE GEMMs both stream the chosen experts at ~96% of the card's rate from 16 tokens a step (OLMoE: 710 MB in 1.2 ms), so there is nothing to tune there; a kernel for 64-256 tokens could win 4-16% at most. Uniform routing had hk ahead to 8 tokens, but a real router puts several tokens on each expert: Gate C on OLMoE lost at 4 and 8 requests. hk wins where vLLM gives each (token, choice) a block of its own, up to 2 tokens: decode 1.10-1.12x at one request, 1.06-1.07x at two, tokens identical. vllm_moe is on on gfx1201 with that limit (BLOCK16_MAX_TOKENS_AT). |
| 53 | gfx1201's large-M GEMM: winners that change with the compiler | hk.tune at 1024-8192 rows of Qwen3's four (N, K): under the vLLM image's clang 23, 11 of 16 shapes win 3.5-6%; under ROCm 7.2.3's clang 22, 3 do. Timed under each other's compiler, clang 23's champions are 2-5% slower than the default under clang 22 at four shapes, where clang 22's own win under both. 11 schedules ship, none more than 1% slower than the default under either compiler. hk.schedules.lookup, hk.templates.gemm.plan and hk.tune's incumbent now read the asked arch's records, not the current one's. Gate C on Qwen3.5-9B: tokens identical, prefill 1.09-1.14x stock, which two processes cannot tell from chapter 50's 1.11-1.14x. The RDNA4 line pauses here. |