You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(models): apertus and seed_oss dense decode at ~0.83x of mlx-lm #269
On M1 Ultra, two dense families trail mlx-lm by a moderate margin: Apertus-8B-Instruct-2509-4bit ~70 vs ~85 tok/s (0.83x) and Seed-OSS-36B-Instruct-4bit ~17.1 vs ~20.3 tok/s (0.84x). For reference, dense granite-3.3-2b is at ~0.99x on the same harness, so these two have model-specific overhead rather than a generic dense-path problem.
Measured on an Apple M1 Ultra (128 GB, macOS 26.5.1, MLX commit a6ec712) against mlx-lm 0.31.3. Decode throughput was measured with mlxcel-bench-decode (warmup pass + measured pass in one process, --no-chat-template) versus scripts/bench_mlxlm.py (mlx-lm's own prompt_tps/generation_tps), identical checkpoint, raw continuation prompt, 100 decode tokens, best-of-3 with cooldown, temp-0 greedy.
Proposed Solution
Apertus has an xIELU MLP, QK-norm, and llama3 RoPE scaling (ported in PR #260); the per-layer xIELU scalar coefficients are bf16 and required an f32 cast (see the bf16 scalar trap). Seed-OSS (PR #261) is a standard Llama dense with a split attention bias. Investigate the decode hot path versus mlx-lm; suspects: xIELU activation cost / extra graph nodes (apertus), avoidable astype/eval, attention scale or bias handling.
Lower priority than the Mamba2 hybrid and dots.llm1 gaps.
Acceptance Criteria
Per-model decode overhead for apertus and seed_oss characterized versus mlx-lm.
Investigation: no model-specific bug; same per-op-dispatch overhead as #268
Benchmarked dense families on M1 Ultra (decode tok/s, mlxcel-bench-decode vs mlx-lm 0.31.3, raw prompt, 100 tok after warmup, temp 0):
Model
extra per-layer ops vs vanilla Llama
mlxcel
mlx-lm
ratio
llama-3.1-8b
none (baseline)
109.3
109.4
1.00×
granite-3.3-2b
none
184
186
0.99×
qwen3-8b
+ QK-norm (2 RMSNorm/layer)
75.3
83.8
0.90×
apertus-8b
+ QK-norm + xIELU (~10 elementwise ops)
70
85
0.83×
seed_oss-36b
+ attention q/k/v bias
17.1
20.3
0.84×
Vanilla Llama dense is at parity (1.00×), so the base decode path is healthy (the old ~0.85× for 8B is gone, closed by earlier KV-cache work). The residual gap tracks the number of extra small element-wise ops per layer a model adds on top of the Llama baseline.
Ruled out as model-specific bugs
No forced evals.seed_oss.rs has zero eval(); apertus.rs's only eval() is in read_scalar (load time).
xIELU is already leaner than mlx-lm. mlxcel precomputes the post-softplus alpha_p/alpha_n as Rust f32 scalars and uses multiply_scalar; mlx-lm (models/activations.pyXieLU) keeps them as mx.array and applies softplus on GPU every call. So xIELU is not a mlxcel disadvantage.
QK-norm / attn-bias match mlx-lm op-for-op (RMSNorm over head_dim; bias fused into UnifiedLinear).
Conclusion
apertus/seed_oss have no standalone performance bug. Their gap is the general per-op-dispatch overhead (mlxcel's per-FFI-op cost + less lazy-graph fusion than mlx-lm), proportional to how many extra small ops each model runs per decode token. This is the same root cause as #268 (where the MoE router/combine small ops dominate), just milder on dense models. Whatever op-fusion / dispatch-reduction work closes #268 should also lift these. Recommend tracking the fix under #268 and treating this as subsumed (kept open and linked for the benchmark record).
Activity
inureyes commentedon Jun 13, 2026
Investigation: no model-specific bug; same per-op-dispatch overhead as #268
Benchmarked dense families on M1 Ultra (decode tok/s,
mlxcel-bench-decodevsmlx-lm0.31.3, raw prompt, 100 tok after warmup, temp 0):Vanilla Llama dense is at parity (1.00×), so the base decode path is healthy (the old ~0.85× for 8B is gone, closed by earlier KV-cache work). The residual gap tracks the number of extra small element-wise ops per layer a model adds on top of the Llama baseline.
Ruled out as model-specific bugs
seed_oss.rshas zeroeval();apertus.rs's onlyeval()is inread_scalar(load time).alpha_p/alpha_nas Rust f32 scalars and usesmultiply_scalar; mlx-lm (models/activations.pyXieLU) keeps them asmx.arrayand appliessoftpluson GPU every call. So xIELU is not a mlxcel disadvantage.head_dim; bias fused intoUnifiedLinear).Conclusion
apertus/seed_oss have no standalone performance bug. Their gap is the general per-op-dispatch overhead (mlxcel's per-FFI-op cost + less lazy-graph fusion than mlx-lm), proportional to how many extra small ops each model runs per decode token. This is the same root cause as #268 (where the MoE router/combine small ops dominate), just milder on dense models. Whatever op-fusion / dispatch-reduction work closes #268 should also lift these. Recommend tracking the fix under #268 and treating this as subsumed (kept open and linked for the benchmark record).
docs(benchmarks): MoE decode gap investigation (#268)
docs(benchmarks): MoE decode gap investigation (#268) (#273)
perf(models): profile apertus/seed_oss decode and trim xIELU op (#399)
docs(benchmarks): MoE decode gap investigation (lablup#268) (lablup#273)
perf(models): profile apertus/seed_oss decode and trim xIELU op (labl…