From 98d1642ad6bea5695329e94275c2c8de14963010 Mon Sep 17 00:00:00 2001 From: jonathan308 <5055076+jonathan308@users.noreply.github.com> Date: Fri, 30 Oct 2026 01:55:14 -0700 Subject: [PATCH 1/2] Take the M5 Ultra verify-window layout for exact Qwen TP projections Pin mlx-swift-lm f98ced91 (one commit on the pinned d5bd32b8): AffineQuantizedVectors takes an architecture's own layouts ahead of its family's, and the M5 Ultra (applegpu_g17d) takes rows in registers (b:2:2:4, b:2:2:5) for a verify window's four and five vectors. The M5 Max and the M3 Ultra keep theirs. Measured on two M5 Ultra 256 GB serving Qwen3.8 27B tensor parallel (DevNet branch.9 with only this worker change): the one-request round 35.3 -> 33.2 ms, decode 75.8 -> 80.5 tok/s at 256 tokens and 62.7 -> 66.8 at 1,024, prefill unchanged; the 12 fixed greedy answers byte-identical, concurrent rows at 1/2/4/8 byte-equal to solo. AffineQuantizedVectorsTests expects br2s2v4/br2s2v5 on applegpu_g17d and ar2s4v4 on g17s and g15d, and tiles of four past five vectors on all three (its earlier whole-cohort expectation already failed on origin/dev: the SDK went back to tiles of four on 2026-10-26). Docs and a changelog fragment follow. Co-Authored-By: Claude Opus 5.5 --- .../cluster-qwen-m5-ultra-window-layout.md | 3 +++ docs/architecture/inference.md | 12 +++++++++--- .../AffineQuantizedVectorsTests.swift | 17 ++++++++++++----- libs/mlx-swift-lm | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 changelog.d/cluster-qwen-m5-ultra-window-layout.md diff --git a/changelog.d/cluster-qwen-m5-ultra-window-layout.md b/changelog.d/cluster-qwen-m5-ultra-window-layout.md new file mode 100644 index 0000000000..9ded5678e0 --- /dev/null +++ b/changelog.d/cluster-qwen-m5-ultra-window-layout.md @@ -0,0 +1,3 @@ +### Faster Qwen tensor-parallel decode on two M5 Ultra + +- Qwen3.8 27B tensor parallel on two M5 Ultra decodes about 6% faster for one request (75.8 to 80.5 tok/s at 256 tokens, 62.7 to 66.8 at 1,024). The exact decode projections take a layout measured on the M5 Ultra for a verify window's vectors (rows in registers). Outputs are unchanged byte for byte, and other chips keep their layouts. diff --git a/docs/architecture/inference.md b/docs/architecture/inference.md index ae8c401234..f5865e9101 100644 --- a/docs/architecture/inference.md +++ b/docs/architecture/inference.md @@ -1,6 +1,6 @@ # Provider inference engine -> Last updated: 2026-10-29 +> Last updated: 2026-10-30 How a chat-completion request is served inside the `darkbloom` provider process: one in-process engine (`mlx-swift-lm` @@ -3725,10 +3725,16 @@ multiply-add per weight and vector) and the words a lane takes per step (capped to the weight's quantization group). The M3 Ultra (family 15) and the M5 Max (17) take the dequantized weights at one word per lane, with layouts `a:4:4:1` for one vector, `a:2:4:4` for two to four and `a:2:4:5` for five, and tiles of -four (`a:2:4:4`) past five. The kernel also serves whole-cohort tiles (one tile +four (`a:2:4:4`) past five. The M5 Ultra (`applegpu_g17d`, family 17) has its +own table in `architectureLayouts`, read before the family's: rows in registers +for two to five vectors (`b:2:2:4`, `b:2:2:5`) and family 17's for the rest. +On two M5 Ultra 256 GB serving the 27B pair the table cut the one-request round +from 35.3 to 33.2 ms and raised decode from 75.8 to 80.5 tok/s at 256 tokens +(62.7 to 66.8 at 1,024), with identical outputs. +The kernel also serves whole-cohort tiles (one tile of eight, `b:4:4:8`, or tiles of sixteen, `b:2:4:16`, reading the weights once for up to 32 vectors; a tile that runs past the call's end skips its missing -vectors), but no family selects them: on two M5 Ultra 256 GB serving the 27B +vectors), but no table selects them: on two M5 Ultra 256 GB serving the 27B pair they lowered the four-request aggregate by 19 % (73.1 against 90.1 tok/s, identical outputs). Other families take the scaled inputs and the generic layouts. A layout (rows per SIMD group, SIMD groups, vectors per weight read, diff --git a/libs/darkbloom-cluster/Tests/DarkbloomClusterRuntimeTests/AffineQuantizedVectorsTests.swift b/libs/darkbloom-cluster/Tests/DarkbloomClusterRuntimeTests/AffineQuantizedVectorsTests.swift index c055a119f8..9c23b7eca0 100644 --- a/libs/darkbloom-cluster/Tests/DarkbloomClusterRuntimeTests/AffineQuantizedVectorsTests.swift +++ b/libs/darkbloom-cluster/Tests/DarkbloomClusterRuntimeTests/AffineQuantizedVectorsTests.swift @@ -36,7 +36,7 @@ struct AffineQuantizedVectorsTests { } @Test func layoutsAreValidForEveryVectorCountAndFamily() { - for architecture in ["applegpu_g15d", "applegpu_g17s", "applegpu_g16s", ""] { + for architecture in ["applegpu_g15d", "applegpu_g17s", "applegpu_g17d", "applegpu_g16s", ""] { for vectors in 1...64 { let layout = AffineQuantizedVectors.layout(vectors: vectors, inputs: 5120, outputs: 6144, bits: 4, architecture: architecture) @@ -45,15 +45,22 @@ struct AffineQuantizedVectorsTests { && layout.schedule != .sharedInputs, "\(architecture) M=\(vectors) \(layout)") } } - // The measured families read the weights once for a whole cohort's vectors (up to sixteen a - // tile past five), instead of once per four. - for architecture in ["applegpu_g15d", "applegpu_g17s"] { + // Past five vectors the measured tables keep tiles of four: whole-cohort tiles measured slower on a pair. + for architecture in ["applegpu_g15d", "applegpu_g17s", "applegpu_g17d"] { for vectors in 6...48 { let layout = AffineQuantizedVectors.layout(vectors: vectors, inputs: 5120, outputs: 6144, bits: 4, architecture: architecture) - #expect(layout.vectorsPerTile >= min(vectors, 8), "\(architecture) M=\(vectors) \(layout)") + #expect(layout.vectorsPerTile == 4, "\(architecture) M=\(vectors) \(layout)") } } + // Two M5 Ultra measured rows in registers fastest for a verify window's four and five vectors; the M5 Max + // keeps its family's table. + func window(_ architecture: String, _ vectors: Int) -> String { + AffineQuantizedVectors.layout(vectors: vectors, inputs: 5120, outputs: 6144, bits: 4, + architecture: architecture).description + } + #expect(window("applegpu_g17d", 4) == "br2s2v4" && window("applegpu_g17d", 5) == "br2s2v5") + #expect(window("applegpu_g17s", 4) == "ar2s4v4" && window("applegpu_g15d", 4) == "ar2s4v4") #expect(AffineQuantizedVectors.parseLayout("b:2:4:32") != nil && AffineQuantizedVectors.parseLayout("b:2:4:33") == nil) #expect(AffineQuantizedVectors.family("applegpu_g15d") == 15) #expect(AffineQuantizedVectors.family("applegpu_g17s") == 17) diff --git a/libs/mlx-swift-lm b/libs/mlx-swift-lm index d5bd32b81c..f98ced91b6 160000 --- a/libs/mlx-swift-lm +++ b/libs/mlx-swift-lm @@ -1 +1 @@ -Subproject commit d5bd32b81c5891b32955a7e69fe11a5e4b3193a1 +Subproject commit f98ced91b6a3b5d60bea087c98b9375a002fadd0 From 3420e337a580bae82008b0ff5e169d6f0516c68a Mon Sep 17 00:00:00 2001 From: David Tai Date: Fri, 30 Oct 2026 15:11:42 -0500 Subject: [PATCH 2/2] docs: name the baseline of each M5 Ultra layout figure The 35.3 ms round is the family layout on the same build; the decode figures compare against the 0.10.4-dev.branch.9 release (34.5 ms). Co-Authored-By: Claude Opus 5.5 --- docs/architecture/inference.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/architecture/inference.md b/docs/architecture/inference.md index f5865e9101..17716e8d40 100644 --- a/docs/architecture/inference.md +++ b/docs/architecture/inference.md @@ -3729,8 +3729,9 @@ four (`a:2:4:4`) past five. The M5 Ultra (`applegpu_g17d`, family 17) has its own table in `architectureLayouts`, read before the family's: rows in registers for two to five vectors (`b:2:2:4`, `b:2:2:5`) and family 17's for the rest. On two M5 Ultra 256 GB serving the 27B pair the table cut the one-request round -from 35.3 to 33.2 ms and raised decode from 75.8 to 80.5 tok/s at 256 tokens -(62.7 to 66.8 at 1,024), with identical outputs. +from 35.3 ms (family 17's layout, same build) to 33.2 ms. Against the +`0.10.4-dev.branch.9` release (34.5 ms) it raised decode from 75.8 to 80.5 tok/s +at 256 tokens (62.7 to 66.8 at 1,024), with identical outputs. The kernel also serves whole-cohort tiles (one tile of eight, `b:4:4:8`, or tiles of sixteen, `b:2:4:16`, reading the weights once for up to 32 vectors; a tile that runs past the call's end skips its missing