Skip to content

feat(hip): the MLX affine products: dot2 tiles, the gfx11 matrix-core GEMM tile, stream and K-parallel tiles - #7

Merged
BlivionIaG merged 15 commits into
mainfrom
hip-kernels-affine
Oct 16, 2026
Merged

BlivionIaG merged 15 commits into
mainfrom
hip-kernels-affine

Conversation

@BlivionIaG

Copy link
Copy Markdown
Owner

Mirror of ashhart#621 (same branch), to rehearse the review on the fork.

What this changes

The MLX affine 2- to 8-bit products a model's projections run, the second kernels slice tracked in ashhart#491, chosen per product by the registry (ashhart#613) over a per-GPU tuning table:

  • decode: the row, column, stream (up to four products sharing x, and a stacked gate and up with its activation as the epilogue) and split tiles, and RDNA2's wide tile;
  • prompt: the dot2 GEMM tile, the K-parallel tiles of short prompts, and gfx11's matrix-core GEMM tile with the compiler's WMMA builtins, so no rocWMMA (Ubuntu's ROCm 7.1 package, which lacks its header, builds it);
  • routed plans over stacked experts, and the embedding gather;
  • tuning tables for gfx1030 (RDNA2) and gfx1100 (RDNA3, RDNA3.5, RDNA4 on their dot2 tiles), read at build time so every rank picks alike.

The tile sources hold device code only; each kernel the launches resolve is instantiated explicitly.

Stacks on ashhart#617 and ashhart#613 (their commits are included here until they land); review the last commit.

Receipt

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off. (No engine path in this change.)
  • Drafted output equals "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.)
  • No precision traded for speed. Each tile is checked against float64 at the fp32 sum's bound.
  • Prompt processing is no slower than the last release. (No prompt path in this change.)
  • The description says which platforms I ran and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

…, 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.
…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.
…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.
# Conflicts:
#	zig/src/core/quant/quant.zig
#	zig/src/core/root.zig
…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.
@BlivionIaG
BlivionIaG merged commit 4793b82 into main Oct 16, 2026
2 checks passed
ashhart pushed a commit that referenced this pull request Nov 28, 2026
…dy shaders for ashhart#1544

Rewrites the omarchy-derived Vulkan compute shaders from the behavior spec,
from cast/copy through the gated-delta state machines to the argreduce pair.
omarchy_trig.h becomes vulkan_trig.h (single inv_freq helper, Synthena #6),
gated_delta_prefill_ash becomes gated_delta_prefill_oracle, accepting both
-DASH_QWEN35 and -DORACLE_QWEN35. PRESERVE_F32 requests OpExecutionMode
DenormPreserve (f32) via spirv_execution_mode; sdpa_decode_native pins the
single-key bit-exact V transport (Synthena #7) and the 7168-key shared bound.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant