Taewoo Park

Research

mumax3-ultrafast

The fastest micromagnetic simulator on a Mac — 3.3× to 30× faster and 5.9× to 26× more energy-efficient than every other simulator that runs on Apple Silicon, with the physical model left exactly where it was.

Optimisation is what turns a port into an instrument

mumax3-for-mac proved the physics could be executed through Metal. This is what I did next: the same execution layer, optimised, until on an M4 MacBook Air it runs 3.3× to 30× faster than every other micromagnetic simulator that runs on a Mac, using 5.9× to 26× less energy.

I changed the hardware backend and nothing else. The .mx3 language, the Go solver, the material terms, the integration methods and the output formats stay mumax3-compatible, and results agree with the CUDA-era references to within the original tolerances.

Speed, energy and size, measured in one session on one M4 MacBook Air with identical physics in every arm
Speed, energy and size, measured in one session on one M4 MacBook Air with identical physics in every arm

Three of the four alternatives cannot use an Apple GPU at all

mumax3 and mumax+ are CUDA-only and do not run on Apple hardware. MicroMagnetic.jl lists Apple GPUs among its supported backends, but version 0.5.0 does not run on one: its own unmodified examples/std4.jl fails at Sim() because the package defaults to Float64 and Apple GPUs have no double-precision hardware. Forcing set_precision(Float32) then still fails inside GPU kernels — gpu_fill_kernel! and newell_f in the demag tensor. Every path reaches a double inside a Metal kernel.

magnum.np has no Apple GPU path at all: its initialiser selects cuda:N or cpu, forces float64 at import, and builds the demag tensor in double precision. Reaching MPS took me three source patches, and that patched configuration is what I put in the tables — its best case, not what pip install gives you, benchmarked separately. OOMMF has no GPU backend for any vendor.

Every arm solves the identical problem, and has to agree before it is timed

Demagnetisation plus exchange, Heun integration at a fixed 1e-13 s step, the same number of steps per mesh, in every simulator. Each arm therefore performs exactly two effective-field evaluations per step — mumax3 reports Neval as twice the step count, OOMMF energy_calc_count as twice plus one — which is what makes a cell-evaluation-per-second number comparable across codes at all. I made agreement a precondition for any timing to count, and committed the harnesses.

mumax3-ultrafast returns 1.61×10⁸ cell-evaluations per second at 128², peaks at 2.21×10⁸ at 256², and holds 1.36×10⁸, 1.27×10⁸ and 1.17×10⁸ at 512², 1024² and 2048². OOMMF on eight CPU threads runs between 2.85×10⁷ and 4.14×10⁷ across the same sweep. Patched magnum.np on MPS climbs from 1.11×10⁷ to 3.02×10⁷. MicroMagnetic.jl on CPU falls from 1.85×10⁷ to 8.22×10⁶, and magnum.np as shipped from 7.41×10⁶ to 4.97×10⁶. MicroMagnetic.jl's Metal backend has no row at any size, because it does not run.

The same 512² run, measured with powermetrics on the real rails
The same 512² run, measured with powermetrics on the real rails

The same physics for the power of a light-bulb filament

Energy is the axis nobody can settle against NVIDIA, because published comparisons divide throughput by a nominal board TDP and the answer moves threefold with what the card really draws. So I removed the assumption instead of arguing with it: every arm ran on the same chip, with powermetrics reading the real rails.

mumax3-ultrafast finishes in 7.6 s at 6.10 W combined — 46.6 J, or 22.51 million cell-evaluations per joule. Patched magnum.np on MPS takes 43.4 s at 6.38 W for 277.1 J and 3.78 million per joule. MicroMagnetic.jl on CPU takes 86.1 s for 560.6 J and 1.87; magnum.np as shipped takes 143.7 s for 1218.1 J and 0.86. The machine's idle floor during the runs was 0.195 W combined and 0.002 W on the GPU.

OOMMF is the instructive case: only 3.3× behind on wall time, at 25.2 s, but burning 16.42 W against 6.10 W on the GPU — 414.2 J against 46.6 J, so on energy it falls 8.9× behind. Time and energy are not the same ranking.

A whole patterned device, not a corner of one

83.9 million cells complete without paging out. At 4 nm cells that is a 32.8 by 41.0 µm film — a whole patterned device rather than a corner of one — and 5.0× more than any other GPU-capable tool on the platform.

The honest qualifier is in the README's own scope section: capacity ties OOMMF. Both reach 83.9 million cells and both fail at 104.9 million. What separates them there is speed, where mumax3-ultrafast is 4.5× faster, 29.2 s against 131.1 s. It is faster; it is not larger.

Two pieces of measurement hygiene changed my numbers, and I wrote both down so nobody else loses a day to them. Swap has to be watched through vm_stat's Swapouts, not Pageouts, which Apple Silicon's compressor leaves nearly still while gigabytes are written; and mumax3's demag kernel cache reaches 8–10 GB per entry here, so it has to be dropped between runs.

Largest problem that fits in 32 GB — a tie with OOMMF, stated as a tie
Largest problem that fits in 32 GB — a tie with OOMMF, stated as a tie
Four independently written codes, three languages, three backends, one answer
Four independently written codes, three languages, three backends, one answer

Three languages and three backends return the same magnetisation

After the same number of steps, the mean in-plane magnetisation from mumax3-ultrafast reads 0.994939, 0.9950321 and 0.9950429 at 512², 1024² and 2048². OOMMF returns 0.994942, 0.9950322 and 0.9950370; MicroMagnetic.jl on CPU 0.994939, 0.9950319 and 0.9950369; patched magnum.np on MPS 0.994939, 0.9950319 and 0.9950370. The worst disagreement in the sweep is 7.1×10⁻⁵.

The upstream validation the port already passed still holds underneath, with the full breakdown on mumax3-for-mac rather than repeated here — and that hundred per cent is tolerance conformance, not bit-for-bit identity.

Three knobs, each with its own stated failure mode

At research mesh sizes an Apple GPU is often idle waiting for the host rather than short of arithmetic — at 128×128 the host takes longer to encode a Dormand–Prince step than the GPU takes to run it. SpeculativeStep overlaps host encoding with GPU execution for a measured 1.53×; MinimizeOnGPU keeps the Barzilai–Borwein step size of minimize() on the device for 1.58×; queueing three minimize() jobs per GPU gives a 2.53× aggregate. None change the default build.

I print each caveat beside its number, because a knob whose failure mode is unstated is worse than no knob. SpeculativeStep still enforces MaxErr, but the rejection lands one step late, so the trajectory diverges at roughly one per cent after a few thousand steps; it closes itself under FixDt, finite Temp and relax(). MinimizeOnGPU keeps every descent step bit-identical, moving only the convergence check one iteration late. High-order demag extrapolation is off by default, fails closed to exact convolution, and has an error depending on trajectory and time step — so a benchmark on another problem guarantees nothing about yours.

Underneath, I keep the GPU resident across blocking drains, split large demag transforms one axis at a time to avoid MPSGraph's collapsed scheduling region, and use a vendored VkFFT path for eligible 2D transforms. Throughput per cell peaks at 256², and at or below 128² a fixed overhead of 172 to 187 µs per evaluation dominates, where a wider GPU cannot help.

An interface on top of the engine, never in place of it

I kept the engine and the command line as the primary installation. The macOS app is an optional layer that leaves .mx3 files as the source of truth while adding an editor, working-folder selection, one-click runs, live magnetisation and solver metrics, logs, and an integrated 3D OVF viewer that will also open result folders produced outside the app. Projection maps an X, Y or Z spin component from −1 to +1 along an editable two-colour line, white to black by default.

It builds locally without an Apple Developer Program membership, ad-hoc signing on your own Mac — and I say so rather than leaving it to be discovered: such a build is not notarised and may be restricted on managed Macs, so a signed disk image is the faster path when a release includes one.

Script workspace — write an `.mx3` file in a folder you choose
Script workspace — write an .mx3 file in a folder you choose
Live run — magnetisation, solver metrics, progress and logs
Live run — magnetisation, solver metrics, progress and logs
The OVF result as a 3D vector field
The OVF result as a 3D vector field
Glyph styles at close range
Glyph styles at close range

Against NVIDIA on raw speed, this loses

On mumax3's own sixty-two-GPU benchmark table an M4 lands between a mobile GTX 1650 and a GTX 970. I scoped the claim to Apple Silicon deliberately, because that is the range where I can measure every axis on one machine with no TDP assumption left in it.

Two further edges sit in the same section. Capacity ties OOMMF, as the capacity entry above already concedes. And my margin over the previous release narrows with mesh size, from 5.4× at 128² to 1.38× at 2048², because this round targeted the latency-bound regime where research meshes actually sit.

When a run takes seconds, checking becomes cheap enough to do every time

The reason the speed matters to me is not the number. A simulation that meant an overnight queue slot now finishes inside a conversation, so I can refine the mesh three times, cross-check against a closed-form estimate and re-run a sweep in one sitting. spinloop is what makes me actually do it, and it exists only because this does.

Comparison targets are cited as measured: MicroMagnetic.jl 0.5.0 with Metal.jl 1.10, magnum.np 2.2.0 and OOMMF 2.0b0. GNU GPL v3 or later.