• About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us
AimactGrow
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing
No Result
View All Result
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing
No Result
View All Result
AimactGrow
No Result
View All Result

How Ok-Search Brings Many years of Kernel Experience to Apple Silicon – The Berkeley Synthetic Intelligence Analysis Weblog

Admin by Admin
August 1, 2026
Home AI
Share on FacebookShare on Twitter



Kernel knowledge transfer from CUDA to MLX

Determine 1: CUDA-to-MLX optimization translation map. CUDA optimization information might be translated into architecture-native MLX methods moderately than copied instruction-for-instruction.

We face a brand new epoch in computing. {Hardware} is altering quickly — not simply sooner GPUs, however a rising vary of chips from totally different distributors, every with its personal structure and sometimes tailor-made to particular AI workloads. Software program is altering simply as quick, and AI coding instruments now generate in minutes what took months of effort a number of years in the past.

With a lot of computing now centered on AI, GPU kernels are a vital part of its success. These are the low-level packages that run contained in the GPU, and writing environment friendly ones is much from apparent — it takes years of experience to get proper. Transferring a kernel from one vendor’s {hardware} to a different is tougher nonetheless, and sometimes means rediscovering the identical optimizations from scratch. The CUDA ecosystem, for instance, has amassed a long time of hard-won kernel experience: hand-tuned implementations of consideration, state area fashions, and different vital operations representing hundreds of engineering hours. Newer {hardware} ecosystems (Apple Silicon, customized AI accelerators, and others) are rising quick however lack this depth.

On this work we ask whether or not that experience might be transferred mechanically. We constructed on Ok-Search, an evolutionary kernel search framework launched by Cao et al. at Berkeley Sky Lab that makes use of AI to optimize GPU kernels, and prolonged it with a backend for MLX — Apple’s machine-learning framework for its personal Apple Silicon chips. We developed a novel structured CUDA-to-MLX translation layer that lets Ok-Search take present CUDA kernels as a information base and adapt them into high-quality GPU kernels for Apple Silicon, moderately than rebuilding from scratch.

We present that our strategy reaches near-expert degree efficiency on Apple Silicon with 0.97x speedup in comparison with the native MLX Consideration kernel, and as much as a 20x prefill speedup over the group mlx-lm implementation on the Mamba SSM kernel; we report the numbers, and the way a lot of the achieve comes from the interpretation layer, within the sections under. Though we give attention to MLX kernels for Apple Silicon, the tactic will not be particular to MLX and applies to any ecosystem the place CUDA experience is transferable.

Why MLX?

Apple’s MLX framework has seen exceptional adoption since late 2023. With Apple Silicon in tons of of hundreds of thousands of MacBooks and Mac Studios, MLX permits native AI inference with out cloud prices. The unified reminiscence structure makes it particularly enticing for mid-sized fashions (7B–70B parameters on M collection chips).

But beneath this momentum lies a big hole: many performance-critical kernels that the NVIDIA ecosystem takes without any consideration: paged consideration, optimized SSM scan kernels, fused MoE routing are both absent or naive with out hardware-specific tuning. MLX runs fashions accurately however usually leaves important efficiency on the desk.

This hole is what motivates the remainder of this publish.

What’s Ok-Search?

Ok-Search is an evolutionary kernel optimization framework initially developed by our first writer Shiyi Cao at UC Berkeley Sky Lab. Given a naive kernel and a {hardware} specification, it runs an iterative optimization loop: an LLM causes about which optimizations to strive subsequent, a code-writing mannequin generates candidate kernels, and people candidates are compiled and benchmarked on actual {hardware}.

Measurements feed again into the search, which retains refining, pursuing promising instructions and dropping lifeless ends till efficiency converges.

Pseudocode for K-Search via co-evolving world models

Algorithm 1: Ok-Search by way of co-evolving world fashions. The search alternates between deciding on probably the most promising motion, instantiating and evaluating code till enchancment stagnates, and evolving the world mannequin by insert, replace, and prune operations. Tailored from Cao et al. (2026).

Search is grounded by a Spec: a domain-specific doc encoding {hardware} guidelines, optimization patterns, and mathematical constraints which retains generated code from hallucinating invalid primitives and ensures candidates will really compile and run effectively.

In our runs, a single mannequin (Gemini 3.5 Professional Preview) performs each roles: it maintains the reasoning state and writes the kernels. The reasoning half is prompted as a “GPU kernel efficiency engineer” and requested to work by a set evaluation earlier than proposing something: classify the kernel (discount, scan, consideration/softmax, …), rewrite the reference computation in canonical type, map out knowledge structure and entry patterns, and hypothesize the seemingly bottleneck (bandwidth, latency, compute, or synchronization) in every runtime regime. Solely then does it emit candidate optimizations, every as a single change implementable in a single iteration.

We name the persistent reasoning state a world mannequin. Fairly than a flat record of issues to strive, it’s a choice (prefix) tree: every root→leaf path composes a full optimization plan, and sibling branches are competing alternate options. Each node is scored — an overall_rating in [0, 10], a confidence in [0, 1], and per-node impacts on reminiscence bandwidth, register stress, and compute/{hardware} match — so the search can rank partial plans and develop probably the most promising ones. The tree persists and grows throughout rounds: refining an thought provides a toddler node moderately than overwriting its father or mother, and if one of the best rating fails to enhance for a number of rounds (a stagnation window) the search backs off to discover an alternate department. A single node, because it seems mid-run on the eye kernel, appears like this:

{
  "motion": "Exchange the threadgroup-memory softmax discount
             with a register-only discount: every SIMD group
             owns 8 question rows and reduces throughout lanes with
             simd_shuffle_xor, eradicating a threadgroup_barrier.",
  "difficulty_1_to_5": 4,
  "impacts": {
    "memory_bandwidth":  8,
    "register_pressure": 4,   // threat: spill if Br > 8
    "compute_hw_fit":    9    // SIMD width 32; preserve tile 8x8
  },
  "overall_rating_0_to_10": 8,
  "confidence_0_to_1": 0.7
}

Itemizing 1: Instance Ok-Search world-model node. Every candidate optimization information a concrete motion, estimated {hardware} impacts, an total precedence score, and the mannequin’s confidence.

Overview of the K-Search loop

Determine 2: Overview of Ok-Search. The framework operates on a Search State $S_t$ structured as a search tree. The tree consists of Closed nodes (blue, visited states with connected program like $x_{12}$) and a Frontier of Open nodes (orange, pending hypotheses like $u_{13}$). The workflow iterates by three phases: (1) Motion Choice, the place probably the most promising motion node is retrieved from the frontier primarily based on world mannequin estimated precedence rating $V$; (2) Native Refinement, the place a stochastic coverage $pi_{mathrm{code}}$ samples concrete implementations till stagnation; and (3) World Mannequin Replace, the place the LLM causes over the trajectory to replace the search tree by way of Insert (including new actions), Replace (adjusting $V$, e.g., $u_{11}$ dropping from 0.9 to 0.6), and Prune (eradicating much less promising nodes like $u_{10}$).

The unique Ok-Search paper evaluated this search technique on CUDA kernels from FlashInfer. Throughout GQA decode, MLA decode, MLA prefill, and MoE, Ok-Search improved extra persistently than OpenEvolve and ShinkaEvolve over the identical 120-iteration funds. These outcomes set up the search framework we construct on right here; the rest of this publish asks whether or not its optimization information can switch past CUDA.

K-Search benchmark results compared with OpenEvolve and ShinkaEvolve

Determine 3: Foremost outcomes from the unique Ok-Search paper. Throughout three runs, Ok-Search achieves stronger best-so-far search scores, per-workload kernel efficiency, and speedup distributions than OpenEvolve and ShinkaEvolve on 4 FlashInfer CUDA kernels. Reproduced precisely from Cao et al. (2026).

Constructing an MLX backend

To convey Ok-Search to Apple Silicon, we first constructed a local MLX backend. We carried out a full MLX-specific process adapter for Ok-Search, together with:

  • An MLX process backend in k_search/duties/ dealing with kernel compilation and execution on Apple Silicon by way of MLX’s Metallic/C++ APIs.
  • Up to date kernel generator prompts for writing and modifying Metallic/MLX kernels.
  • MLX-specific benchmarking integration utilizing mlx.core measurement utilities.

Translating CUDA experience to MLX

Nevertheless, the extra fascinating problem was not merely operating Ok-Search on MLX. The important thing perception is that professional CUDA kernels encode a long time of optimization information that’s transferable to Apple GPU in the event you can bridge the conceptual hole. Merely handing an LLM a CUDA kernel and asking it to port it’s not sufficient: with out deep {hardware} context, it produces code that’s syntactically legitimate however architecturally unsuitable (unsuitable tile sizes, invalid primitives, mismatched reminiscence assumptions).

Our translation layer consists of:

  • Idea mapping tables: A structured glossary of CUDA primitives and their MLX/Metallic equivalents with exhausting constraints. For instance:
    • __shared__ maps to Metallic threadgroup reminiscence however with a tough 32 KB restrict (vs. NVIDIA’s 48 KB)
    • warp_reduce maps to MMA (most popular)
    • __syncthreads() turns into threadgroup_barrier(mem_flags::mem_tg)
    • H100’s ~3.35 TB/s HBM3 maps to M3 Max’s ~400 GB/s unified DRAM a bandwidth distinction that reshapes which optimizations are price pursuing.
  • MLX-specific hints and patterns: Concrete code-level patterns for operations with no direct CUDA equal, equivalent to register-based row reductions utilizing simd_shuffle_xor in an 8×8 MMA tile structure, or the “exp2 trick” (changing $exp(x)$ with $exp_2(x log_2 e)$) for sooner softmax on Apple’s quick $exp_2$ {hardware} instruction.
  • Reusable assertions: Skilled kernel behaviors reframed as properties the evolutionary search should protect, moderately than code to repeat.

Matching professional kernel efficiency: the Consideration kernel

We consider three configurations of an MLX consideration kernel for Apple Silicon: (1) a naive baseline, (2) pure evolution with no further offered context, and (3) a full context translation layer, which provides the optimizer with architecture-specific implementation information extracted from high-performance kernels (e.g., FlashAttention-2), letting the evolutionary search purpose about implementation methods moderately than ranging from a naive kernel. Collectively, these three configurations allow us to isolate the precise impression of the interpretation layer.

Performance scaling of the Attention Kernel through stacked optimizations

Determine 4: Efficiency scaling of the Consideration Kernel by stacked optimizations. The “Full Context” configuration efficiently discovers and implements superior methods like double buffering and loop unrolling, attaining near-expert efficiency.

The soar from 0.26× to 0.97× the pace of Apple’s state-of-the-art consideration kernel — illustrates how a lot the interpretation layer issues. With full context, the advanced kernel independently discovers the important thing optimizations in FlashAttention 2: threadgroup reminiscence tiling, on-line softmax, Ok-transposition for reminiscence entry, and the exp2 trick. The final of those replaces each softmax exponential with a base-2 exponential,

[e^x = 2^{x log_2 e},]

which is actual and lets the kernel use Apple’s quick quick::exp2() {hardware} instruction immediately as a substitute of paying for a base conversion at runtime.

A 20× sooner prefill: the Mamba SSM kernel

To judge whether or not Ok-Search generalizes past consideration kernels, we utilized it to the state-space mannequin (SSM) kernel utilized by Mamba. Not like consideration, the computational bottleneck is a recurrent state replace moderately than a softmax, offering a considerably totally different optimization problem. We examine the advanced implementation in opposition to the group MLX implementation (mlx-lm) and the PyTorch reference implementation (mamba.py) on an M1 Max.

Evaluated on mamba-370m f16, M1 Max 64GB:

Metric mlx-mamba (ours) mlx-lm (group) mamba.py
Decode 152 tok/s 116 tok/s 40 tok/s
Prefill L=512 5,751 tok/s 329 tok/s 1,089 tok/s
Prefill L=1024 6,010 tok/s 327 tok/s 1,127 tok/s
Prefill L=2048 6,612 tok/s 326 tok/s 1,092 tok/s
Prefill L=4096 6,743 tok/s 339 tok/s 1,042 tok/s

Desk 1: Prefill and decode throughput on mamba-370m (f16, M1 Max 64GB). mlx-mamba (ours) reaches ~20× greater prefill throughput than the group mlx-lm baseline, whereas decode stays comparable.

The ~20× prefill speedup over mlx-lm comes down to 1 distinction: mlx-lm doesn’t implement a parallel scan for the SSM. The state recurrence

[h_t = bar{a}_t h_{t-1} + bar{b}_t]

appears inherently sequential, however every step might be written as a pair $(bar{a}_t, bar{b}_t)$ beneath the associative mix

[(a_2, b_2) circ (a_1, b_1) = left(a_2 a_1, a_2 b_1 + b_2right),]

which reproduces the recurrence precisely. As a result of the operator is associative, the entire sequence might be evaluated with a parallel (prefix) scan in $O(log N)$ dependent steps as a substitute of $O(N)$. mlx-lm skips this and processes tokens one by one, leaving most of Apple Silicon’s compute idle; our advanced Metallic kernel applies the scan and makes a lot fuller use of GPU throughput. The achieve exhibits up in prefill, the place the complete sequence is offered to scan in parallel, and never in single-token decode, the place there is just one new token per step and no scan to parallelize — which is why the decode row is roughly flat whereas prefill is ~20×.

mamba.py is sluggish on each prefill and decode as a result of it’s a PyTorch reference implementation that falls again to CPU or MPS on Apple Silicon, forgoing the hardware-specific optimizations that MLX’s Metallic backend makes attainable.

What’s subsequent?

On the 2 kernels we studied, AI-driven evolutionary kernel search grounded in structured cross-platform translation information reached near-expert efficiency on Apple Silicon with out a staff of GPU specialists ranging from scratch. We don’t but understand how far this generalizes, however the result’s encouraging.

For us the primary takeaway is that the bottleneck was not the LLM’s potential to write down Metallic code, however the high quality of the context and constraints we gave it. Our CUDA translation layer converts present NVIDIA kernel experience into actionable steering for Apple Silicon, and lets Ok-Search’s evolutionary search do the remainder.

We’re actively extending this work in a number of instructions: supporting new architectures, with present efforts centered on growing new kernels for the IBM Spyre AIU and broader {hardware} targets; including extra kernels equivalent to paged consideration and fused MoE routing; and enhancing integration with the Ok-Search evolution loop to make translation context much more automated.

Acknowledgements

This work was carried out by IBM Analysis and builds on Ok-Search from the UC Berkeley Sky Lab (Cao et al., 2026). We welcome collaboration and suggestions from the MLX and broader AI methods communities. If you’re engaged on kernel optimization for non-CUDA {hardware}, we might love to listen to from you.


Quotation

@article{cao2026k,
  title={Ok-Search: LLM Kernel Era by way of Co-Evolving Intrinsic World Mannequin},
  writer={Cao, Shiyi and Mao, Ziming and Gonzalez, Joseph E and Stoica, Ion},
  journal={arXiv preprint arXiv:2602.19128},
  yr={2026}
}

Appendix: Attempt it your self

The MLX backend is constructed on prime of the open-source Ok-Search repo, so the outcomes right here might be reproduced immediately. The steps are:

1. Clone and set up

git clone https://github.com/caoshiyi/Ok-Search.git
cd Ok-Search

uv pip set up openai wandb
uv pip set up git+https://github.com/caoshiyi/flashinfer-bench-ksearch.git

2. Set your credentials

Open the related script beneath scripts/ and set three variables on the prime:

KSEARCH_ROOT=/path/to/Ok-Search
API_KEY=your-llm-api-key

3. Run kernel search

# Optimize Flash Consideration on Apple Silicon (world-model mode)
bash scripts/mac_flash_attention_wm.sh

# Or a Mamba SSM kernel, e.g. the selective scan
bash scripts/mamba_selective_scan_fwd_wm.sh

Full CLI reference and documentation are within the README.

Tags: AppleArtificialBerkeleyBlogbringsdecadesExpertiseIntelligenceKernelKSearchresearchSilicon
Admin

Admin

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended.

Quantum Witch exhibits the countless potentialities of what cults, coercion, and in the end, the fitting help can do

Quantum Witch exhibits the countless potentialities of what cults, coercion, and in the end, the fitting help can do

June 30, 2025
Z-A Change 2 Version Will get Its First Main Worth Reduce at Amazon

Z-A Change 2 Version Will get Its First Main Worth Reduce at Amazon

June 24, 2026

Trending.

Backrooms director Kane Parsons explains the birds, the portals, and his sensible results

Backrooms director Kane Parsons explains the birds, the portals, and his sensible results

May 31, 2026
100 Most Costly Key phrases for Google Advertisements in 2026

100 Most Costly Key phrases for Google Advertisements in 2026

January 13, 2026
Resident Evil followers have adopted a Love & Deepspace character because the son of Leon S. Kennedy and one in every of his potential spouses

Resident Evil followers have adopted a Love & Deepspace character because the son of Leon S. Kennedy and one in every of his potential spouses

April 4, 2026
Random Forest Algorithm in Machine Studying With Instance

Random Forest Algorithm in Machine Studying With Instance

May 4, 2025
AI & data-driven Starbucks – Deep Brew

AI & data-driven Starbucks – Deep Brew

May 18, 2026

AimactGrow

Welcome to AimactGrow, your ultimate source for all things technology! Our mission is to provide insightful, up-to-date content on the latest advancements in technology, coding, gaming, digital marketing, SEO, cybersecurity, and artificial intelligence (AI).

Categories

  • AI
  • Coding
  • Cybersecurity
  • Digital marketing
  • Gaming
  • SEO
  • Technology

Recent News

How Ok-Search Brings Many years of Kernel Experience to Apple Silicon – The Berkeley Synthetic Intelligence Analysis Weblog

How Ok-Search Brings Many years of Kernel Experience to Apple Silicon – The Berkeley Synthetic Intelligence Analysis Weblog

August 1, 2026
Pokemon Go August 2026 Occasions: Raid Bosses, Highlight Hours, Pokemon Debuts, And Extra

Pokemon Go August 2026 Occasions: Raid Bosses, Highlight Hours, Pokemon Debuts, And Extra

August 1, 2026
  • About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us

© 2025 https://blog.aimactgrow.com/ - All Rights Reserved

No Result
View All Result
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing

© 2025 https://blog.aimactgrow.com/ - All Rights Reserved