mlx-metal-kernels

mlx-metal-kernels is a skill for Claude Code from ssmall256/mlx-metal-kernels-skill. It costs 91 tokens per session (3,401 once invoked), scanned A, original, MIT.

Guidance for writing custom Metal GPU programs through MLX, Apple's machine-learning framework, on Apple Silicon Macs.

In plain words
What is it for?
Implementing or profiling operations such as normalization, softmax, attention, quantized matrix-vector work, and matrix multiplication.
Why use it?
It helps developers choose suitable kernel patterns and avoid common measurement, memory-layout, bounds, and data-type errors.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Implementing or profiling operations such as normalization, softmax, attention, quantized matrix-vector work, and matrix multiplication.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ssmall256/mlx-metal-kernels-skill/skill
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add ssmall256/mlx-metal-kernels-skill --skill skill
Clone the repo
git clone --depth 1 https://github.com/ssmall256/mlx-metal-kernels-skill

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mlx-metal-kernels

README.md
[![agentmods](https://agentmods.dev/badge/skills/ssmall256/mlx-metal-kernels-skill/skill/github.svg)](https://agentmods.dev/skills/ssmall256/mlx-metal-kernels-skill/skill)
Your own site
<a href="https://agentmods.dev/skills/ssmall256/mlx-metal-kernels-skill/skill"><img src="https://agentmods.dev/badge/skills/ssmall256/mlx-metal-kernels-skill/skill/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mlx-metal-kernels

Your own site · 80×15
<a href="https://agentmods.dev/skills/ssmall256/mlx-metal-kernels-skill/skill"><img src="https://agentmods.dev/badge/skills/ssmall256/mlx-metal-kernels-skill/skill.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 91 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,401 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00091 $0.03401
Opus 5 $0.00046 $0.01700
Sonnet 5 $0.00018 $0.00680
Haiku 4.5 $0.00009 $0.00340

Measured 9d ago against content hash 0beabb903e27, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

mlx-metal-kernels scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

The scan reads SKILL.md. This mod also ships 20 executable files (__init__.py, kernels/__init__.py, kernels/autotune_cache.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skill/SKILL.md · 252 lines

How it starts

The opening of the file, as written. The whole thing — 252 lines — stays where its author put it; the contents beside it link to each section on GitHub.

MLX Metal Kernels for Apple Silicon

Routing Guide (Pick the Right Template)

  • Elementwise / pointwise opsscripts/batch_elementwise_kernel.py
  • Row-wise reductions (RMSNorm / LayerNorm / Softmax)scripts/rmsnorm_kernel.py, scripts/layernorm_kernel.py, scripts/softmax_kernel.py
  • Attention → Prefer MLX built-ins first (mx.fast.scaled_dot_product_attention) and use references/attention-variants-guide.md only when you need a custom layout/mask.
  • Long-context partitioned attentionscripts/paged_attention_partitioned_kernel.py + references/paged-attention-patterns.md for two-phase partition + reduce softmax.
  • Quantized matvec / dequant patternsscripts/dequant_matvec_kernel.py
  • M3+ matrix ops (simdgroup_matrix)scripts/simdgroup_matmul_kernel.py + references/simdgroup-matrix-guide.md

Pre-Benchmark Checklist (Avoid “bench lies”)

  1. Force evaluation: time with mx.eval(out); mx.synchronize() (MLX is lazy).
  2. Contiguity: if your kernel does x[row * D + i], require contiguous inputs (or call mx.ascontiguousarray).
  3. Bounds checks: if you round grid up, guard if (tid >= ...) return;.
  4. Dtype expectations: float16 I/O is common; accumulate in float32 for stability.
  5. Threadgroup limits: threadgroup.x must be ≤ 1024 and a multiple of 32 (one simdgroup).
  6. First-call compile: ignore the first run when benchmarking (compile + cache effects).

This skill provides patterns and guidance for developing custom Metal compute kernels using MLX's mx.fast.metal_kernel() API, targeting Apple Silicon GPUs (M1, M2, M3, M4).

Quick Start

import mlx.core as mx

kernel = mx.fast.metal_kernel(
    name="my_relu",
    input_names=["x"],
    output_names=["out"],
    source="uint i = thread_position_in_grid.x; out[i] = max(x[i], T(0));",
)
x = mx.random.normal((1024,))
out = kernel(
    inputs=[x],
    template=[("T", mx.float32)],
    grid=(1024, 1, 1),
    threadgroup=(256, 1, 1),
    output_shapes=[(1024,)],
    output_dtypes=[mx.float32],
)[0]
mx.eval(out)

Read the full file on GitHub · 252 lines

Files

What ships with it

38 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 252 lines · 91 tokens per session scan A 0beabb903e27

Subscribe to this mod's changes

mlx-metal-kernels is a skill published in the GitHub repository ssmall256/mlx-metal-kernels-skill (2 stars, last pushed 6mo ago), licensed MIT. It adds 91 tokens to every session and 3,401 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

mlx-model-porting

Guides and validates architecture-aware ports of PyTorch/Hugging Face models to Apple MLX, inspects existing local MLX projects, and plans evidence-gated optimizations for Apple Silicon. Use when the user asks to run, port, convert, inspect, quantize, benchmark, or fix a model (LLM, VLM, audio/TTS/ASR, diffusion, SSM…

Amal-David/mlx-porting-skill · 244 tokens

llama-cpp

Runs LLM inference on CPU, Apple Silicon, and consumer GPUs without NVIDIA hardware. Use for edge deployment, M1/M2/M3 Macs, AMD/Intel GPUs, or when CUDA is unavailable. Supports GGUF quantization (1.5-8 bit) for reduced memory and 4-10× speedup vs PyTorch on CPU.

davila7/claude-code-templates · 76 tokens

running-openmed-ondevice

Run OpenMed models fully on-device with the MLX (Apple Silicon), CoreML (iOS/macOS), or ONNX/WebGPU (cross-platform/browser) backends, including convert-quantize-run workflows. Use when the user wants to deploy OpenMed at the edge, run NER/de-id on Apple Silicon, target iPhone/iPad/Mac, export to ONNX or WebGPU…

maziyarpanahi/openmed · 175 tokens

add-new-model

Use this skill when the user wants to add or port a new model architecture to MLX-VLM — mapping a Hugging Face modeltype to a new file under mlxvlm/models, writing the ModelConfig, matching layer/weight names, reusing a similar existing model, adding a test class, and validating the port. Covers vision-language…

Blaizzy/mlx-vlm · 83 tokens

benchmarking

Use this skill when the user wants to benchmark an MLX-VLM change and present the numbers in a PR — fork-vs-main A/B comparisons, isolated-module micro-benchmarks, median-of-N timing with warmup, peak-memory reporting, correctness checks, parameter sweeps, and self-contained reproducible bench scripts to paste into a…

Blaizzy/mlx-vlm · 74 tokens

cli-inference

Use this skill when the user wants to run or debug MLX-VLM inference from the command line, including uv run mlxvlm.generate, image/audio/video inputs, local model paths, Hugging Face model IDs, deterministic repro commands, and CLI errors around processors, prompts, model loading, or missing weights.

Blaizzy/mlx-vlm · 67 tokens