Skip to content

EXL3: share decoded weights across prefill rows - #729

Merged
ashhart merged 2 commits into
ashhart:mainfrom
mrv777:perf/exl3-prefill-weight-sharing
Oct 18, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
mrv777:perf/exl3-prefill-weight-sharing

Conversation

@mrv777

@mrv777 mrv777 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Decode each weight tile once for four eight-row SIMDgroups in larger plain prefill windows. Preserve each row’s compensated arithmetic, scratch layout and output bits.

Use the 128-thread kernel only when its pipeline supports that capacity. Smaller windows, filtered/indexed work and unavailable pipelines retain the existing path. Keep the benchmark’s arithmetic reference independent of the new kernel.

M1 Max validation on #718 (4dbeca49), 32-core GPU/32 GB, macOS 26.7, Zig 0.17.0:

  • 21 GPU and 13 host tests pass. 177 large full-reference cases cover supported widths, BF16/F32 and partial tiles. Regressions check guards, resumed windows and gather/scatter; a wrong-row mutant is rejected. All 34 tests also pass with Metal validation on a clean merge with main (0efbd447); the benchmark compiles.
  • Five batches of 20 alternating pairs across 20 prefill cases give median GPU-time ratios of 1.23–2.05× versus EXL3: use branch-free trellis window extraction #718. Longer repeats of the weakest case give 1.228–1.233×; identical-kernel controls stay near 1.00×. Memory pressure stays normal.
  • Fresh full suite: 1,313 pass, two skips, only the known GLM failure (GLM: fix sparse attention thread limit on M1 #704). Native/golden checks pass; the final recheck finds no new failures.

Depends on #718, included as a separate commit; #681 has merged. This follow-up commit contains the prefill change. Lean check: 534 inherited findings, zero added. Timings use resident synthetic mul1/3-bit BF16 projections with packed-sign scales. Other chips and model throughput are unmeasured. Raw logs stay local.

satindergrewal added a commit to satindergrewal/TensorFold that referenced this pull request Oct 13, 2026
…3 experts

Checked ash hart PRs open+closed (read-only). Direct hits on our
problems, all OPEN, branch BHCC2025/TensorFold exl3-cuda-experts:
- ashhart#741 EXL3 routed experts behind experts.Grouped: gate+up+SwiGLU
  ONE kernel, down on pair rows, each expert's rows rotated by its
  own suh INLINE (register-resident rot for 1-2 pair chunks - the
  problem we had deemed impossible tile-incrementally). Rides on
  grouped.zig's Plan (in our tree). 297cu+124zig lines, with an
  exactness test harness (tf-cuda-test exl3-experts) - 367,872
  values within FP64 bounds, alone==grouped byte-equal.
- ashhart#740 EXL3 projections behind qlinear (the stacked base).
- ashhart#718 branch-free trellis window extraction (perf).
- ashhart#729 share decoded weights across prefill rows (perf).
- ashhart#728 MiMo-V2.6 CUDA EXL3 two-GPU (another full CUDA EXL3 family).
- ashhart#765 GLM CUDA multi-rank doorbells; ashhart#770/777/768 nemotron CUDA
  single-launch shared rounds + batched MTP drafting (patterns for
  our later concurrency work).
PLAN: vendored exl3_experts.cu/.zig + exl3.cuh into our tree (this
commit, unwired). Next: build wiring (fatbin + mod), port moeBlock
to Grouped.decode with the router->plan plumbing from grouped.zig,
run their exl3-experts test on our checkpoint, parity, bench. Our
own grouped kernels (stage-1 parity) stay as fallback.
@ashhart

ashhart commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Thank you, @mrv777, the guarded 128-thread prefill path shares decoded weights while retaining the older path for unsupported work.

We checked 8eaf366. exl3_projection.zig:154-161 rejects an unsuitable optional pipeline, and :328-337 selects it only for plain, non-indexed, non-routed windows of at least 32 rows.

This is ready as the Metal part of the shared EXL3 composition, with your contribution and @vcruz305's original work credited. We will retain row/output, guard, gather and cache controls and qualify the final source before family integration. Please keep the synthetic timing workload identified separately from model throughput; the shared CUDA selection proceeds through #837/#741/#806 on equal tensors and bits.

Posted by Ash's AI Assistant Synthena

@ashhart ashhart mentioned this pull request Oct 17, 2026
@mrv777
mrv777 marked this pull request as ready for review October 18, 2026 03:36
@ashhart
ashhart merged commit f12fcc5 into ashhart:main Oct 18, 2026
ashhart added a commit that referenced this pull request Oct 18, 2026
…lamaV3's notice

One line for the CUDA module (#837, #806, #741, #740) and one for Metal's shared prefill tiles (#729). The
third-party notice names the native scan, the CUDA kernels and their Zig side beside the decoders it already
lists, under the same Turboderp attribution.
@ashhart

ashhart commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Thank you, @mrv777, for sharing decoded EXL3 tiles across prefill rows and retaining the row-count checks.

We merged #729 for 1.1.0 in f12fcc5. The Metal projection now uses the same checkpoint scan and parts as CUDA, with packed sign planes retained in c56cb1a.

The reported M3 Ultra operator run passes 21/21 checks; 32, 33 and 128-row comparisons retain bit equality with the eight-row kernel on M3 and M5 Ultra. Metal family adoption remains separate work.

Apple M3/M5 Ultra: 32/33/128-row comparisons had zero mismatches; whole-model Metal EXL3 adoption remains separate.

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
…lamaV3's notice

One line for the CUDA module (ashhart#837, ashhart#806, ashhart#741, ashhart#740) and one for Metal's shared prefill tiles (ashhart#729). The
third-party notice names the native scan, the CUDA kernels and their Zig side beside the decoders it already
lists, under the same Turboderp attribution.
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