Skip to content

Fit: what runs here, and the arithmetic

Which open model can you actually serve on this hardware, at your context and your concurrency?

onpar fit answers with a memory budget, not a guess. For each catalogue model it adds three terms and compares the sum with the memory the accelerator may use. A model that fits is ranked by size, largest first, because the biggest model you can run is usually the best one you can run. A model that does not fit is listed with the term that broke the budget.

Every number is one flag away from its arithmetic. --explain prints the formula with this machine’s values in it, so a sizing you disagree with can be argued line by line rather than taken on trust.

$ onpar fit --context 32k --concurrency 8
M4 Max · 16 cores · 128 GB · 546 GB/s
usable for inference: 96 GB
raise to ~118 GB with: sudo sysctl iogpu.wired_limit_mb=120586
FEASIBLE at 32,768 context, concurrency 8
model quant weights kv total free ~tok/s license
----------------------------------------------------------------------------------------
Qwen3 32B q4 17.2G 64.0G 84.1G 11.9G 15 slow Apache-2.0 OK
Qwen3 30B-A3B (MoE) q8 28.4G 24.0G 56.2G 39.8G 60 Apache-2.0 OK
Mistral Small 24B q8 22.0G 40.0G 65.2G 30.8G 14 slow Apache-2.0 OK
Phi-4 14B q8 13.7G 50.0G 66.3G 29.7G 18 MIT OK
Llama 3.1 8B q8 7.5G 32.0G 41.6G 54.4G 32 Llama 3.1 !
NOT FEASIBLE
Gemma 3 27B weights fit (14 GB) but KV at 32,768 ctx x8 (124 GB) puts it 45 GB over the 96 GB available
Llama 3.3 70B weights fit (37 GB) but KV at 32,768 ctx x8 (80 GB) puts it 25 GB over the 96 GB available
Qwen3 235B-A22B (MoE) weights alone need 123 GB at q4 — MoE sparsity (22B of 235B active) cuts compute, not memory
DeepSeek V3 (MoE, MLA) weights alone need 352 GB at q4 — MoE sparsity (37B of 671B active) cuts compute, not memory
GLM-5.2 weights alone need 186 GB at q4 — MoE sparsity (32B of 355B active) cuts compute, not memory
Kimi K2.7 Code weights alone need 524 GB at q4 — MoE sparsity (32B of 1000B active) cuts compute, not memory
Kimi K3 (2.8T MoE) weights alone need 1,467 GB at q4 — MoE sparsity (50B of 2800B active) cuts compute, not memory
DeepSeek V4 Pro weights alone need 838 GB at q4 — MoE sparsity (45B of 1600B active) cuts compute, not memory
MiniMax M3 weights alone need 239 GB at q4 — MoE sparsity (46B of 456B active) cuts compute, not memory
runtime -> mlx
Apple silicon: the CUDA engines cannot run here at all. MLX has the better
batching story of the two Metal options.
~tok/s is a memory-bandwidth roofline, not a measurement — `onpar measure` measures.
onpar fit --explain <model-id> # show the arithmetic
# recorded 2026-11-03 on M4 Max · 128 GB · onpar 1.5.2
$ onpar fit --explain qwen3-30b-a3b --context 32k --concurrency 8
Qwen3 30B-A3B (MoE) @ q8, 32,768 ctx, concurrency 8
weights 30.5B params x 8 bits / 8 = 28.4 GB (MoE: ALL experts resident)
kv cache 98,304 B/tok x 32,768 tok x 8 = 24.0 GB (GQA)
overhead 8% of weights + 1.5 GB floor = 3.8 GB
--------------------------------------------------------------
required 56.2 GB
usable 96.0 GB
headroom 39.8 GB
decode is bandwidth-bound, and reads both:
weights 3.1 GB/token (3.3B active)
kv cache 3.0 GB/token (the whole cache, every token)
total 6.1 GB/token at 72% of peak
~60 tok/s single-stream (roofline estimate, not measured)
! MoE at batch 8: the weight read above is held at 3.3B, which is exact only at batch 1.
Sequences route to different experts, so the real read is between 3.3B and 26.4B — up to 8.0x.
The aggregate throughput and $/Mtok figures take the low end, so they flatter rather than warn.
verdict: FITS
# recorded 2026-11-03 on M4 Max · 128 GB · onpar 1.5.2

Read it top to bottom. The three memory terms are:

  • Weights: parameters times bits per weight, divided by 8. For an MoE model that is every expert, which the line marks as ALL experts resident.
  • KV cache: bytes per token, times context, times concurrency. Bytes per token is 2 × kv_heads × head_dim × layers × 2 for grouped-query attention. For MLA models it is kv_lora_rank × layers × 2 instead.
  • Overhead: 8% of the weights plus a 1.5 GB floor, for activations, workspace and allocator fragmentation.

The catalogue entry supplies every input. Check the KV line against it: 4 KV heads, a head dimension of 128 and 48 layers give the 98,304 bytes per token shown above.

The MLA formula is why DeepSeek-family models are not oversized. DeepSeek V3 has 61 layers, 128 heads of dimension 128, and a 512-rank latent. The grouped-query formula gives 61 × 2 × 128 × 128 × 2 = 3,997,696 bytes per token. The latent gives 61 × 512 × 2 = 62,464. That is 64 times less cache, and a sizing that used the first figure would buy hardware for memory the model never touches.

$ onpar catalog qwen3-30b-a3b
id qwen3-30b-a3b
name Qwen3 30B-A3B (MoE)
params_b 30.5
active_b 3.3
layers 48
kv_heads 4
head_dim 128
kv_scheme gqa
max_context 131072
license Apache-2.0
license_ok True
quants ('fp16', 'q8', 'q4')
verified True
kv_lora_rank None
repo Qwen/Qwen3-30B-A3B
reasoning True
onpar fit --explain qwen3-30b-a3b # does it fit here, and the arithmetic
onpar where qwen3-30b-a3b # which hardware runs it
# recorded 2026-11-03 on M4 Max · 128 GB · onpar 1.5.2

A GB on these pages is 2^30 bytes, the unit src/onpar/fit.py computes in.

Speed is a roofline estimate, not a measurement

Section titled “Speed is a roofline estimate, not a measurement”

Decode is bandwidth-bound. Each generated token reads the active weights once and the whole KV cache once, so single-stream speed is effective bandwidth divided by bytes read per token. Effective bandwidth is peak bandwidth times BANDWIDTH_EFFICIENCY. Every ~tok/s figure onpar prints is that estimate, and every surface labels it as one.

The constants behind these figures are calibration knobs, not physics. They live at the top of src/onpar/fit.py:

Constant Value What it stands for
OVERHEAD_FRACTION 0.08 non-weight, non-KV memory, as a share of weights
OVERHEAD_FLOOR 1.5 GB the fixed runtime floor under that share
BANDWIDTH_EFFICIENCY 0.72 the share of peak bandwidth a real decode loop reaches

BANDWIDTH_EFFICIENCY scales every throughput figure, and it has not yet been checked against a measurement. onpar measure is the upgrade path: it times a running endpoint, and with --model it prints the measured rate beside this estimate.

The runtime -> line at the bottom of fit names the engine family this hardware can start. On Apple silicon the CUDA engines cannot run at all, so it names a Metal option. Serve makes the full choice.

A NOT FEASIBLE row always says why, in one of two shapes:

  • weights alone need N GB means no context or concurrency setting helps. You need a heavier quantisation, a smaller model or more memory. For MoE models the row adds that sparsity cuts compute, not memory.
  • weights fit (...) but KV ... puts it N GB over means the weights fit and the cache does not. A shorter context or fewer concurrent requests may close it.

--explain on a model that does not fit prints the same breakdown and ends with verdict: DOES NOT FIT, exiting 1.

$ onpar where qwen3-30b-a3b --context 32k
Qwen3 30B-A3B (MoE) · 30.5B (3.3B active, MoE) · Apache-2.0 OK
at 32,768 context, concurrency 1
hardware quant total ~tok/s $/hr $/Mtok
------------------------------------------------------------------
NVIDIA RTX 5090 q4 21.8G 254 0.55 0.60
NVIDIA L40S q8 35.2G 95 0.80 2.33
NVIDIA A100 40 GB q8 35.2G 172 1.10 1.78
NVIDIA A100 80 GB q8 35.2G 225 1.80 2.22
AMD MI300X 192 GB q8 35.2G 585 2.50 1.19
NVIDIA H100 80 GB SXM q8 35.2G 370 2.90 2.18
NVIDIA H200 141 GB q8 35.2G 530 3.60 1.89
NVIDIA B200 192 GB q8 35.2G 883 5.50 1.73
2× NVIDIA H100 q8 35.2G 684 5.80 2.35
TPU v5e (8 chips) q8 35.2G 659 9.60 4.05
4× NVIDIA H100 q8 35.2G 1313 11.60 2.45
TPU v5p (4 chips) q8 35.2G 1084 16.80 4.31
TPU v6e Trillium (8 chip q8 35.2G 1257 21.60 4.77
8× NVIDIA H200 q8 35.2G 3683 28.80 2.17
Apple M3 Ultra 512 GB q8 35.2G 90 - -
Apple M4 Max 128 GB q8 35.2G 60 - -
Apple M4 Pro 48 GB q8 35.2G 30 - -
CPU only (64 GB DDR5) q8 35.2G 7 - - slow
WILL NOT RUN
NVIDIA L4 short by 160 MB — weights fit, but KV at 32,768 ctx x1 does not
NVIDIA RTX 4090 short by 160 MB — weights fit, but KV at 32,768 ctx x1 does not
$/Mtok assumes the machine is busy at the requested concurrency;
a box at 10% utilisation costs about ten times this per token.
Throughput figures are roofline estimates, not measurements.
# recorded 2026-11-03 on M4 Max · 128 GB · onpar 1.5.2

where sizes one model against every hardware profile onpar knows. $/Mtok assumes the machine is busy at the requested concurrency, and the output says how far that moves at low utilisation.

  • --context and --concurrency set the workload. The defaults are 32k and 1.
  • --explain MODEL_ID prints the arithmetic and a verdict.
  • --json returns the same numbers with estimate_basis on every throughput figure, for a script or an agent.
  • A catalogue file in ~/.config/onpar/models.d/ adds or corrects a model without a release. A malformed file is an error, never a silent skip. An MLA entry without kv_lora_rank is refused rather than sized with the wrong formula.

Next: serve the model you picked with onpar run.