Skip to content

perf(models): apertus and seed_oss dense decode at ~0.83x of mlx-lm #269

Closed

Description

@inureyes

Problem / Background

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.
  • Cheaply recoverable overhead recovered.
  • Greedy temp-0 output unchanged.

Activity

  1. added
    status:ready
    type:performance
    priority:low
    area:models
    area:inference
    platform:macos
    status:in-progress
    and removed
    status:ready
    on Jun 13, 2026
  2. inureyes commented on Jun 13, 2026

    @inureyes
    MemberAuthor

    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.py XieLU) 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).

  3. added
    status:ready
    and removed
    status:in-progress
    on Jun 13, 2026
  4. added this to the 0.4 milestone on Jun 21, 2026
  5. added
    status:in-progress
    status:review
    status:done
    and removed
    status:ready
    status:in-progress
    status:review
    on Jun 22, 2026
  6. self-assigned this
    on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:inferencearea:modelsplatform:macospriority:lowstatus:donetype:performance

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions