r/oMLX • • 9h ago

How fast can local LLM inference get on Apple Silicon?

Thumbnail
reddit.com
0 Upvotes

r/oMLX • • 22h ago

Qwen4 speeds dropping to 12 tok/s on memory-constrained Mac (and the fix)

Post image
32 Upvotes

Qwen4 runs at 70 tokens/s on a 32 GB MacBook. Mine was stuck at 12.

I've been testing the new Qwen4-35B-A3B (4-bit) locally on an M2 Max. Short prompts were fine, but past about 1,000 prompt tokens generation dropped to 12 tokens/s and stayed there.

The model was not the problem. The runtime asks macOS to keep all GPU memory wired, and a 23 GB model does not fit that way on a 32 GB machine. Every GPU call was paying about 4 ms to re-wire memory, 19 times per token.

Two fixes, both measured:
→ Turn the wired limit off: 12 → 69 tokens/s
→ Memory-map the weights: same speed, and RAM drops from 23 GB to 14 GB

With MTP (speculative decoding) it goes from 7 to over 70.

One machine, one run per cell, so treat the numbers as a pointer. But if your Qwen4 feels slow on a Mac that it nearly fills, check wired memory before blaming the model.

Details and repro in the oMLX issue: https://github.com/jundot/omlx/issues/5996


r/oMLX • • 14h ago

Tradeoffs of oQe vs oQh quants?

1 Upvotes

What are the tradeoffs of enabling or disabling the rotated codes? Isn't oQh just always better? Is it considerably slower or something vs oQe? Why is it not default/more widely used?


r/oMLX • • 8h ago

Qwen4-35B-A3B: KL divergence for various oQ quants

Post image
35 Upvotes

I wanted to know how much accuracy each Qwen4-35B-A3B quant gives up compared with full-precision BF16, so I measured KL divergence against the BF16 model. Everything ran on an M5 Max with 64 GB under oMLX 0.8.5. The models are the mlx-community oQ builds plus Qwen's official FP8 release. Surprisingly, the oQ6e quant beats the official FP8 release.

If you have 64+ gigs of unified memory, I recommend the oQ6e quant. You lose a lot with the oQ4e quant. This confirms my anecdotal experience with various simple coding tests.

(details of how I generated this was written by Claude; I include that for people who want to know about the method)

ModelSize (GB)Mean KLD± s.e.p99 KLDSame top token as BF16PPL
oQ3e-mtp29.50.12180.00171.31786.2%6.747
oQ4e-mtp33.80.05170.00070.57890.9%6.688
oQ5e-mtp40.40.03000.00040.30793.0%6.670
oQ6e-mtp47.10.02360.00040.24294.0%6.659
FP8 official, exact weights58.40.02510.00040.25793.6%6.654
FP8 official, as oMLX loads it58.40.02940.00050.31493.2%6.650
oQ8e-mtp60.20.02110.00030.23094.3%6.655
BF16 (reference)-----6.652
  • Text model on disk, including the n-gram table (12.8 GB in oQ3e/oQ4e, 15.4 GB in oQ5e, 17.9 GB in oQ6e, about 20.5 GB in FP8) but not the vision encoder or MTP head.

Takeaways

  • oQ6e is the closest to BF16 of anything I tested, closer even than Qwen's own FP8 release, and it's 11 GB smaller. FP8 uses one scale for each 128×128 block of weights. oQ uses a scale for every 64 weights, gives more bits to the sensitive layers, and calibrates with an importance matrix.
  • oQ5e is about as close as FP8 in oMLX, at 18 GB less.
  • Each step down from oQ5e roughly doubles the drift. oQ5e → oQ4e is 1.7× and oQ4e → oQ3e is 2.4×. At oQ3e, about 1 token in 7 differs from BF16's first choice, and the worst 1% of tokens change a lot (p99 KLD > 1).
  • oQ3e saves less memory than "3-bit" suggests. The backbone averages 3.8 bits per weight, but the 12.8 GB n-gram table stays at 4 bits or more, so the whole checkpoint averages 4.3. If memory is the problem, the SSD N-gram Offload setting takes that table out of RAM, which may help more than dropping a quant level.
  • When oMLX loads the FP8 checkpoint, it converts the weights to MXFP8. That adds a bit of drift (KLD 0.025 → 0.029) and wastes a little of FP8's advantage. The FP8 checkpoint does load and run fine in oMLX, though.
  • Perplexity barely tells them apart. Every quant is within about 1.4% of BF16, and FP8-oMLX actually scores a hair below BF16, which is noise. KLD is the better measure for comparing quants.

Method

  • Text: WikiText-2 (raw) test set, 32 chunks of 2048 tokens. Only the second half of each chunk is scored, as in llama.cpp's KLD, for 32,736 scored tokens. KLD is computed over the full 248k vocabulary.
  • BF16 reference: the BF16 backbone (~70 GB) doesn't fit in 64 GB, so I ran it one decoder layer at a time. Each layer was loaded from disk, every chunk was pushed through it, and then the next layer was loaded. This used oQ's own streamed-layer loader, the one it uses to calibrate models bigger than RAM. Peak memory was about 7 GB and the whole pass took about 40 s.
  • Checking the method: on oQ6e, the layer-by-layer path matched a normal full forward exactly (KLD 0). Skipping a single layer gave KLD 0.22, so the check does catch mistakes.
  • "FP8 exact" decodes the FP8 weights with the same layer-by-layer loader. "FP8 as oMLX loads it" is the normal mlx-vlm load path, i.e. what you get when you serve the checkpoint.
  • Quants were loaded the way oMLX's VLM engine loads them, with SSD n-gram offload on, and run as plain forward passes. MTP isn't involved, since it only affects speed.

Caveats

  • This is one dataset of English prose. Code, other languages, chat formatting, and long-context behavior could rank differently. With 2048-token chunks, the sparse attention's 2048-token selection budget never kicks in, so long context isn't tested at all.
  • The ± values are standard errors over tokens. They show the differences are stable on this text, not that they hold everywhere.
  • These numbers aren't directly comparable to Unsloth's GGUF KLD charts, which use different evaluation sets, a different reference run, and llama.cpp.

(I updated the graph to include oQ8e, but I can't figure out how to delete the first version of the figure...)


r/oMLX • • 9h ago

Selecting the Engram Table?

5 Upvotes

I came across this post and it really opened my eyes to how much harm quanting the engram table can have on the results: https://www.reddit.com/r/LocalLLM/comments/1ydjcaf/qwen_4_35b_a3b_vs_qwen_38_flash_next/

In oMLX is it possible to select the engram table like someone can do in Unsloth?


r/oMLX • • 9h ago

Qwen4-35B-A3B Uncensored MLX

Thumbnail
huggingface.co
35 Upvotes

more MLX quants: 3-bit (27 GB) / 6-bit (46.7 GB)

happy testing! would love to hear how it runs on your setup