Repository navigation
docs: experimental Metal associate kernel and benches - #41
Merged
Merged
Conversation
Add an isolated experiments/metal-kernels prototype (MSL + CUDA source, Bend product and bang harnesses, Mac results) and a PERF_NOTES section. No product Run path change, no LAWS/PROOF edits, no release cut.
jkbennitt
enabled auto-merge
November 10, 2026 05:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Jason asked compute-heavy bots to try an AI-written GPU kernel on unsga3-bend (inspired by a custom CUDA kernel that cut an OCR loop from hours to minutes). This PR is the measured prototype: a hand-written Metal associate kernel on the Mac mini M4, compared with the current Bend CPU path and Bend's own
!Metal backend.What changed
experiments/metal-kernels/(MSL + CUDA source, Swift host, Python reference, Bend product/bang harnesses, Mac results).docs/PERF_NOTES.mdsection with the tables.src//LAWS.bend/PROOF.bendedits, no productRunpath change, no release cut, no CHANGELOG version section.Hot spot
Fresh
--threads 1profiles (bend 2.0.40) picked association (perp distance + argmin, plus niche-count histogram) as the largest uniform map a kernel can honestly target. At oracle DTLZ2 92×150 it is 16–18% of wall;nds(23–27%) is divergent andnichefill (25–27%) is sequential/RNG-ordered.Headline numbers (JMac-mini M4, 2026-11-10 00:48–00:52 America/New_York)
Hand MSL e2e vs Bend product (current path): 1.51× at 184×91 (DTLZ2 combined pool), 50.5× at 2048×276, 277× at 32k×3003. Hand MSL e2e vs Bend
!Metal: 17.9× at 184×91; Bend!stack-overflows at 2048×276 and 32k×3003. Full table, ranges, checksums, and break-even:experiments/metal-kernels/results/TABLES.mdand the new PERF_NOTES section.Correctness
sum_idx. Observed max abs distance ≤ 5.6e-8 (tolerance abs 1e-6 / rel 1e-5).src/edits).verifystill runs the seed-1 yardstick.CUDA
associate.cuis the same algorithm.nvccis not on the box; a CUDA toolkit is not a cheap install. No compile-check, no CUDA timings claimed.Lane
Low risk: non-production experiment + docs only. Nothing here is imported by
src/algorithm.bend. Please auto-merge on greenverify.