Repository navigation
HIP: model-free Zig runtime, caps table and one exact affine matmul - #492
BlivionIaG wants to merge 7 commits into
Conversation
zig/src/hip mirrors zig/src/cuda: the entry points declared by hand from HIP's ABI, a driver that admits the library only when every one resolves, the current device, device and pinned host memory with range-checked copies and fills, streams and events, modules and launches with packed arguments. Stream-less fills and device copies finish before they return. zig build test runs its host unit tests; nothing else changes.
…he table refused zig/src/hip/caps.zig lists RDNA2 (gfx1030-gfx1036), RDNA3 (gfx1100-gfx1103), RDNA3.5 (gfx1150-gfx1153) and RDNA4 (gfx1200, gfx1201) with the wave width, dot and matrix instructions each has. Context reads the device's gcnArchName and refuses a GPU the table does not list, naming it, instead of picking a nearby generation.
…ds 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 refuses it. Both checks follow the argument and grid validation in ashhart#463. Co-authored-by: ThinkOffApp <[email protected]>
…a real GPU zig/build/hip.zig builds zig/kernels/hip/probe.hip with -Dhipcc into one offload bundle for every -Dgfx target (default gfx1030,gfx1100,gfx1151; the family names rdna2, rdna3 and rdna3.5 stand for every part the caps table lists), and HIP loads the code object built for the device. Without -Dhipcc the program builds with no kernels. tf-hip-test info, smoke, cooperative and image mirror zig/tests/cuda/runtime_tests.zig: blocking and async copies through pinned memory, fills, mapped host memory, launches, argument packing, module globals, the wave width, refusals, a cooperative grid and refused images. No model, family or serving code is involved.
… so 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]>
…ld test, on any host A mock library in host memory, built three ways: complete, missing one entry point, and an unknown GPU. The tests check admission, copies, fills, out-of-range refusals, the GPU table, and that a launch hands HIP its geometry and packed arguments while an overfull pack or a grid past 2^32 threads never reaches it. A refused library or GPU logs a warning; the caller reports the error.
…hen its bits move zig/kernels/hip/affine.hip computes y = sum over groups of scale * (x . codes) + bias * sum(x) with bf16 x, scales and biases and fp32 sums: one thread an output, an ordered fma of x and code and a plain sum of x a group, then two fmas into the output. zig/src/hip/affine.zig launches it and refuses group sizes MLX does not use. zig/tests/hip/affine_reference.zig is the same recipe on the host, a float64 reference and the fp32 bound between them; zig build test checks the recipe against that bound and pins its output digest. tf-hip-test affine checks every GPU output against the host recipe bit for bit at 1, 3 and 16 rows over every group size, each against float64 within the bound, and the pinned digest.
|
gfx1151 receipt (Strix Halo, Radeon 8060S), #492 has no RDNA3.5 hardware run yet. At head 5f6550a with Zig 0.17.0, the build passes 7/7, |
|
Thank you, @BlivionIaG. Your gfx1100 and gfx1030 runs, 10,304 affine outputs bit-exact, and @ThinkOffApp's gfx1151 rerun show this runtime works. We're keeping one HIP runtime, the one #463 landed, so we'll close this as superseded by it. Two pieces #463 doesn't have yet are welcome as small PRs on top of it, each with its exactness check: the gfx caps table from RDNA2 to RDNA4, and the |
|
Hi yeah I have the next PRs that is additive on top of it as planned and in testing. Will push when it's done. |
What this changes
A model-free HIP runtime for the Zig engine in its own
zig/src/hip, besidezig/src/cuda:-Dhipcccompiles the kernels into one offload bundle for-Dgfx, which also takesrdna2,rdna3andrdna3.5.No model, family, serving or tensor-parallel code. CUDA and Metal are untouched;
build.ziggains one import and two calls. The argument-pack and grid refusals and the async new-bytes round trip follow #463 and credit @ThinkOffApp.Receipt
mainat f8fe17d, head 5f6550a. Zig 0.17.0. HIP 7.14.60850, Linux 7.1.7. GPUs: Radeon PRO W7800 (gfx1100) and Radeon PRO V620 (gfx1030). Host tests on an Apple Silicon Mac. No checkpoint involved.zig build teston macOS: 105/105 steps, 397 passed, 2 skipped. The HIP part is 7 runtime unit tests, 4 mock-library tests and 2 reference tests.tf-hip-test allon gfx1100 and gfx1030: 11/11 each (copies, fills, mapped memory, launches, module globals, wave32, argument packing, refusals, cooperative grid, image refusal, affine).-Dgfx=rdna2,rdna3,rdna3.5(15 targets) build.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (No model path touched.)tf-hip-testis a separate program that needs a GPU.