MLX

by Apple · Framework · Text & code

An array and machine-learning framework for Python and other languages that runs and trains neural networks on Apple silicon Macs using unified memory.

mixed

Apple-silicon ML framework: compiling gives real speedups, but custom kernels and quantization have gotchas

Latest · Nov 28macOS 26.2 adds RDMA over Thunderbolt; Apple's note says to enable it from recovery mode with a Terminal command, and a user says macOS 27 moves it into Settings.

AccessOpen codeLicenseMIT

Who says what

Early days

Krishdeep13, who benchmarked mx.compile

Compiling made a 5-op elementwise chain 4.65x faster (4.80 ms vs 22.33 ms), rising to about 10.9x on long chains, with identical outputs in all 90 tested cases. Softmax and matmul+gelu gained nothing, and the first compiled call varied from 7 ms to 273 ms.

MLX: Show and tell and rizumita, who hit its limits

MLX: Show and tell found custom kernels copy non-contiguous arrays on every call (about 9 ms for 1M x 128) and always allocate new outputs. rizumita found mx.quantize in 0.31.1 returns negative scales, breaking code that assumes positive ones.

Apple, and Jorge Marfil reporting on Mac clusters

Apple claims two M5 Ultras speed a 65,536-token prefill about 1.8x. Marfil reports no Thunderbolt 5 switches exist, so every Mac must be cabled to every other.

What would settle it. An independent test of the multi-Mac setup Apple describes, timing real prefill and generation.

Seen running on

MachineSpeedHowSeen by
1 run on a 24 GB Mac
MacBook Pro
and 3 more builds in the same post
no speed givenfloat32Krishdeep13 · Nov 28

Evidence

  1. Nov 28
    mx.compile ran a 5-op elementwise chain on 2^27 float32 in 4.80 ms versus 22.33 ms eager, 4.65x faster with identical outputs
    Hands-on testKrishdeep13
  2. Nov 28
    mx.compile speedup on elementwise chains grew from 1.90x at 1 step to 10.87x at 128 steps, plateauing near 10.6-10.9x from 32 steps
    Hands-on testKrishdeep13
  3. Nov 28
    At 4096x4096, compile sped up where by about 4.6-4.9x and layernorm by about 1.3x, but softmax and matmul+gelu stayed about 1.0x
    Hands-on testKrishdeep13
  4. Nov 28
    Compiled time rose in steps after 11, 22 and 33 ops, consistent with MLX's max_compile_depth of 11; author says this is not proof
    Hands-on testKrishdeep13
  5. Nov 28
    First mx.compile call varied from about 7 ms to 273 ms across runs versus a steady 4.8 ms afterwards; cause not found
    Hands-on testKrishdeep13
Show all 12
  1. Nov 28
    Compiled and eager outputs matched exactly (max difference 0.0) in all 90 tested cases of functions, dtypes and shapes
    Hands-on testKrishdeep13
  2. Nov 25
    In MLX 0.31.1, mx.quantize in affine mode returns negative scales for blocks where |min| > |max|; code assuming positive scales gives wrong rounding statistics.
    Hands-on testrizumitaJapanese
  3. Nov 19
    Apple reports pipeline parallelism on two M5 Ultras speeds a 65,536-token prefill about 1.8x; tensor parallelism needs low-latency RDMA, and two cables per link cut one test from 50.5 s to 40.6 s.
    Maker's claimAppleviaJorge MarfilSpanish
  4. Nov 19
    Gurman says no Thunderbolt 5 switches exist, so each Mac must be cabled to every other; Apple cables cost $70 each.
    ReportedJorge MarfilSpanish
  5. Nov 12
    mx.array from a NumPy view keeps its strides; with ensure_row_contiguous=True a custom kernel copies the whole array each call, about 9 ms for 1M x 128
    Hands-on testMLX: Show and tell
  6. Nov 12
    With MTL_SHADER_VALIDATION=1, Metal counts threadgroup memory twice, so a kernel fitting in 32 KB fails validation above 16 KB
    Hands-on testMLX: Show and tell
  7. Nov 12
    Custom kernel outputs are always new arrays, forcing per-round allocation in NN-Descent; asks whether in-place state updates across iterations could be supported
    Hands-on testMLX: Show and tell

Everything said about MLX, on the wire