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.
npx skills add ssmall256/mlx-metal-kernels-skill --skill skillgit clone --depth 1 https://github.com/ssmall256/mlx-metal-kernels-skillWrote 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.
[](https://agentmods.dev/skills/ssmall256/mlx-metal-kernels-skill/skill)<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.
<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>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.
| Model | Per session | Once 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 |
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.
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.
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 ops →
scripts/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 usereferences/attention-variants-guide.mdonly when you need a custom layout/mask. - Long-context partitioned attention →
scripts/paged_attention_partitioned_kernel.py+references/paged-attention-patterns.mdfor two-phase partition + reduce softmax. - Quantized matvec / dequant patterns →
scripts/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”)
- Force evaluation: time with
mx.eval(out); mx.synchronize()(MLX is lazy). - Contiguity: if your kernel does
x[row * D + i], require contiguous inputs (or callmx.ascontiguousarray). - Bounds checks: if you round
gridup, guardif (tid >= ...) return;. - Dtype expectations: float16 I/O is common; accumulate in float32 for stability.
- Threadgroup limits:
threadgroup.xmust be ≤ 1024 and a multiple of 32 (one simdgroup). - 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)
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.
- __init__.py 61 B runs code
- kernels/__init__.py 52 B runs code
- kernels/autotune_cache.py 3.6 KB runs code
- kernels/utils.py 6.1 KB runs code
- manifest.txt 1.1 KB
- references/apple-silicon-optimization-guide.md 9.5 KB
- references/attention-kernel-guide.md 5.4 KB
- references/attention-variants-guide.md 5.7 KB
- references/cuda-to-metal-guide.md 6.3 KB
- references/kernel-debugging-walkthrough.md 8.1 KB
- references/kernel-templates.md 14 KB
- references/metal-4-ml-kernel-notes.md 2.6 KB
- references/mlx-integration.md 9.4 KB
- references/multi-dim-grid-patterns.md 6.3 KB
- references/mx-compile-interaction.md 5.9 KB
- references/paged-attention-patterns.md 3.2 KB
- references/production-error-handling.md 6.1 KB
- references/profiling-guide.md 8.7 KB
- references/quantized-kernel-patterns.md 4.6 KB
- references/simdgroup-matrix-guide.md 7.6 KB
- references/testing-patterns.md 6.6 KB
- references/troubleshooting.md 11 KB
- scripts/__init__.py 29 B runs code
- scripts/attention_kernel.py 11 KB runs code
- scripts/attention_variants_kernel.py 24 KB runs code
- scripts/batch_elementwise_kernel.py 3.4 KB runs code
- scripts/bench_all.py 5.7 KB runs code
- scripts/benchmark_rmsnorm.py 4.6 KB runs code
- scripts/dequant_matvec_kernel.py 9.3 KB runs code
- scripts/e2e_custom_kernels.py 6.6 KB runs code
- scripts/layernorm_kernel.py 9.0 KB runs code
- scripts/multihead_rope_kernel.py 8.9 KB runs code
- scripts/paged_attention_partitioned_kernel.py 14 KB runs code
- scripts/rmsnorm_kernel.py 7.4 KB runs code
- scripts/simdgroup_matmul_kernel.py 8.1 KB runs code
- scripts/softmax_kernel.py 9.2 KB runs code
- tests/__init__.py 13 B runs code
- tests/smoke_test.py 2.3 KB runs code
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.
- 9d ago First seen · 252 lines · 91 tokens per session scan A 0beabb903e27
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.
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…
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.
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…
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…
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…
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.