Enceladus v0.1.0 · alpha
MethodologyBenchmarks pages
OverviewMethodologyElementwiseSoftmax and reductionsNormalizationScans and atomicsMatmulFlash attentionDispatch overhead

Benchmarks

Methodology

How the benchmark scripts time Enceladus, MLX, and PyTorch, which statistic each table reports, the machine that produced the results, and how to run the benchmarks yourself.

How Enceladus kernels are timed

Every Enceladus throughput number comes from enceladus.testing.do_bench, which reads GPU timestamps instead of the wall clock. For each call, do_bench does the following:

  1. Raises the stream's flush threshold so that each repetition runs in its own command buffer.
  2. Runs the function until it has spent 50 ms of GPU time. The GPU clocks down when it's idle, so cold measurements run slow.
  3. Runs the function rep times, and records the GPU start and end time of each command buffer.

Because the time comes from the command buffer, it excludes host-side launch cost and synchronization. The function must launch on enceladus.Tensor arguments; a launch that synchronizes internally can't be timed this way. For more information, see Performance.

How MLX and PyTorch are timed

MLX and PyTorch don't expose per-command-buffer GPU timestamps to these scripts, so their times use the wall clock around a synchronized call: mx.eval(...) for MLX, and the operation followed by torch.mps.synchronize() for PyTorch. Each script runs a few warmup calls first. bench_matmul times MLX and PyTorch inside the same interleaved rounds as its Enceladus variants, and reports their minimum and median.

The wall clock includes launch and synchronization overhead, which the softmax and attention scripts estimate at about 0.1 ms. That overhead is small for long kernels, for example under 1% for a 4096³ matmul, but it's a large fraction of a kernel that runs for well under a millisecond. When a comparison involves a short kernel, read the MLX and PyTorch numbers as lower bounds on their throughput.

Minimum and median

Most tables report the minimum time over the repetitions, converted to throughput. The minimum is the least noisy estimate of what the kernel can do when nothing else interferes. Where the scripts also report the median, the tables show it in parentheses or in its own column. A large gap between the two means the kernel's time varies from run to run; for example, the float32 mpp matmul at 4096³ has a minimum of 5.40 TFLOPS and a median of 4.69.

Interleaved rounds

GPU clocks, temperature, and other GPU users change during a run. To spread those changes evenly across the kernels under comparison, two scripts interleave their measurements:

  • bench_matmul times every Enceladus variant for one shape and dtype in turn, followed by MLX and PyTorch, for 3 rounds. In each round, each Enceladus variant runs 10 times with GPU timestamps, and MLX and PyTorch each run 3 warmup calls and 10 wall-clock runs. The script reports the minimum and median over all 30 samples of each.
  • bench_attention alternates the Enceladus kernel and MLX in one process for 3 rounds of 10 runs. It reports the best round's minimum and the median of the round medians.

Thermal throttling

On a laptop, sustained GPU work lowers the GPU clock. In a 24-round run of back-to-back 4096³ float16 matmuls that lasted about 50 s, every kernel, MLX included, slowed by 5-7% after about 35 s. After several minutes of matmul work on battery power, float32 matmuls ran up to 35% slower.

For this reason, bench_matmul times MLX and PyTorch in the same rounds as the Enceladus variants, so that a clock change affects all of them alike. run_all.py takes a --cooldown SECONDS flag that idles between scripts, so that heat from one benchmark doesn't slow the next one.

Throughput units

The scripts convert times to throughput as follows:

  • Memory-bound kernels report GB/s, counting the minimum traffic: each input read once and each output written once. A kernel that rereads data from the cache can report less than its real traffic.
  • Matmul reports TFLOPS as 2 × M × N × K floating-point operations per time.
  • Attention reports TFLOPS as 4 × batch × heads × sequence length² × head dimension operations per time, halved for a causal mask.
  • Dispatch overhead reports microseconds per launch, measured on the host with the wall clock.

Machine

All results on these pages come from one machine:

ComputerMacBook Pro, Apple M4 Pro, 24 GB unified memory
GPU16 cores, Apple9 family, applegpu_g16s
SoftwaremacOS 27, Xcode 27, Enceladus 0.1.0
Results filebenchmarks/results/2026-09-27-applegpu_g16s-2.md, from a run on 2026-09-27 with 90 s of idle time between scripts
PowerThe run started on battery power, and the laptop was connected to power during it.

The M4 Pro's GPU isn't Apple10, so the Metal 4 matmul2d operation behind the mpp tl.dot backend runs on the regular shader cores, not on dedicated matrix hardware. Expect different ratios on other chips.

Reproduce the results

To run the benchmarks on your own Mac, follow these steps:

  1. Clone the repository and install the development environment, which includes MLX and PyTorch:
    shell
    uv sync
  2. Close other GPU-heavy apps, and connect the computer to power.
  3. Run every benchmark and write a report:
    shell
    uv run python benchmarks/run_all.py --cooldown 90

    The script runs every bench_*.py script in benchmarks/, in alphabetical order, and idles for 90 seconds before each one after the first. It writes a Markdown report named DATE-ARCHITECTURE.md to benchmarks/results/, with one section per benchmark. If a report with that name exists, the new report gets a numeric suffix, such as DATE-ARCHITECTURE-2.md.

To run one benchmark, run its script directly, for example:

shell
uv run python benchmarks/bench_matmul.py --quick

The --quick flag limits bench_matmul to the 4096³ shape and bench_attention to sequence length 2048. A script skips its MLX or PyTorch rows when that framework isn't installed, except bench_attention, which requires MLX.

Source

The following script runs the benchmarks and writes the report:

benchmarks/run_all.pyGitHub
"""Runs every benchmark and writes a Markdown report to `benchmarks/results/`.

Run with `uv run python benchmarks/run_all.py`. The runner discovers every
`benchmarks/bench_*.py` script. The report is named `<date>-<architecture>.md`; when a
report of that name exists, the new one gets a numeric suffix, such as
`<date>-<architecture>-2.md`, so an earlier run is never overwritten. Pass `--dry-run` to
print the benchmarks and the report path without running anything.

On a laptop, sustained GPU work lowers the GPU clock within about a minute, so a benchmark
that follows the matmul benchmark can run slower than it would alone. To let the GPU cool
between scripts, pass `--cooldown SECONDS`.
"""

from __future__ import annotations

import argparse
import datetime
import subprocess
import sys
import time
from pathlib import Path

import enceladus

HERE = Path(__file__).resolve().parent
RESULTS = HERE / "results"


def benchmarks() -> list[str]:
    """Returns the name of every `bench_*.py` script, in alphabetical order."""
    return sorted(p.stem for p in HERE.glob("bench_*.py"))


def report_path(date: str, arch: str) -> Path:
    """Returns the first report path for `date` and `arch` that doesn't exist yet."""
    out = RESULTS / f"{date}-{arch}.md"
    n = 2
    while out.exists():
        out = RESULTS / f"{date}-{arch}-{n}.md"
        n += 1
    return out


def main() -> None:
    parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
    parser.add_argument("--dry-run", action="store_true",
                        help="print the benchmarks and the report path, and exit")  # fmt: skip
    parser.add_argument("--cooldown", type=float, default=0.0, metavar="SECONDS",
                        help="idle time before each benchmark after the first")  # fmt: skip
    args = parser.parse_args()
    caps = enceladus.get_device().caps
    date = datetime.date.today().isoformat()
    names = benchmarks()
    out = report_path(date, caps.architecture)
    if args.dry_run:
        print("\n".join(names))
        print(f"would write {out}")
        return
    lines = [
        f"# Enceladus benchmarks, {date}",
        "",
        f"Device: {caps.name} ({caps.architecture}). Enceladus {enceladus.__version__}.",
        "Enceladus times use GPU timestamps; MLX and PyTorch times use the wall clock.",
        *([f"Each benchmark after the first ran after {args.cooldown:g} s of idle time."]
          if args.cooldown else []),
        "",
    ]
    for i, name in enumerate(names):
        if i and args.cooldown:
            time.sleep(args.cooldown)
        print(f"running {name}...", flush=True)
        r = subprocess.run([sys.executable, str(HERE / f"{name}.py")], capture_output=True,
                           text=True)  # fmt: skip
        status = [] if r.returncode == 0 else [f"The script exited with status {r.returncode}.",
                                               ""]  # fmt: skip
        lines += [f"## {name}", "", *status, "```text", (r.stdout + r.stderr).strip(), "```", ""]
    out.parent.mkdir(exist_ok=True)
    out.write_text("\n".join(lines))
    print(f"wrote {out}")


if __name__ == "__main__":
    main()