Skip to content

Add model-free Zig HIP runtime and GPU qualification - #463

Closed
ThinkOffApp wants to merge 10 commits into
ashhart:zig-flashnextfrom
ThinkOffApp:codex/pr144-zig-rocm
Closed

ThinkOffApp wants to merge 10 commits into
ashhart:zig-flashnextfrom
ThinkOffApp:codex/pr144-zig-rocm

Conversation

@ThinkOffApp

@ThinkOffApp ThinkOffApp commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Environment: head 3270cec, rebased onto zig-flashnext f8fe17d (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.
  • Exactness: not applicable, because no model path is touched. At kernel level, exactness is per engine: every pinned output equals HIP's own committed bits; a row alone equals the same row in batches of 1 to 32; repeats and runs under concurrent load give identical bits. Against 24 cases exported from MLX Metal (core/row_projection, Sum.f32), 2 of 4032 BF16 outputs differ by one ulp, so this PR claims no cross-backend bit equality.
  • Decode speed before and after: not applicable (opt-in kernel, no model path).
  • Prompt speed before and after: not applicable (opt-in kernel, no model path).
  • Tests run, with pass, fail and skip counts:
    • zig build test at 3270cec, fresh cache: 97/97 steps, 411 passed, 2 skipped.
    • gfx1151 at 3270cec, 2026-10-08 05:22 UTC: hip-affine-test 22/22, hip-gpu-test 16/16.
    • Negative controls, compiled and run on the device at 7824ed0 (02:30 UTC; same HIP sources and HIP build block as 3270cec): -ffp-contract=fast and 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.
    • Flush-to-zero and the alternative epilogue and pass-order variants are checked by the fixture generator's host emulation only, not as separate device builds.
  • Not run, and why:
    • CUDA and Metal: sources untouched.
    • gfx1150 and gfx1201 at this head: no such hardware here. jkuepker (gfx1201) and millaguie (gfx1150) ran 8ba9f41, an earlier head.
    • The signed-zero identity and NaN paths are untested.

What the tests cover:

  • 12 pinned shapes with 9,600 outputs (N up to 25, K up to 4096, groups 32 and 64).
  • Searched order-sensitive records for contraction, shuffle order and K-pass order (K = 576, 1088, 4096), reproducible with hip_affine_fixtures.py picks.
  • Exact round-to-nearest-even ties of both parities, plus subnormal and x-sum-order cases.
  • Fresh-output float64 bounds on every output.
  • Poisoned outputs and untouched tail rows.
  • fill8 now blocks until the fill completes, and fill8Async is checked by a kernel reading on the same stream.

Credits:

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off. (No decode path touched.)
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (No model path touched.)
  • No precision traded for speed. If the bits change, the description says which sums change and why. (New opt-in kernel; no existing sums change.)
  • Prompt processing is no slower than the last release. (No prefill path touched.)
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (The GPU tests fail rather than skip when HIP is missing.)
  • Comments and docstrings are one line. No measurements or history in the source. (No measurements or history in the source, but three two-line header comments remain.)
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

@jkuepker

jkuepker commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@ThinkOffApp ran this on gfx1201 as offered.

  • Head 0c83c1e, Zig 0.17.0, inside rocm/dev-ubuntu-24.04:7.2.1-complete (HIP 7.2.53211, AMD clang 22.0.0git), Ubuntu host, Radeon AI PRO R9700 (gfx1201, PCI 03:00.0), one card visible.
  • zig build hip-host-test: 15/15 passed.
  • zig build hip-gpu-test -Dhip-arch=gfx1201 -Dhipcc=/opt/rocm/bin/hipcc --search-prefix /opt/rocm: 15 pass (15 total), 418 ms.

One build note: without --search-prefix /opt/rocm the hip-gpu-build step fails with zig/src/hip/device_arch.c:2:10: error: 'hip/hip_runtime_api.h' file not found, because ROCm here lives in /opt/rocm and nothing adds its include directory. A -Dhip-include option (or deriving it from -Dhipcc) would save the next person that step, or a line in the PR description.

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.

@millaguie

Copy link
Copy Markdown
Contributor

Ran it on gfx1150 (Radeon 890M, Ryzen AI 9 HX 370), ROCm 7.2 on Arch Linux, Zig 0.17.0, at 0c83c1e.

  • zig build hip-host-test: 23/23 passed.
  • zig build hip-gpu-test -Dhip-arch=gfx1150 -Dhipcc=/opt/rocm/bin/hipcc --search-prefix /opt/rocm: 15/15 passed. Same include-path note as @jkuepker: without --search-prefix the HIP headers aren't found here either.
  • The neighbour check: built with -Dhip-arch=gfx1151 and run on this gfx1150, the GPU test is refused with error.UnsupportedArchitecture at Module.loadForArchitecture, as intended. Since hip-arch defaults to gfx1151, the arch has to be passed explicitly on a gfx1150.

@ThinkOffApp

Copy link
Copy Markdown
Contributor Author

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 UnsupportedArchitecture is the behaviour we want.

The header problem you both hit is fixed in 6235561 (build.zig only, four lines):

  • -Dhipcc is now resolved through PATH, and the HIP headers default to the include directory next to it, so /opt/rocm/bin/hipcc gives /opt/rocm/include.
  • -Dhip-include=<dir> overrides that for any other layout.

We have checked it on our gfx1151 box (hipcc in /usr/bin, headers in /usr/include), but not yet on an /opt/rocm layout like yours. If you have a minute, a rerun without --search-prefix would confirm it:

zig build hip-gpu-test -Dhip-arch=<your arch> -Dhipcc=/opt/rocm/bin/hipcc

@jkuepker

jkuepker commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@ThinkOffApp confirmed: 6235561 resolves the headers on an /opt/rocm layout. -Dhipcc=/opt/rocm/bin/hipcc, no --search-prefix, Radeon AI PRO R9700 (gfx1201), rocm/dev-ubuntu-24.04:7.2.1-complete (HIP 7.2.53211), Zig 0.17.0, fresh Zig cache: hip-host-test 23/23, hip-gpu-test 16/16 (the run below, which contains 6235561 unchanged).

As agreed on #426, here is the gfx1201 follow-up for review before it becomes a PR: jkuepker/TensorFold hip-gfx1201, one commit (af60ec8) on 6235561, 3 files, +68/−11, model-free.

  • -Dhip-arch takes a comma-separated list (default gfx1150,gfx1151,gfx1201); the test binary embeds one exact code object per entry (zig/build/hip.zig). Unknown or duplicate entries stop the build. Loading is unchanged: only the object whose arch equals gcnArchName loads.
  • New GPU test: a build without the device's arch fails with DeviceArchitectureNotEmbedded, selection from the other objects fails with UnsupportedArchitecture, and HIP itself refuses each other arch's object (hipModuleLoadData → HipFailed).

gfx1201 receipt (same setup as above):

Command Result
zig build hip-host-test 23/23 passed
zig build hip-gpu-test -Dhipcc=/opt/rocm/bin/hipcc (all three objects) 16/16 passed
... -Dhip-arch=gfx1150,gfx1151 (negative control, no gfx1201 object) 14/16, both GPU tests fail closed as intended
error: 'runtime_tests.test.HIP copies fills and mixed-width kernel arguments on real GPU' failed:
           return selected orelse error.UnsupportedArchitecture;
error: 'runtime_tests.test.only the device's exact code object loads and a build without it fails closed' failed:
           if (n != images.len - 1) return error.DeviceArchitectureNotEmbedded;

Host: Apple M5 Max, zig build test 244/244; lean_check.py 150 problems, the same as this PR's baseline.

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 zig build hip-gpu-test -Dhipcc=<your hipcc> on the branch, that settles it. No CUDA or Metal source changes; host tests only there.

Happy to open it against zig-flashnext once this PR lands, or fold it in here if you prefer.

@millaguie

Copy link
Copy Markdown
Contributor

Both confirmed on gfx1150 (Radeon 890M), ROCm 7.2 on Arch Linux (/opt/rocm layout), Zig 0.17.0:

  • 6235561: zig build hip-gpu-test -Dhip-arch=gfx1150 -Dhipcc=/opt/rocm/bin/hipcc, no --search-prefix: 15/15. hip-host-test passes.
  • @jkuepker's hip-gfx1201 (af60ec8): hip-gpu-test -Dhipcc=/opt/rocm/bin/hipcc with all three objects: 16/16. So on gfx1150 HIP refuses both the gfx1151 and the gfx1201 object (hipModuleLoadData → HipFailed), the sibling RDNA 3.5 case you hadn't seen. Negative control -Dhip-arch=gfx1151,gfx1201: 14/16, with both GPU tests failing closed (UnsupportedArchitecture and DeviceArchitectureNotEmbedded), as in your receipt.

@ThinkOffApp

Copy link
Copy Markdown
Contributor Author

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):

Command Result
zig build hip-host-test passed
zig build hip-gpu-test -Dhipcc=/usr/bin/hipcc (all three objects) 16/16 passed
... -Dhip-arch=gfx1150,gfx1201 (negative control, no gfx1151 object) 14/16, both GPU tests fail closed (UnsupportedArchitecture, DeviceArchitectureNotEmbedded)

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.

@jkuepker

jkuepker commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@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 hip-events, one commit (907911c) on af60ec8, 5 files, +238/−1, model-free. It adds what the discrete card needed from the CUDA module's stream layer:

  • Event (timing or ordering-only): record, synchronize, done, elapsedMs; Stream.done and Stream.wait(event). hipErrorNotReady from a query means unfinished, other results still fail; foreign owners are refused before HIP.
  • Context.memInfo from hipMemGetInfo, refusing a zero total or free above total.
  • A probe kernel that sleeps before one write, so the GPU test has queued work: right after queueing, the event and stream report unfinished; a second stream that waits on the event reads the written value; the timed span is positive.

Receipt, Radeon AI PRO R9700 (gfx1201) ×2, each card on its own (HIP_VISIBLE_DEVICES), rocm/dev-ubuntu-24.04:7.2.1-complete (HIP 7.2.53211), Zig 0.17.0, fresh Zig cache, cards otherwise idle:

Command Card 0 Card 1
zig build hip-host-test 26/26 26/26
zig build hip-gpu-test -Dhipcc=/opt/rocm/bin/hipcc 22/22 22/22
same, with try reader.wait(end); removed (negative control) ordering test fails ordering test fails

Negative control output: expected 12648430, found 0, so without the wait the reader's copy runs first and returns the zero fill. Free memory on card 0 went from 33,982,251,008 to 33,915,142,144 bytes around a 64 MiB allocation, exactly 67,108,864 lower, with the total unchanged at 34,208,743,424.

One limit: when another process has filled the card, hipMemGetInfo here reported exactly 2 MiB free and a 2 MiB allocation did not move it. So the allocation check uses 64 MiB and reports a skip, never a pass, when less than 128 MiB is free; on a full card the GPU run is 21 pass, 1 skip.

Host: Apple M5 Max, zig build test passes; lean_check.py 150 problems, the same as the baseline. Not run: gfx1151 and gfx1150; the delay kernel's __builtin_amdgcn_s_sleep builds for all three objects. No CUDA or Metal source changes.

@ThinkOffApp

Copy link
Copy Markdown
Contributor Author

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:

Command Result
zig build hip-host-test 26/26 passed
zig build hip-gpu-test -Dhipcc=/usr/bin/hipcc 22/22 passed
same, with try reader.wait(end); removed (negative control) 21/22, the ordering test fails: expected 12648430, found 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.

@millaguie

Copy link
Copy Markdown
Contributor

gfx1150 receipts (Radeon 890M), ROCm 7.2 on Arch Linux, -Dhipcc=/opt/rocm/bin/hipcc, Zig 0.17.0, fresh Zig cache:

Branch Command Result
#463 at 8ba9f41 hip-host-test 28/28
hip-gpu-test -Dhip-arch=gfx1150 15/15
hip-affine-test -Dhip-arch=gfx1150 22/22
@jkuepker's hip-events at 907911c hip-host-test 26/26
hip-gpu-test (all three objects) 22/22
same, with try reader.wait(end); removed 21/22, the ordering test fails: expected 12648430, found 0

So the affine golden and the event ordering both hold on gfx1150 too. Not run: the memInfo full-card skip path.

@jkuepker

jkuepker commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

gfx1201 receipt for #463 at 8ba9f41 (Radeon AI PRO R9700 ×2, each card on its own via HIP_VISIBLE_DEVICES), rocm/dev-ubuntu-24.04:7.2.1-complete (HIP 7.2.53211), -Dhipcc=/opt/rocm/bin/hipcc, Zig 0.17.0, fresh Zig cache, clean git archive of 8ba9f41 (hip_affine_g64.hex SHA-256 8752ae3a…c383):

Command Card 0 Card 1
zig build hip-host-test -Dhip-arch=gfx1201 28/28 28/28
zig build hip-gpu-test -Dhip-arch=gfx1201 15/15 15/15
zig build hip-affine-test -Dhip-arch=gfx1201 22/22 22/22

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 hip-gfx1201 and hip-events onto 8ba9f41.

@jkuepker

jkuepker commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Rebased both follow-ups onto 8ba9f41 and force-pushed:

  • hip-gfx1201 (e41ea76, 4 files, +86/−22)
  • hip-events (98e25a1, 5 files, +238/−1, unchanged apart from the rebase)

One thing to know if you fold the multi-architecture change in: a plain rebase onto 8ba9f41 applies cleanly but breaks hip-affine-test. The affine build reads -Dhip-arch as one architecture, so the list default would reach --offload-arch as gfx1150,gfx1151,gfx1201, and the image's arch tag would never equal gcnArchName. The rebased commit builds the affine kernel the same way as the probe, one exact object per architecture, through a shared helper in zig/build/hip.zig. affine_gpu_test.zig now selects from that set instead of a single image.

gfx1201 (R9700, same setup as above, card 0, default -Dhip-arch, i.e. all three objects):

Branch hip-host-test hip-gpu-test hip-affine-test
hip-gfx1201 28/28 16/16 22/22
hip-events 31/31 21 pass, 1 skip 25/25
  • With -Dhip-arch=gfx1150,gfx1151 the GPU and affine tests fail closed (UnsupportedArchitecture, DeviceArchitectureNotEmbedded).
  • The skip is the memInfo allocation check: another process held the card, so it reported 2 MiB free.
  • Affine's 25 on hip-events are the 22 plus three stream/context unit tests reached through its imports.
  • This run was one commit before the final amend, which only changes the -Dhip-arch help string.
  • Host: zig build test passes on Apple M5 Max; lean_check.py 151 problems, the same as a clean 8ba9f41.

Not run on the rebased branches: gfx1151 and gfx1150.

BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 7, 2026
… 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]>
BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 7, 2026
…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]>
@BlivionIaG

Copy link
Copy Markdown
Contributor

fill8 runs hipMemset on the null stream (memory.zig:43), but launches go to a hipStreamNonBlocking stream (stream.zig:11), which doesn't wait for the null stream. And hipMemset can return before the fill is done: on ROCm 7.14 / gfx1030 a 4 GiB fill returns at 33 ms, hipStreamQuery(NULL) still says not ready, and it finishes at 44 ms. hipMemsetD8 and hipMemcpyDtoD behave the same. I haven't checked gfx1151.

That's why the tests need a manual sync after each fill (affine_gpu_test.zig:56, :68, :82), and any caller who forgets it reads a half-filled buffer.

Suggestion: have fill8 call hipStreamSynchronize(NULL) before returning, and add an async variant that takes a stream. That's what we do in our fork. Happy to send it as a PR to your branch.

@ThinkOffApp

ThinkOffApp commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author

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 fill8 followed by a launch is a race unless the caller syncs. We'll make fill8 synchronous and add an async variant that takes the launch stream, in the next revision, with credit to your fork. We haven't checked the timing on gfx1151 either.

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.

@BlivionIaG

Copy link
Copy Markdown
Contributor

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 fill8 followed by a launch is a race unless the caller syncs. We'll make fill8 synchronous and add an async variant that takes the launch stream, in the next revision, with credit to your fork. We haven't checked the timing on gfx1151 either.

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 :).
I have asked a friend to launch tests on strix halo, so I can report what works well on gfx1151 with #490

@ThinkOffApp

Copy link
Copy Markdown
Contributor Author

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 picks command, per-output float64 bounds, and device negative controls that fail as they should (FMA, reversed shuffle, BF16 sums).

@BlivionIaG, fill8 now blocks until the fill is done, and there is a fill8Async that takes the stream. A device test fills on a stream and reads the result with a kernel on the same stream, with no host sync in between. We also ran #492 at 5f6550a on our gfx1151 (Radeon 8060S, Zig 0.17.0): build 7/7, tf-hip-test all exit 0, and all 10,304 affine outputs bit-exact.

@jkuepker, hip-events can rebase onto this head; the stream-taking fill should fit your events. Once it is rebased, we'll run hip-gfx1201 and hip-events on gfx1151 as promised.

BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… 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.
BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…, 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.
BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…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.
BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… 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.
BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…, 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.
BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…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.
BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… 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.
@ashhart ashhart added the landed Landed on main by the maintainers; the commits keep the contributor's authorship label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

landed Landed on main by the maintainers; the commits keep the contributor's authorship

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants