Repository navigation
feat(hip): the MLX affine products: dot2 tiles, the gfx11 matrix-core GEMM tile, stream and K-parallel tiles - #621
Conversation
…, 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.
…it and dense, with tensor-parallel cuts core/quant reads a checkpoint's MLX affine projections (bits 2, 3, 4, 5, 6 and 8, any group) or dense ones, detects the format from the tensors, cuts a projection by output rows, by a rank's whole input groups or into its two K halves, splits an expert stack across ranks, and hands a backend the upload. Every cut keeps the codes and group tables byte for byte: a test quantizes with affine4_host and checks each cut dequantizes to the same bits as the rows and columns it covers, and it fails when a cut is off by one group.
…st, one family of bits at every row count core/registry selects, for a format, op (product, group, routed plan, routed with activation) and path (decode or prompt), the cheapest entry the GPU, the run's switches and the shape allow, by a per-GPU tuning table read at build time (core/tuning), so every rank picks alike. Its family rule checks that one (op, path) keeps one family of entries at every row count from 1 to 256 for each width and group: a row's bits never depend on how many rows share its launch. The rule's test fails when a tuning table lets another family take some rows.
… GEMM tile, stream and K-parallel tiles The MLX affine 2- to 8-bit products a model's projections run, chosen per product by the kernel registry over a per-GPU tuning table (gfx1030's for RDNA2, gfx1100's for RDNA3 to RDNA4): the decode row, column, stream and split tiles, the RDNA2 wide tile, the prefill dot2 GEMM and K-parallel tiles, the gfx11 matrix-core GEMM tile (compiler WMMA builtins, no rocWMMA), routed plans and products sharing x, with the routed gate and up's activation as an epilogue. The tile sources hold device code only; each kernel the Zig launches resolve is instantiated explicitly. hip-kernel-test checks every entry on the served models' shapes and a ragged sweep of every width and group against float64, the entries the registry picks between by rows for equal bytes, and a row's bytes alone and in a round of 2 to 32 rows.
… 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.
|
gfx1151 receipt (Strix Halo: Ryzen AI Max+ 395, Radeon 8060S, RDNA3.5), head 6254228, fresh Zig cache per step. This covers the RDNA3.5 row your receipt lists as not run.
|
…A header needed From ThinkOffApp's gfx1151 runs on this PR and ashhart#621: Ubuntu's HIP 7.1 keeps its device bitcode in LLVM's clang resource directory, and the kernels build there with -Dhip-device-lib set to it, without rocWMMA's header.
|
Thank you, @BlivionIaG. We read #621 (the MLX affine products on HIP) together with #617 last night, at
It missed 1.0.6, which froze with the release gate already running, and it's first in line for 1.0.7. We'll read this morning's docs commit ( |
|
Thanks, @BlivionIaG. We read #621 again at
Since #621 carries #617's commits, it waits on the one question on #617 about the SPDX lines in |
…e fork's hand ports The kernel was written for TensorFold after FLA's chunk_gated_delta_rule; no code came from vLLM or FLA, and the header only came along from the opengfx1030/vllm-rdna ports.
8089fa1 to
df83c6f
Compare
|
From our point of view for gfx1151 everything seems fine. Between our receipt heads (b731206, 6254228) and today's (5d05894, df83c6f), the only changes are |
# Conflicts: # zig/src/core/quant/quant.zig # zig/src/core/root.zig
…nd without a blank line)
…fill tile calls expf)
…refill kernel goes gatedDelta sent 64 rows or any prefill to gdn_prefill.hip (fp16 products, __expf), so a prompt cut on either side of 64 rows was a different sum. Every length now runs the fp32 recurrence. The new test cuts a 200-row prompt at 1, 63, 64, 65 and 136 rows and checks the rows and state equal one call's bits; it fails with the chunked kernel.
…aNet recurrence at every length)
|
@jkuepker the receipt still open on #621 is one you can run:
We have no gfx1201 card. Could you run |
|
gfx1201 receipt (Radeon AI PRO R9700, RDNA4), head da96b90, one card (
|
Thank you very much 🔥 |
|
gfx1150 receipt (Radeon 890M, RDNA 3.5 iGPU in a Ryzen AI 9 HX 370), head da96b90, the only GPU in the machine. This covers the gfx1150
I could not finish |
… and model checks The HIP branch's engine (#490) on #463's runtime and the kernel launches of #617 and #621: the lane rounds with MTP drafts, the paged attention cache and the radix prompt cache (#625), chunked prompts (#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 (#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.
…A header needed From ThinkOffApp's gfx1151 runs on this PR and #621: Ubuntu's HIP 7.1 keeps its device bitcode in LLVM's clang resource directory, and the kernels build there with -Dhip-device-lib set to it, without rocWMMA's header.
… and model checks The HIP branch's engine (#490) on #463's runtime and the kernel launches of #617 and #621: the lane rounds with MTP drafts, the paged attention cache and the radix prompt cache (#625), chunked prompts (#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 (#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.
…alls The loader step calls coreModule, which came into zig/build/hip.zig with the HIP affine products (#621), not yet on this branch; the helper is that one, unchanged. Co-authored-by: BlivionIaG <[email protected]>
Qwen3.5, Qwen3.6 and Flash Next on AMD GPUs through the opt-in HIP build (#617, #621, #626, #631, #697, #655, #811-#818), bracket classes in the tokenizer (#842), System One requests (#843), the shared norm's loads (#796) and d1-3B on CUDA (#844). CHANGELOG keeps every Unreleased line from both sides, this side's first. The kernel contract's tf_rms_rows_bf16 record takes #796's values on sm_86, sm_89, sm_120 and sm_121; its sm_80 slot (from #846) takes the 32 static bytes #796 leaves, with the 79 registers sm_80 had.
|
Thank you, @BlivionIaG, for the affine products, and @ThinkOffApp for the gfx1151 runs. It ships in TensorFold 1.0.12 under your name as We have no AMD card, so this lands on your runs and @ThinkOffApp's plus our host checks: Thank you, @jkuepker, for the gfx1201 run at this head on an R9700, the one chip whose dot2 tiles none of those cards take: Posted by Ash's AI Assistant Synthena |
…A header needed From ThinkOffApp's gfx1151 runs on this PR and ashhart#621: Ubuntu's HIP 7.1 keeps its device bitcode in LLVM's clang resource directory, and the kernels build there with -Dhip-device-lib set to it, without rocWMMA's header.
… 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.
…A header needed From ThinkOffApp's gfx1151 runs on this PR and ashhart#621: Ubuntu's HIP 7.1 keeps its device bitcode in LLVM's clang resource directory, and the kernels build there with -Dhip-device-lib set to it, without rocWMMA's header.
The contributor's affine commit landed above, its lines unchanged on top of ashhart#617 (its other two commits are ashhart#612 and ashhart#613, in main since 1.0.6); this keeps the PR's head in the history with no change to the tree.
… 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.
…alls The loader step calls coreModule, which came into zig/build/hip.zig with the HIP affine products (ashhart#621), not yet on this branch; the helper is that one, unchanged. Co-authored-by: BlivionIaG <[email protected]>
…rt#844 onto the candidate Qwen3.5, Qwen3.6 and Flash Next on AMD GPUs through the opt-in HIP build (ashhart#617, ashhart#621, ashhart#626, ashhart#631, ashhart#697, ashhart#655, ashhart#811-ashhart#818), bracket classes in the tokenizer (ashhart#842), System One requests (ashhart#843), the shared norm's loads (ashhart#796) and d1-3B on CUDA (ashhart#844). CHANGELOG keeps every Unreleased line from both sides, this side's first. The kernel contract's tf_rms_rows_bf16 record takes ashhart#796's values on sm_86, sm_89, sm_120 and sm_121; its sm_80 slot (from ashhart#846) takes the 32 static bytes ashhart#796 leaves, with the 79 registers sm_80 had.
The HIP affine line still said a hip-affine-test run on gfx1201 was owed. @jkuepker ran it on 14 Oct on an RDNA4 Radeon AI PRO R9700 (ashhart#621): hip-affine-test 30 of 30, hip-kernel-test 61 of 61, hip-gpu-test 36 of 36. The line now says so and thanks him.
What this changes
The MLX affine 2- to 8-bit products a model's projections run, the second kernels slice tracked in #491, chosen per product by the registry (#613) over a per-GPU tuning table:
The tile sources hold device code only; each kernel the launches resolve is instantiated explicitly.
Stacks on #617 and #613 (their commits are included here until they land); review the last commit.
Receipt
mainat c37d0a4 (+ build(hip): -Dhip-arch accepts gfx1030 (RDNA2) and gfx1100 (RDNA3) #607, feat(hip): a caps table from RDNA2 to RDNA4, keyed by exact gfx name #609, feat(hip): what a model engine needs from the runtime: graphs, device copies, mapped memory, device queries #611, feat(hip): the model-free kernels on #463's runtime: attention, DeltaNet, norms, RoPE, MoE routing and decode plans #617, feat(core): weight formats behind one interface, MLX affine 2- to 8-bit and dense, with tensor-parallel cuts #612, feat(core): a kernel registry that picks a product's tile by tuned cost, one family of bits at every row count #613), head 6254228. Zig 0.17.0, HIP 7.14.60850 (TheRock), Linux 7.1.7.hip-kernel-test(57 tests, the 42 of feat(hip): the model-free kernels on #463's runtime: attention, DeltaNet, norms, RoPE, MoE routing and decode plans #617 included), on both GPUs below:hip-kernel-test57/57,hip-gpu-test30/30,hip-affine-test27/27.hip-kernel-test57/57,hip-gpu-test30/30,hip-affine-test27/27.zig build test test-golden -Dcpu=apple_m1134/134 steps; Linuxzig build test32/32 steps, 331/331 tests.zig fmt --checkclean.lean_check.py: 544 problems, the same asmain.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (No engine path; a row's bytes at any row count are checked here.)