Skip to content

feat(core): a kernel registry that picks a product's tile by tuned cost, one family of bits at every row count - #613

Merged
ashhart merged 2 commits into
ashhart:mainfrom
BlivionIaG:core-registry
Oct 10, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
BlivionIaG:core-registry

Conversation

@BlivionIaG

Copy link
Copy Markdown
Contributor

What this changes

zig/src/core/registry.zig and zig/src/core/tuning.zig: a kernel registry, the registry shared-code slice tracked in #491. Backend-neutral; no backend calls it yet (the HIP kernels slice is its first user).

  • A backend lists entries: id, format, op (product, group sharing x, routed plan, routed with its activation), path (decode or prompt), family, and what the GPU, the run's switches and the shape must allow.
  • select takes the cheapest allowed entry by a per-GPU tuning table read at build time from .zon; nothing is autotuned, so every rank picks the same entry.
  • The family rule (verify) checks that each (op, path) keeps one family of entries, entries that write the same bits for any row, at every row count from 1 to 256, for widths 2 to 8 and groups 32, 64 and 128. A row's bits then never depend on how many rows share its launch.

Stacks on #612 (its commit is included here until it lands); review the last commit.

Receipt

  • Environment: base main at c37d0a4 (+ feat(core): weight formats behind one interface, MLX affine 2- to 8-bit and dense, with tensor-parallel cuts #612), head fde39a1. Zig 0.17.0, macOS on Apple silicon and Linux 7.1.7.
  • Exactness: "the family rule refuses a path whose family changes with the rows" builds a tuning table in which another family takes rows 9 and up, and expects the refusal; with the rule's family comparison removed, it fails.
  • Decode and prompt speed: not applicable (no backend uses it yet).
  • Tests run: macOS zig build test test-golden -Dcpu=apple_m1 133/133 steps; Linux zig build test 31/31 steps, 310/310 tests. zig fmt --check clean. lean_check.py: 544 problems, the same as main.
  • Not run, and why: device runs (no backend calls it in this change).

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off. (No engine path touched.)
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (No engine path touched; the family rule is what keeps concurrent equal to solo once a backend uses it.)
  • No precision traded for speed.
  • Prompt processing is no slower than the last release. (No prompt path touched.)
  • 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.

…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.
@ashhart

ashhart commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Thank you, @BlivionIaG. The kernel registry is merged into main (9fd141b) on top of #612, your commit as it was, and it ships in 1.0.6. The family rule is the part we like most: a row's bits can't depend on how many rows share its launch, checked at every row count from 1 to 256, and it is the same contract our lane kernels keep. Picking only from a build-time tuning table, so every rank picks the same entry, fits the tensor-parallel case. Gates as in #612.

ashhart added a commit that referenced this pull request Oct 16, 2026
The contributor's affine commit landed above, its lines unchanged on top of #617 (its other two commits are #612 and #613, in main since 1.0.6); this keeps the PR's head in the history with no change to the tree.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…'s tile by tuned cost, one family of bits at every row count

Thanks @BlivionIaG.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
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.
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.

2 participants