Repository navigation
perf(hip): the stream tile stages x in LDS and sizes its waves by compute units; RDNA2 64-row prompt tile (stacks on #7) - #17
Open
BlivionIaG wants to merge 4 commits into
Open
BlivionIaG wants to merge 4 commits into
BlivionIaG wants to merge 4 commits into
Conversation
A stream launch narrowed its columns a lane until it made 3000 waves on every GPU. A GPU of 8 compute units holds about 256 waves, so its 4096-column products ran 2 columns a lane, below the 4 and 8 that stream weights faster. The target is now 96 waves a compute unit, at most 3000: large GPUs (W7800, V620) keep 3000, 8 CUs take 768. The launcher reads the count from the current device's HIP attribute. The columns a lane carries never change a product's bits.
Every lane of the stream tile loaded its 32 codes' x for each row and round, made the x pairs and summed x: the same work again in every column block. A launch of one row (4 or 8 columns a lane), or of two rows at 8 columns on a small GPU, now stages the block's rows once in LDS: x in pair order and each chunk's sum of x, computed by the same dot2 chain. The lanes read them back, so every value, and every output bit, is the one they computed themselves. Steam Deck (gfx1033), 9B MLX 4-bit decode products, one row: 66-72 GB/s before, 74-78 GB/s staged. W7800: the same or better at 4 and 8 columns a lane; 2 columns a lane and two rows stay unstaged there. The new kernel test runs every width, group, row count and columns-a-lane through staged and unstaged launches, compares their bytes and pins their hash to the one the tile wrote before this change (fp16 and bf16).
Two-expert plans with their members reversed join the fp32, activation-type and gate|up launches: one and two rows a block stage the plan's own rows. The pinned hashes are again the ones the tile wrote before the stage (fp16 on a gfx1033, bf16 on a gfx1100).
…ws a block The dot2 GEMM tile works 128 rows a block, so on a prompt of 33 to 64 rows half of its waves idle. The tile now also comes on 64 rows a block: the waves of a row group split its 128 columns, and every row and column keeps the dot2 chain and fma fold it had, so it writes the 128-row tile's bits (the prompt tiles stay one family). The RDNA2 table takes it for 33 to 64 rows; gfx11 keeps its matrix cores. The rows test compares every tile the registry picks between, at every row count, byte for byte.
8 tasks done
BlivionIaG
pushed a commit
that referenced
this pull request
Oct 20, 2026
- EXL3 packs on CUDA (experimental): a prompt path whose rows never depend on their chunk, fixes for the 27B and Flash Next engines, and serving that states it is experimental. - --ssd-experts streams routed experts from the checkpoint into a GPU pool, for Flash Next and GLM on Macs with less memory. - A reply that isn't a tool call comes back as content, never an HTTP 500. - GLM on CUDA keeps a prompt chunk's rows apart past 2,051 tokens, and EXL3 prompts past 128 tokens run. - An earlier prompt chunk evaluates only its caches, as mlx_lm's server does, and GLM's sparse prompt scores run in bf16 with a precise softmax. The bits don't change. - Tests that need PyTorch skip on machines without it. Fixes #17, #51 and #53.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacks on #7 (mirror of ashhart#621): based on
hip-kernels-affine(df83c6f), so the diff is only the four commits below.What this changes
Three speed changes to the MLX affine tiles of ashhart#621. None of them changes an output bit; together they let a GPU with few compute units stream its decode products near its memory bandwidth.
perf(hip): the stream tile's wave target follows the GPU's compute units: a stream launch narrowed its columns a lane until it made 3000 waves, on every GPU. The target is now 96 waves a compute unit, at most 3000. The launcher reads the count from the current device's HIP attribute (hipGetDevice,multiprocessor_count), so no engine change is needed. Every GPU with 32 compute units or more keeps 3000 (W7800 70, V620 72); an 8-CU APU takes 768. The columns a lane carries never change a product's bits.perf(hip): the stream tile stages a block's rows of x in LDS, same bits: every lane loaded its chunk of x for each row and round, built the x pairs and summed x, the same work again in every column block. A launch of one row at 4 or 8 columns a lane (or of two rows at 8 columns, on a GPU under 32 compute units) now stages the block's rows once in LDS: x in pair order, and each chunk's sum of x from the same dot2 chain. Lanes read back the values they used to compute, so every bit is the same. At most 32 KiB a block; two columns a lane and wider rounds keep the per-lane loads.test(hip): the stream stage test runs routed plans too: the new kernel testkernel_tests/affine/stream.zig(added in 2) runs every width, group, row count (1, 2, 3, 5, 16) and columns-a-lane, for fp32, activation-type, gate|up and two-expert routed outputs, staged and unstaged. It compares their bytes and pins the hash of all outputs to the one the tile wrote before this change (fp16 and bf16).perf(hip): RDNA2 prompts of 33 to 64 rows take the GEMM tile on 64 rows a block: the 128-row dot2 GEMM block left half its waves idle on 33 to 64 rows.gemm_tiletakes the block's row count as a template parameter: under 128 rows the waves of a row group split its 128 columns, and each row and column keeps its dot2 chain and fma fold, so the bits are the 128-row tile's. The gfx1030 table takes the 64-row block for 33 to 64 rows. gfx11 is unchanged (matrix cores).Receipt
Environment: base
hip-kernels-affinedf83c6f, head b3c7e7e. Zig 0.17.0, HIP 7.14 (TheRock), Linux 7.1.7. GPUs: Radeon PRO W7800 (gfx1100), Radeon PRO V620 (gfx1030), and a Steam Deck LCD (gfx1033, 8 CUs, 15 W) for the small-GPU numbers.Exactness, kernels:
hip-kernel-test59/59 on both GPUs. The new stream test's hash equals the hash the unmodified feat(hip): the MLX affine products: dot2 tiles, the gfx11 matrix-core GEMM tile, stream and K-parallel tiles ashhart/TensorFold#621 tile writes on the same inputs (fp16: 0x36ef53355d892c81, measured on gfx1033 and passing on gfx1030; bf16: 0x6b703ab847138aad on gfx1100).Exactness, model: the engine of feat(qwen3_5): the Qwen3.5 / 3.6 engine on HIP (draft, slice 12) #11 (
qwen35-engine) with these commits merged, against the same engine without them:tf-qwen35-test logitsbyte-identical for Qwen3.5-9B 4-bit and Qwen3.6-35B-A3B 4-bit MTP, decode (300 rounds) and prefill (300 rows), on both GPUs, and for a 53-row prompt of the 9B (the 64-row tile) on both GPUs.Speed, served 9B MLX 4-bit MTP, greedy, 256 tokens, old and new alternating (median of three on the desktop GPUs, two on the Deck, which starts each request at or below 70 C):
Break checks:
gemm64 differs from gemm);Tests run: W7800 and V620:
hip-kernel-test59/59,hip-gpu-test30/30,hip-affine-test27/27. macOSzig build test test-golden -Dcpu=apple_m1134/134 steps, 0 unexpected golden differences; Linuxzig build testfrom the pushed head 32/32 steps, 332/332 tests.lean_check.py544, the same as the base.zig fmt --checkis clean on the changed files; three files of the base itself (moe_bench.zig,tokenizer.zig,native/cuda.zig) were already unformatted there.Not run, and why: RDNA3.5 and RDNA4 hardware (none here); Metal and CUDA (sources untouched).
Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (A row's bytes at every row count are checked; logits are byte-identical on the merged engine.)