Skip to content

perf(colibri): K2 — 1×4 union tile in the planar IDOT matmul (bit-identical) - #1088

Merged
JustVugg merged 1 commit into
devfrom
perf/k2-union-tile
Aug 18, 2026
Merged

JustVugg merged 1 commit into
devfrom
perf/k2-union-tile

Conversation

@JustVugg

Copy link
Copy Markdown
Owner

The idea

The prefill union delivers each expert nr = 2..16 activation rows, and the per-row kernel re-paid the weight block's load + mask for every one of them — which is why measured GMAC/s was flat in S. K2 pays it once per 4 rows: inside matmul_i4p_idot, rows go 4 at a time (one accumulator each, the masked lo/hi weight forms shared across the four vpdpbusd pairs), with a per-row remainder identical to the old path.

Dispatch untouched — every planar IDOT caller gets the tile for free; S<4 falls through to the exact per-row loop. Structurally this is the piece llama.cpp cannot copy: their wave-prefill rows are redundant replays, so a tile over them would only speed up wasted work; the union's rows are genuinely distinct at 1× I/O.

Measured (harness vs the pair-layout IDOT baseline, i7-1355U AVX-VNNI)

S baseline K1+K2 planar tile ratio
2 76.9–83.3 GMAC/s 145.6–153.2 1.84–1.89×
4 72.3–81.7 193.0–253.2 2.67–3.10×
8 87.8–89.4 229.3–248.5 2.57–2.83×

0 bit mismatches at every S and shape (integer sums — bit-identical by associativity). Matches the audit prototype's 2.70–2.99× prediction at S=4.

Verification

  • test_int_kernel_exact now runs the matmul comparison at S=6 (4-row tile main + 2-row remainder): 3,968 checks, 0 failures — and the ARM job from ci: ARM oracle job + integer-kernel bit-exactness gate (closes #1081) #1083 keeps holding the same bar with NEON live (the tile is gated coli_dpbusd256, so non-VNNI builds keep the per-row loop verbatim)
  • glm_tiny e2e at int4: tokens byte-identical vs unpatched dev, [K1] activation line confirming the planar path actually ran

Series: 0.1 ✅ · K1 #1079 ✅ · #1086 fixes ✅ · this PR = K2 · next: K3 fusion on the FUSED3 (#1082) shape, then the perplexity ablation unlocking g_i4s=1 + fmt=4/gs64 planar.

🤖 Generated with Claude Code

…ntical)

The prefill union delivers nr=2..16 rows per expert, and the per-row
kernel re-paid the weight block's load+mask for every row — measured
GMAC/s was flat in S. The tile pays it once per 4 activation rows:
inside matmul_i4p_idot, rows are processed 4 at a time (one accumulator
each, the masked lo/hi weight forms shared), with a per-row remainder
identical to the old path. Dispatch untouched: every planar IDOT caller
gets the tile for free, S<4 falls through to the exact per-row loop.

Integer sums, so bit-identical by associativity — asserted in-tree:
test_int_kernel_exact now runs the matmul comparison at S=6 (4-row tile
main + 2-row remainder), 3,968 checks, 0 failures.

Measured vs the pair-layout IDOT baseline (harness, this box):
  S=2: 1.84-1.89x | S=4: 2.67-3.10x | S=8: 2.57-2.83x  (peak 253 GMAC/s)
matching the audit prototype's 2.70-2.99x prediction at S=4. glm_tiny
e2e at int4: tokens byte-identical vs unpatched dev, [K1] activation
line confirming the planar path ran.

Gated with the K1 planar family (coli_dpbusd256: AVX-VNNI or
AVX-512VL+VNNI); other builds keep the per-row loop unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <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.

1 participant