Automationscribe.com
  • Home
  • AI Scribe
  • AI Tools
  • Artificial Intelligence
  • Contact Us
No Result
View All Result
Automation Scribe
  • Home
  • AI Scribe
  • AI Tools
  • Artificial Intelligence
  • Contact Us
No Result
View All Result
Automationscribe.com
No Result
View All Result

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

admin by admin
August 8, 2026
in Artificial Intelligence
0
How Okay-Search Brings Many years of Kernel Experience to Apple Silicon – The Berkeley Synthetic Intelligence Analysis Weblog
399
SHARES
2.3k
VIEWS
Share on FacebookShare on Twitter



Kernel knowledge transfer from CUDA to MLX

Determine 1: CUDA-to-MLX optimization translation map. CUDA optimization data might be translated into architecture-native MLX methods slightly 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 completely different distributors, every with its personal structure and infrequently 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 couple of years in the past.

With a lot of computing now centered on AI, GPU kernels are an important element of its success. These are the low-level applications that run contained in the GPU, and writing environment friendly ones is way from apparent — it takes years of experience to get proper. Transferring a kernel from one vendor’s {hardware} to a different is more durable nonetheless, and infrequently means rediscovering the identical optimizations from scratch. The CUDA ecosystem, for instance, has accrued many years of hard-won kernel experience: hand-tuned implementations of consideration, state house fashions, and different important 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 robotically. We constructed on Okay-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 Okay-Search take present CUDA kernels as a data base and adapt them into high-quality GPU kernels for Apple Silicon, slightly than rebuilding from scratch.

We present that our strategy reaches near-expert stage 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 beneath. Though we give attention to MLX kernels for Apple Silicon, the tactic just isn’t 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 lots of of tens of millions 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 as a right: 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 vital efficiency on the desk.

This hole is what motivates the remainder of this submit.

What’s Okay-Search?

Okay-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 useless ends till efficiency converges.

Pseudocode for K-Search via co-evolving world models

Algorithm 1: Okay-Search through co-evolving world fashions. The search alternates between choosing essentially 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 hard and fast evaluation earlier than proposing something: classify the kernel (discount, scan, consideration/softmax, …), rewrite the reference computation in canonical kind, map out information structure and entry patterns, and hypothesize the probably 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. Moderately than a flat checklist of issues to strive, it’s a determination (prefix) tree: every root→leaf path composes a full optimization plan, and sibling branches are competing options. Each node is scored — an overall_rating in [0, 10], a confidence in [0, 1], and per-node impacts on reminiscence bandwidth, register strain, and compute/{hardware} match — so the search can rank partial plans and develop essentially the most promising ones. The tree persists and grows throughout rounds: refining an concept provides a baby node slightly than overwriting its father or mother, and if one of the best rating fails to enhance for a couple of rounds (a stagnation window) the search backs off to discover another department. A single node, because it seems mid-run on the eye kernel, seems to be like this:

{
  "motion": "Substitute 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; maintain tile 8x8
  },
  "overall_rating_0_to_10": 8,
  "confidence_0_to_1": 0.7
}

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

Overview of the K-Search loop

Determine 2: Overview of Okay-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 essentially 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 through 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 Okay-Search paper evaluated this search technique on CUDA kernels from FlashInfer. Throughout GQA decode, MLA decode, MLA prefill, and MoE, Okay-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 submit asks whether or not its optimization data can switch past CUDA.

K-Search benchmark results compared with OpenEvolve and ShinkaEvolve

Determine 3: Primary outcomes from the unique Okay-Search paper. Throughout three runs, Okay-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 Okay-Search to Apple Silicon, we first constructed a local MLX backend. We applied a full MLX-specific job adapter for Okay-Search, together with:

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

Translating CUDA experience to MLX

Nevertheless, the extra fascinating problem was not merely working Okay-Search on MLX. The important thing perception is that skilled CUDA kernels encode many years of optimization data 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/Steel equivalents with exhausting constraints. For instance:
    • __shared__ maps to Steel threadgroup reminiscence however with a tough 32 KB restrict (vs. NVIDIA’s 48 KB)
    • warp_reduce maps to MMA (most well-liked)
    • __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 value 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: Knowledgeable kernel behaviors reframed as properties the evolutionary search should protect, slightly than code to repeat.

Matching skilled 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 extra supplied context, and (3) a full context translation layer, which provides the optimizer with architecture-specific implementation data extracted from high-performance kernels (e.g., FlashAttention-2), letting the evolutionary search cause about implementation methods slightly than ranging from a naive kernel. Collectively, these three configurations allow us to isolate the precise affect 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 velocity 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, Okay-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 an alternative of paying for a base conversion at runtime.

A 20× sooner prefill: the Mamba SSM kernel

To guage whether or not Okay-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 slightly than a softmax, offering a considerably completely different optimization problem. We examine the advanced implementation towards 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× increased prefill throughput than the group mlx-lm baseline, whereas decode stays comparable.

The ~20× prefill speedup over mlx-lm comes down to at least one 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]

seems to be inherently sequential, however every step might be written as a pair $(bar{a}_t, bar{b}_t)$ underneath 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 an alternative of $O(N)$. mlx-lm skips this and processes tokens one after the other, leaving most of Apple Silicon’s compute idle; our advanced Steel 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 out there 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 gradual 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 Steel backend makes doable.

What’s subsequent?

On the 2 kernels we studied, AI-driven evolutionary kernel search grounded in structured cross-platform translation data reached near-expert efficiency on Apple Silicon and not using a staff of GPU consultants 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 capacity to put in writing Steel code, however the high quality of the context and constraints we gave it. Our CUDA translation layer converts present NVIDIA kernel experience into actionable steerage for Apple Silicon, and lets Okay-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 creating new kernels for the IBM Spyre AIU and broader {hardware} targets; including extra kernels equivalent to paged consideration and fused MoE routing; and bettering integration with the Okay-Search evolution loop to make translation context much more automated.

Acknowledgements

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


Quotation

@article{cao2026k,
  title={Okay-Search: LLM Kernel Technology through 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: Strive it your self

The MLX backend is constructed on prime of the open-source Okay-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/Okay-Search.git
cd Okay-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 underneath scripts/ and set three variables on the prime:

KSEARCH_ROOT=/path/to/Okay-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
Previous Post

Customized OS set up now out there on AWS DeepRacer gadgets

Leave a Reply Cancel reply

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

Popular News

  • Greatest practices for Amazon SageMaker HyperPod activity governance

    Greatest practices for Amazon SageMaker HyperPod activity governance

    405 shares
    Share 162 Tweet 101
  • How Cursor Really Indexes Your Codebase

    405 shares
    Share 162 Tweet 101
  • Construct a serverless audio summarization resolution with Amazon Bedrock and Whisper

    404 shares
    Share 162 Tweet 101
  • Context Engineering — A Complete Fingers-On Tutorial with DSPy

    403 shares
    Share 161 Tweet 101
  • Speed up edge AI improvement with SiMa.ai Edgematic with a seamless AWS integration

    403 shares
    Share 161 Tweet 101

About Us

Automation Scribe is your go-to site for easy-to-understand Artificial Intelligence (AI) articles. Discover insights on AI tools, AI Scribe, and more. Stay updated with the latest advancements in AI technology. Dive into the world of automation with simplified explanations and informative content. Visit us today!

Category

  • AI Scribe
  • AI Tools
  • Artificial Intelligence

Recent Posts

  • How Okay-Search Brings Many years of Kernel Experience to Apple Silicon – The Berkeley Synthetic Intelligence Analysis Weblog
  • Customized OS set up now out there on AWS DeepRacer gadgets
  • Loop Engineering for RAG Query Parsing: The Small Loop That Runs Earlier than Retrieval
  • Home
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions

© 2024 automationscribe.com. All rights reserved.

No Result
View All Result
  • Home
  • AI Scribe
  • AI Tools
  • Artificial Intelligence
  • Contact Us

© 2024 automationscribe.com. All rights reserved.