Skip to content

EXLR8: reduce projection barriers at 1–4 rows - #789

Merged
ashhart merged 2 commits into
ashhart:mainfrom
mrv777:perf/exlr8-double-buffer
Oct 16, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
mrv777:perf/exlr8-double-buffer

Conversation

@mrv777

@mrv777 mrv777 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Alternate input tiles only in the 1-, 2- and 4-row EXLR8 projection kernels, reducing barriers from 2B+1 to B+1 without changing arithmetic or threadgroup memory. The 8/16-row kernels retain baseline storage and barriers, addressing the reported M3 Ultra slowdown in the ungated version. Their optimized AIR function bodies, including helpers, match baseline exactly with the installed compiler. Split kernels are unchanged.

On M1 Max, repeated-dispatch synthetic projections (3-bit, 48 blocks, 32 jobs; F32/BF16/F32 outputs) used 9.2%/2.0%/3.5% less GPU time at 1/2/4 rows, respectively: three paired trials, identical-kernel controls within 0.7%. The restored 16-row repeated-dispatch control stayed within 0.2% of baseline. Single-dispatch results are noisier; these resident microbenchmarks do not establish model throughput gains. The former 16-row speedup claim does not apply to this revision.

Validated on M1 Max, Zig 0.17.0, -Dcpu=apple_m1, against 1.0.10 (f930fbb7):

  • FP64 references and row windows 1–16 pass, including the capacity boundary. A wrong-inactive-tile control fails.
  • API and Shader Validation pass; 324 guarded cases match 1,557,504 values bit-for-bit.
  • Native builds and goldens pass, with zero unexpected differences. Full suites: 1,953 passed, eight skipped; both commands fail only on the inherited checkpoint logging diagnostic.
  • Formatting passes; zero new lean findings (527 inherited).

The gated version still needs an M3 hardware retest. Other GPUs, actual four-set execution and end-to-end generation are untested. Raw logs remain local.

@ashhart

ashhart commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Thank you, @mrv777. The EXLR8 projection alternates two input tiles, so the barrier after the load covers a tile before it is reused two blocks later (zig/kernels/metal/core/exlr8_projection.metal, head 596f72d23).

This is not in 1.0.10. 596f72d23 is your head. It is exact, and on an M3 Ultra it is 3% to 8% slower at 8 to 16 rows. A version gated on row count is what we can take.

@ashhart ashhart mentioned this pull request Oct 14, 2026
@mrv777
mrv777 force-pushed the perf/exlr8-double-buffer branch from 596f72d to a3d1241 Compare October 14, 2026 13:39
@mrv777 mrv777 changed the title EXLR8: reduce barriers in Metal projections EXLR8: reduce projection barriers at 1–4 rows Oct 14, 2026
@ashhart
ashhart merged commit 629cc8d into ashhart:main Oct 16, 2026
4 checks passed
ashhart added a commit that referenced this pull request Oct 16, 2026
@ashhart

ashhart commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Thank you, @mrv777. Gating the alternation to capacities 1 to 4 is the version we asked for.

It ships in TensorFold 1.0.12 under your name (01bc5e520, 74a5e09d8). Our a36124df9 wraps three lines past 120 columns, and your head is merged after it with no change to the tree (629cc8d37), so this pull request shows as merged.

On an M3 Ultra all 45 cases of tf-exlr8-check give the same bytes as the build before your change, and they match our runs of your first version on that chip and on an M5 Max. One-set kernel GPU time, in a base, tip, tip, base order over 12 layouts: one row takes 2% to 5% less, two rows up to 2% less, four rows between 6% less and 2% more by layout, and 8 and 16 rows the same as the base, where the first version was 3% to 8% slower.

The serving rule sends 1-to-4-row windows of jobs with 32 or more blocks (and at most 160 jobs) to the split kernels, which this leaves alone. Forced onto this kernel, your K3 case took 3.6% less at one row; served, that case takes a split kernel and its time is unchanged.

Posted by Ash's AI Assistant Synthena

BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
@mrv777
mrv777 deleted the perf/exlr8-double-buffer branch November 26, 2026 22:24
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