Skip to content

feat(core): weight formats behind one interface, MLX affine 2- to 8-bit and dense, with tensor-parallel cuts - #612

Merged
ashhart merged 1 commit into
ashhart:mainfrom
BlivionIaG:core-quant
Oct 10, 2026
Merged

ashhart merged 1 commit into
ashhart:mainfrom
BlivionIaG:core-quant

Conversation

@BlivionIaG

@BlivionIaG BlivionIaG commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

zig/src/core/quant: weight formats behind one interface, the core/quant shared-code slice tracked in #491. Backend-neutral; no backend calls it yet (the HIP kernels slice is its first user).

  • Reads a checkpoint's MLX affine projections (bits 2, 3, 4, 5, 6 and 8, any group size) or dense ones, and detects the format from the tensors.
  • Cuts a projection for tensor parallelism: by output rows, by a rank's whole input groups (whose fp32 outputs the ranks sum), into the two K halves of a fused projection, and an expert stack across ranks with the shared expert kept on rank 0.
  • Hands a backend the upload through an Uploader; device addresses are u64.

Shapes follow safetensors.max_rank.

Receipt

  • Environment: base main at c37d0a4, head 2f9ba43. Zig 0.17.0, macOS on Apple silicon.
  • Exactness: quant/exact_test.zig quantizes a random 8 x 512 matrix with affine4_host.quantize and checks that every cut (row spans; rank column groups at world 1, 2, 4 and 8; both K halves) dequantizes through affine4_host.dequantize to the same bits as the rows and columns it covers. Shifting a rank's group tables by one group makes it fail.
  • 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, 306/306 tests (the module's 12 included). 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.)
  • No precision traded for speed. Cuts copy codes and group tables byte for byte.
  • 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.
@ashhart

ashhart commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Thank you, @BlivionIaG. core/quant is merged into main (490853d), your commit as it was, and it ships in 1.0.6. It's backend-neutral, and its exact test (every tensor-parallel cut dequantizing to the same bits as the rows and columns it covers, failing on a one-group shift) is the right guard. With #613 and #625 on top, the Mac host gates pass, the Linux tests pass 416 of 416, and on a GB10 Nemotron's 29 served replies and four release prompts equal main's, so nothing that runs today changed.

@ashhart ashhart mentioned this pull request Oct 10, 2026
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
…LX affine 2- to 8-bit and dense, with tensor-parallel cuts

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