Skip to main content
Enigma

Write. Compile. Run.
GPU Kernels on Apple Metal.

Python-first GPU compute for Apple Silicon. CuTe-style layout algebra. Compiles to Metal.

pip install enigma-dsl

Getting Started

Install Enigma and run your first kernel end-to-end.

Programming Guide

Kernel anatomy, layout algebra, ops, and atomics.

API Reference

Complete signatures for compile() and MetalRuntime.

QUICK LOOK

import enigma
import numpy as np

@enigma.kernel
def add(A: enigma.f32, B: enigma.f32, C: enigma.f32):
    tid = enigma.thread_position_in_grid
    C[tid] = A[tid] + B[tid]

compiled = enigma.compile(add)
rt = enigma.MetalRuntime()

n = 4096
a = np.random.randn(n).astype(np.float32)
b = np.random.randn(n).astype(np.float32)

raw = rt.execute(compiled, [a, b], output_size=n * 4, grid=(n, 1, 1), threads=(256, 1, 1))
out = np.frombuffer(raw, dtype=np.float32)
np.testing.assert_allclose(out, a + b, rtol=1e-5)

Concepts

Compilation pipeline, execution model, and memory model explained.

Examples

Vector add, parallel reduction, tiled GEMM — runnable end-to-end.

Debugging

Common errors, IR dumps, and Metal source inspection.

Release Notes

Track the latest changes to Enigma.