Repository navigation
feat(hip): the model-free kernels on #463's runtime: attention, DeltaNet, norms, RoPE, MoE routing and decode plans - #617
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.
131b913 to
b731206
Compare
… 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 b731206, 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.
|
Thanks, @BlivionIaG. 1.0.7 went out this morning as a one-fix release for Living Weights, so #617 and #621 moved to 1.0.8 and we read them again at today's heads,
One question before it lands.
Once that's settled, #617 and #621 go into 1.0.8 together, with #630's events beside them. |
…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.
f0afbc4 to
5d05894
Compare
|
@ashhart yes, it was written for TensorFold. It follows FLA's chunked gated delta rule, the stages I'd hand-ported in my fork (opengfx1030/vllm-rdna), and the header came from those files. No code was translated: the WY step is a forward substitution, not FLA's blockwise inverse; Header dropped in |
|
Hello @BlivionIaG, Thank you for the model-free HIP kernels, and for the gfx1100 and gfx1030 runs. Two sums still disagree. gated_delta.hip walks the sequence in fp32. gdn_prefill.hip multiplies fp16 operands and decays with __expf (gdn_prefill.hip:216, gdn_prefill.hip:229). gatedDelta sends 64 rows, or any prefill, to the chunked kernel when the head size is 128 (recurrence.zig:55). A prompt cut on either side of 64 rows is a different sum. Please keep one fp32 recurrence at every length. The flat attention tile calls expf (attention_fa.hip:421). The paged tile calls __expf (prefill.hip:171, prefill.hip:175). Please call expf in both. A push with those two, and a hip-kernel-test rerun on gfx1100 or gfx1030, is the update we need. Thank you again. |
…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.
Sounds good to me, launched a rerun I expect some slight hit in prefill. |
d91b074: every length runs the fp32 recurrence (
5537d6a: the paged prefill tile calls
Pushed. |
|
Hello @BlivionIaG, Thank you for turning both changes around so quickly. One fp32 recurrence at every length, with gdn_prefill.hip gone, and a test that cuts a 200-row prompt at 1, 63, 64, 65 and 136 rows and checks the rows and state against one call's bits, is exactly the gate we wanted. The paged tile calling expf matches the flat one. This is ready. It lands first in the HIP series, on your gfx1100 and gfx1030 receipts plus our host checks. We make three small fixes when it lands: the unused line at zig/src/hip/launches.zig:43, and wraps at zig/build/hip.zig:79 and zig/src/hip/kernel_tests/gdn.zig:110 and :114. #631, #697 and #655 follow it. Thank you again. |
… 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.
… 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.
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 model-free HIP kernels and the quick turn on the fp32 recurrence and the paged tile's Your six commits ship in TensorFold 1.0.12 under your name: We have no AMD card, so this lands on your gfx1100 and gfx1030 runs plus our host checks. The HIP host tests and @jkuepker ran these kernels on gfx1201 (an R9700) at #621's head, which carries them: Posted by Ash's AI Assistant Synthena |
… 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.
The contributor's six commits landed above with the same code, followed by our fix-ups; this keeps the PR's head in the history with no change to the tree.
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.
The contributor's two commits landed above, the kernels' lines on the post-ashhart#617 source groups, followed by our wraps; this keeps the PR's head in the history with no change to the tree.
…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.
What this changes
The model-free kernels a model engine composes, on #463's runtime: the first kernels slice tracked in #491, everything but the MLX affine products (the next slice).
-Dhip-archwith the caps table's instruction switches, embedded as one code object a source group and launched from Zig with Add model-free Zig HIP runtime and GPU qualification #463'sModuleandlaunch: elementwise ops and casts, norms and the merged decode tails, RoPE, attention (the flat decode walk; the planned walk over a page table, reading a KV head once for the query heads that share it; the 64-row prompt tile flat and paged), the DeltaNet recurrence in fp32 at every length, the linear attention's conv and gates, the MoE router, pick and route, argmax and top-k, and a lane round's plan kernels.launches.zigresolves every kernel at load;Launcher.Choicespicks between two kernels that give the same bits (merged decode launches, the 64-row prompt tile).extern "C"(tf_*), and each template kernel the launches resolve is instantiated explicitly; no host launchers or C API.ops/checks shapes for each launch;arena.zighands out a forward's scratch front to back, and a counting stream measures what a forward takes without launching.-Dhip-device-libnames ROCm's device bitcode for layouts other than TheRock's (Arch keeps it in<rocm>/amdgcn/bitcode);zig/tests/hip_kernels.mdhas the notes.Stacks on #611 (its three 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), head d91b074. Zig 0.17.0, HIP 7.14.60850 (TheRock), Linux 7.1.7.hip-kernel-test(43 tests), on both GPUs below:hip-kernel-test43/43,hip-gpu-test30/30,hip-affine-test27/27.hip-kernel-test43/43,hip-gpu-test30/30,hip-affine-test27/27.zig build test -Dcpu=apple_m11013/1015 tests (2 skipped),test-golden0 unexpected differences (the launches and ops compile in the host tests); Linux: CIzigpasses. CIfmtpasses.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; the kernels a round uses keep a row's bits at any row count, which these tests check where they apply.)