Skip to content

Bump mlx to b2c93bd1: build and hash each custom kernel variant once, bounded memo (gemma4-qat #189) - #7

Merged
jeethu merged 2 commits into
prismfrom
prism-189-kernel-hash-memo
Sep 30, 2026
Merged

jeethu merged 2 commits into
prismfrom
prism-189-kernel-hash-memo

Conversation

@jeethu

@jeethu jeethu commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Depends on numen-tech/mlx#5. Merge that PR first, with a merge commit so b2c93bd1 (and f5428f85) stay reachable, and then merge this one. The gemma4-qat branch perf/189-kernel-hash-memo pins this PR's head.

  • This bumps Source/Cmlx/mlx from 2f0e44f9 to b2c93bd1 (metal_kernel: build and hash each kernel variant once (gemma4-qat#189) mlx#5 head; the first commit c7f1b05 pinned f5428f85, the second commit bb14f0c moves to b2c93bd1):
    • fast::metal_kernel builds and hashes each kernel variant once per kernel object.
    • CustomKernel stores a shared source and a precomputed hash.
    • The memo is bounded (b2c93bd1, Codex P2): at most 64 shared_ptr-owned variants per kernel object, cleared when full. No raw entry pointer leaves the lock, and a pending array whose entry was evicted still evaluates.
    • MLXFast.metalKernel behaves the same. The memo key includes each template arg's kind, so int 1 and bool true stay distinct kernels, as they already were through the library cache.
  • tools/update-mlx.sh changes no generated source. The mlx change touches no JIT source. The only regenerated diff is the commit stamp in Metal.hpp.
  • I ran the script with LC_ALL=C. Under my shell's default locale, the zsh glob sorts gather_axis.cuh before gather.cuh. That reorders cuda_jit_sources.h against the committed file: the bytes are the same, but the order differs.
  • xcrun swift build succeeds. It still prints warnings, but they predate this PR, and none of them are in the changed files.

Testing is on the gemma4-qat side (perf/189-kernel-hash-memo, commit 715862f7, and re-run at 0596ed0d on this PR's head bb14f0c with the same results):

  • Full Swift suite passes. XCTest totals, as executed/skipped: NumenCoreTests 1506/61, NumenAppTests 1988/11, NumenStudioUITests 750, NumenSessionTests 649/4, NumenIndexTests 90, NumenMemoryTests 31, NumenDispatchTests 19, NumenCLITests 4. Swift Testing: ParoQuantMLXTests 127. Skips are models not provisioned on the host and opt-in soak/live-web runs.

  • ParoQuantMLXTests passes 3 of 3 runs (127 tests each). NumenDispatchTests passes 3 of 3 runs, and every budget is unchanged: decode 327/2/0/2, prefill 434/3/0 with waits 1-3, speculative k=4 418/5/0/5.

  • Greedy stdout from a Release numen-cli (--greedy --no-draft --max-tokens 128) is byte-identical between base a08b1ee and this PR for Granite 4.1 3B PARO, Qwen3.5 2B PARO and Gemma 4 E2B.

  • Host microbench, µs per call, Debug build on a loaded machine, so indicative only:

    Case Base: build Base: eval This PR: build This PR: eval
    Trivial kernel, 95 KB header 10.5 69.6 7.5 10.2
    Trivial kernel, no header 9.0 10.8 7.7 10.1
    PARO rotation 10.5 14.7 9.6 12.6

    At bb14f0c (bounded memo), same Debug microbench: 95 KB header eval 10.4–11.0, no header 10.4–11.0, PARO rotation 12.7–12.9 µs/call, unchanged from the unbounded memo. Greedy stdout is byte-identical base vs bb14f0c for the same three models on two prompt files.

    The quiet-machine A/B is still to do.

…l-explore#189)

Bumps Source/Cmlx/mlx to numen-tech/mlx#5 (fork/189-kernel-hash-memo): metal_kernel builds and hashes each kernel variant once. tools/update-mlx.sh (run with LC_ALL=C so the CUDA jit source order matches the committed file) changes no generated source; only the Metal.hpp commit stamp moves.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T07:08:59.425354Z c7f1b05 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

… gemma4-qat ml-explore#189)

Bumps Source/Cmlx/mlx to numen-tech/mlx#5 head b2c93bd1: the per-kernel variant memo now holds at most 64 shared_ptr-owned entries and is cleared when full (Codex P2). tools/update-mlx.sh (run with LC_ALL=C) changes no generated source; only the Metal.hpp commit stamp moves.
@jeethu jeethu changed the title Bump mlx to f5428f85: build and hash each custom kernel variant once (gemma4-qat #189) Bump mlx to b2c93bd1: build and hash each custom kernel variant once, bounded memo (gemma4-qat #189) Sep 29, 2026
@jeethu
jeethu merged commit d80a01e into prism Sep 30, 2026
@jeethu
jeethu deleted the prism-189-kernel-hash-memo branch September 30, 2026 10:26
jeethu added a commit that referenced this pull request Oct 4, 2026
…ero implied-bias factor gradient, gemma4-qat ml-explore#190)
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