Skip to content

AffineQuantizedVectors: rows in registers for a verify window on M5 Ultra - #373

Merged
davidtai merged 1 commit into
mainfrom
perf/aqv-m5-ultra-window-layout
Oct 30, 2026
Merged

davidtai merged 1 commit into
mainfrom
perf/aqv-m5-ultra-window-layout

Conversation

@jonathan308

Copy link
Copy Markdown

Proposed changes

AffineQuantizedVectors takes its layout (rows per SIMD group, SIMD groups, vectors per weight read, schedule) from
a per-family table. Family 17 covers both the M5 Max and the M5 Ultra, and its entries were measured on an M5 Max.

On two M5 Ultra 256 GB (applegpu_g17d) serving the Qwen3.8 27B tensor-parallel pair, the rows-in-registers
schedule (b:2:2:4, b:2:2:5) is faster for a verify window's four and five vectors than the family's
a:2:4:4 / a:2:4:5.

This PR adds a table keyed by architecture, checked ahead of the family table. Only applegpu_g17d has an entry; the
M5 Max (applegpu_g17s) and the M3 Ultra keep theirs. A layout only decides which threads compute what. The kernel
pins every operation's order, so results are unchanged.

Measured on the pair (installed Darkbloom DevNet build branch.9 with only this change in the cluster worker;
one request; medians):

a:2:4:4 (family table) b:2:2:4 (this PR)
One-request MTP round (median of ~540 rounds) 35.2 / 35.4 ms 33.2 ms
Decode, 256 tokens (3 runs) 75.8 tok/s 80.5 tok/s
Decode, 1,024 tokens (3 runs) 62.7 tok/s 66.8 tok/s
12 fixed greedy answers reference byte-identical
Concurrent rows at 1/2/4/8 requests byte-equal to solo byte-equal to solo

The layout sweep (b:2:4:4, b:2:8:4, b:1:4:4, b:4:4:4, a:4:4:4, a:1:4:4, a:2:8:4, a:2:2:4,
a:1:8:4, t:2:4:4, and b:4:4:1 for one vector) produced identical outputs in every case. Only the
rows-in-registers schedule with two rows per SIMD group was faster.

The cluster's byte-parity tests already cover every layout, schedule and tile. d-inference pins this commit (f98ced91) and adds
an expectation that applegpu_g17d resolves br2s2v4 for four vectors while applegpu_g17s and applegpu_g15d
keep ar2s4v4 (AffineQuantizedVectorsTests.layoutsAreValidForEveryVectorCountAndFamily).

Submitted by Claude Opus 5.5 with the fork owner's explicit approval to push and open PRs in the Layr-Labs MLX forks
(2026-10-30). The AI-usage confirmation below is left for the owner.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes (swift-format lint with .swift-format passes; the pinned pre-commit was not run)
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

AI usage

  • I have read this PR description in full and approve it as my own, and it
    accurately describes the code changes.
  • AI usage disclosure: drafted with Claude Opus 5.5 (overnight benchmarking and the layout sweep on the pair, the
    table change and this description). swift-format lint with the repo's .swift-format passes; the pinned
    pre-commit version was not run locally.

…ltra

Two M5 Ultra 256 GB (applegpu_g17d) serving the Qwen3.8 27B tensor-parallel pair measured the rows-in-registers schedule fastest for a verify window's four and five vectors: the one-request round went from 35.3 to 33.2 ms (medians of about 540 rounds, two runs each), decode from 75.8 to 80.5 tok/s at 256 tokens and from 62.7 to 66.8 at 1,024. Every output was byte-identical: a layout only decides which threads compute what.

The table is keyed by architecture ahead of the family's, so the M5 Max (applegpu_g17s) and the M3 Ultra keep theirs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.

2 participants