Repository navigation
Add model-free Zig HIP runtime and GPU qualification - #463
ThinkOffApp wants to merge 10 commits into
Conversation
|
@ThinkOffApp ran this on gfx1201 as offered.
One build note: without The card was nearly full of another process's memory during the run (about 9 MB free of 32 GB), so the tests got by on very little VRAM. |
|
Ran it on gfx1150 (Radeon 890M, Ryzen AI 9 HX 370), ROCm 7.2 on Arch Linux, Zig 0.17.0, at 0c83c1e.
|
|
Thank you both, @jkuepker (gfx1201, R9700) and @millaguie (gfx1150, 890M). Two outside receipts on two architectures we do not own is exactly what this pull request needed. Thank you too for the neighbour check, @millaguie: a gfx1151 build being refused on gfx1150 with The header problem you both hit is fixed in 6235561 (build.zig only, four lines):
We have checked it on our gfx1151 box (hipcc in |
|
@ThinkOffApp confirmed: 6235561 resolves the headers on an As agreed on #426, here is the gfx1201 follow-up for review before it becomes a PR: jkuepker/TensorFold
gfx1201 receipt (same setup as above):
Host: Apple M5 Max, Not run: gfx1151 and gfx1150. With the new default, the refusal check there loads a sibling RDNA 3.5 object (gfx1150 on gfx1151 and the reverse); I have only seen HIP refuse a foreign object on gfx1201. @ThinkOffApp and @millaguie, if you can run Happy to open it against |
|
Both confirmed on gfx1150 (Radeon 890M), ROCm 7.2 on Arch Linux (
|
|
Thank you both, @jkuepker and @millaguie, for confirming 6235561 on /opt/rocm, and for the gfx1201 and gfx1150 receipts on af60ec8, including the refusal checks. gfx1151 receipt for af60ec8 (Bosgame M5, Strix Halo, hipcc in /usr/bin, Zig 0.17.0):
So HIP refuses the sibling gfx1150 object on gfx1151 too, which settles the question you raised. With that, the change is covered on all three architectures. Our preference is to keep #463 to what Ash scoped on #426 (admission, one exact matmul, a test that fails when one bit moves) and take the multi-architecture change as your follow-up PR once #463 lands, unless Ash prefers it folded in here. |
|
@ThinkOffApp thanks for the gfx1151 run. Agreed: I'll open the multi-architecture change as a follow-up once #463 lands, unless @ashhart wants it folded in. The next follow-up is ready too, stacked on it: jkuepker/TensorFold
Receipt, Radeon AI PRO R9700 (gfx1201) ×2, each card on its own (
Negative control output: One limit: when another process has filled the card, Host: Apple M5 Max, |
|
Thanks @jkuepker. Agreed on the order: #463 first, then the multi-architecture change and hip-events as follow-ups, unless @ashhart prefers them folded in. Status on our side: #463 now carries the MLX 4-bit matmul (8ba9f41), with its qualification notes in zig/tests/hip_affine.md. It stays in draft until our own review finishes, then it's ready for Ash. gfx1151 receipt for hip-events (907911c, on af60ec8), Bosgame M5 (Strix Halo), hipcc in /usr/bin, Zig 0.17.0:
Same result as your R9700 cards, so the event ordering holds on RDNA 3.5 too. Not run: the memInfo full-card skip path (the card was not full). Your stack sits on af60ec8, so it may need a rebase onto #463's new head. |
|
gfx1150 receipts (Radeon 890M), ROCm 7.2 on Arch Linux,
So the affine golden and the event ordering both hold on gfx1150 too. Not run: the memInfo full-card skip path. |
|
gfx1201 receipt for #463 at 8ba9f41 (Radeon AI PRO R9700 ×2, each card on its own via
So the affine golden holds on gfx1201 too, alongside gfx1151 and @millaguie's gfx1150. Another process held almost all VRAM on both cards during the run; the test buffers are KB-sized. I'll rebase |
|
Rebased both follow-ups onto 8ba9f41 and force-pushed:
One thing to know if you fold the multi-architecture change in: a plain rebase onto 8ba9f41 applies cleanly but breaks gfx1201 (R9700, same setup as above, card 0, default
Not run on the rebased branches: gfx1151 and gfx1150. |
… are refused in every build mode The pack's bounds were a debug assert, gone in release builds; a full pack now marks itself and the launch or graph node refuses it. Both checks follow the argument and grid validation in ashhart#463. Co-authored-by: ThinkOffApp <[email protected]>
…o a copy that does nothing fails The first round trip writes a fresh buffer and reads into zeroes, which a stale allocation could satisfy. The second inverts the bytes over the same buffers, as ashhart#463's pinned-memory round trip does. Co-authored-by: ThinkOffApp <[email protected]>
|
That's why the tests need a manual sync after each fill ( Suggestion: have |
|
Thanks @jkuepker for the gfx1201 receipts on both cards and for the rebases. The catch about -Dhip-arch reaching the affine build as a list is a good one; one object per architecture through the shared helper sounds right. Thanks @millaguie too, for the gfx1150 receipts on 8ba9f41 and on hip-events, including the removed-wait control. @BlivionIaG, you're right. A hipStreamNonBlocking stream doesn't order against the null stream, and hipMemset can return before the fill completes, so One heads-up before anyone leans on 8ba9f41: our own review found its affine golden is weaker than it looks. It pins a single output, and that value is the correctly rounded answer, so any accurate kernel reproduces it, including ones that use FMA or reorder the reduction. A revision is coming that pins the full test matrix, adds negative controls that must fail (FMA, reversed shuffle, BF16 sums), and adds the float64 check as code. That means one more rebase for jkuepker's two branches, sorry about that. Once the revised head is up, we'll run hip-gfx1201 and hip-events on gfx1151 too, since those haven't been run there yet @BlivionIaG thanks for #491 and #492. Building on #463 as the runtime base works for us, and your gfx1030/gfx1100 runs and fixes on our branch are welcome. We'll line our revised tests up against #492's. |
Perfect, I will make a new branch for gfx1030/gfx1100 runs, really like the leaner aspect of tensorfold vs making vllm work with rdna :). |
|
The revised head is up: 1dea2a3. It is what the earlier heads-up promised: the full test matrix pinned (9,600 outputs, N up to 25, K up to 4096), order-sensitive records with a reproducible @BlivionIaG, @jkuepker, |
Credit BlivionIaG for identifying the null-stream fill ordering hazard and proposing synchronous fill8 plus an explicit-stream asynchronous variant.
… copies, mapped memory, device queries On ashhart#463's types: device-to-device copies and 32-bit word fills (blocking and on a stream), device addresses for kernel arguments, pinned host memory mapped into the device, held-bytes counters with a device peak, module globals, function attributes and occupancy, cooperative launches, device attributes and name, HIP's error names, and graphs (stream capture, explicit kernel nodes with edges, instantiate, upload, replay, in-place node and whole-exec updates; a refused update is HIP's verdict, not an error). Host tests run on HIP's mock; on a W7800 (gfx1100) hip-gpu-test passes 36/36, the new tests checking every output exactly.
…, DeltaNet, norms, RoPE, MoE routing and decode plans The kernels a model engine composes, built by hipcc for -Dhip-arch with the caps table's instruction switches and embedded as one code object a source group, launched from Zig: elementwise ops and casts, norms and the merged decode tails, RoPE, the attention walks (flat, planned over a page table with the query heads of a KV head read together, the 64-row prompt tile flat and paged), the DeltaNet recurrence token-serial and chunked, the linear attention's conv and gates, the MoE router, pick and route, argmax and top-k, and a lane round's plan kernels. A typed Ops layer checks shapes; an arena hands out a forward's scratch, and a counting stream measures it without launching. hip-kernel-test checks each against a host or float64 reference, and the merged and paged forms against the forms they replace, bit for bit where they promise it; -Dhip-device-lib names ROCm's bitcode. The sources hold device code only: plain kernels by C name, templates instantiated for the types the launches use.
…el-free set The device count, a context's free and total memory (hipMemGetInfo, looked up on its own so the admission set is unchanged), a buffer's base address, a pinned host buffer's sub-range and typed view, and raw.zig: device copies, fills and pinned transfers on a forward's raw stream handle, none of them on the counting stream. hip-gpu-test checks each on the GPU.
… and model checks The HIP branch's engine (ashhart#490) on ashhart#463's runtime and the kernel launches of ashhart#617 and ashhart#621: the lane rounds with MTP drafts, the paged attention cache and the radix prompt cache (ashhart#625), chunked prompts (ashhart#623), CUDA-graph rounds, the memory plan, and tensor parallelism over RCCL (comm/: the library, the rank link, the group). The native server takes it with `zig build native-hip -Dhip-arch=...` and the serve flags it lists (ashhart#624); `tf-qwen35-test` runs the model checks on a GPU. `zig build test` compiles both against stub kernels. The engine reads the policy (`--policy`, TF_POLICY) once and hands the kernels `Launcher.Choices`; a GPU other than the one the kernels were built for is refused with both names. round_shape.zig stays in the family: its only reader is the plan.
…, DeltaNet, norms, RoPE, MoE routing and decode plans The kernels a model engine composes, built by hipcc for -Dhip-arch with the caps table's instruction switches and embedded as one code object a source group, launched from Zig: elementwise ops and casts, norms and the merged decode tails, RoPE, the attention walks (flat, planned over a page table with the query heads of a KV head read together, the 64-row prompt tile flat and paged), the DeltaNet recurrence token-serial and chunked, the linear attention's conv and gates, the MoE router, pick and route, argmax and top-k, and a lane round's plan kernels. A typed Ops layer checks shapes; an arena hands out a forward's scratch, and a counting stream measures it without launching. hip-kernel-test checks each against a host or float64 reference, and the merged and paged forms against the forms they replace, bit for bit where they promise it; -Dhip-device-lib names ROCm's bitcode. The sources hold device code only: plain kernels by C name, templates instantiated for the types the launches use.
…el-free set The device count, a context's free and total memory (hipMemGetInfo, looked up on its own so the admission set is unchanged), a buffer's base address, a pinned host buffer's sub-range and typed view, and raw.zig: device copies, fills and pinned transfers on a forward's raw stream handle, none of them on the counting stream. hip-gpu-test checks each on the GPU.
… and model checks The HIP branch's engine (ashhart#490) on ashhart#463's runtime and the kernel launches of ashhart#617 and ashhart#621: the lane rounds with MTP drafts, the paged attention cache and the radix prompt cache (ashhart#625), chunked prompts (ashhart#623), CUDA-graph rounds, the memory plan, and tensor parallelism over RCCL (comm/: the library, the rank link, the group). The native server takes it with `zig build native-hip -Dhip-arch=...` and the serve flags it lists (ashhart#624); `tf-qwen35-test` runs the model checks on a GPU. `zig build test` compiles both against stub kernels. The engine reads the policy (`--policy`, TF_POLICY) once and hands the kernels `Launcher.Choices`; a GPU other than the one the kernels were built for is refused with both names. round_shape.zig stays in the family: its only reader is the plan.
What this changes
Adds an opt-in, model-free HIP runtime for the Zig engine and one exact matmul: the MLX affine 4-bit row projection (BF16 x, scales and biases; FP32 sums; groups 32 and 64; BF16 round-to-nearest-even output), with tests that fail when its bits move. This is the scope set on #426. No model, family, serving or tensor-parallel code; CUDA and Metal sources are untouched.
Receipt
zig-flashnextf8fe17d (the HIP sources, kernels, fixtures and the HIP build block are byte-identical to the reviewed 1dea2a3). Zig 0.17.0. HIP runtime 70152801. Bosgame M5, AMD Ryzen AI Max+ 395 with Radeon 8060S (gfx1151). Host tests on an Apple M5 Max. No checkpoint involved.core/row_projection, Sum.f32), 2 of 4032 BF16 outputs differ by one ulp, so this PR claims no cross-backend bit equality.zig build testat 3270cec, fresh cache: 97/97 steps, 411 passed, 2 skipped.hip-affine-test22/22,hip-gpu-test16/16.-ffp-contract=fastand a reversed shuffle reduction each fail the sensitive references (6 mismatches). BF16 accumulation fails all four GPU test blocks, including the per-output float64 bound.What the tests cover:
hip_affine_fixtures.py picks.fill8now blocks until the fill completes, andfill8Asyncis checked by a kernel reading on the same stream.Credits:
fill8stream-ordering hazard and proposing the blocking and explicit-stream API.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (No model path touched.)