Skip to content

perf(models): default MLXCEL_FUSED_XIELU on after M5 Max validation - #417

Merged
inureyes merged 1 commit into
mainfrom
perf/fused-xielu-default-on
Jun 24, 2026
Merged

inureyes merged 1 commit into
mainfrom
perf/fused-xielu-default-on

Conversation

@inureyes

Copy link
Copy Markdown
Member

Follow-up to #409 (implemented in PR #414): the M5 Max validation it explicitly deferred.

Summary

Flip MLXCEL_FUSED_XIELU to default-on, with 0/false/off/no as the
case-insensitive opt-out, mirroring the MLXCEL_FUSED_MOE default-on convention
(#282). #409 (PR #414) shipped the fused single-launch Metal xIELU kernel for the
Apertus MLP activation default-off, explicitly pending M5 Max validation. This PR
completes that follow-up.

M5 Max benchmark

Apple M5 Max (128GB), apertus-8b-instruct-2509-4bit, mlxcel-bench-decode,
12 interleaved off/on rounds (order alternated per round, paired to cancel thermal
drift) of 256-token greedy decode, under caffeinate:

Condition mean tok/s median stdev
off (elementwise) 112.03 112.19 0.42%
on (fused) 114.17 114.48 0.83%

Delta +2.14 tok/s (+1.9% mean, +2.05% median), 11/12 paired wins, paired
t ~ 8.9. No regression.

Behavioral check of the flip on the rebuilt binary (default vs explicit env):
default 112.3 ~ on(=1) 112.9 > off(=0) 109.4, confirming that unset
routes through the fused path and =0 opts out.

Parity

Greedy temp-0 decode is byte-identical between the elementwise and fused paths on
M5 Max: an end-to-end full-generation sha256 matches, and the committed
fused_xielu_matches_elementwise_bit_for_bit test passes over the full activation
domain. Every intermediate stays in bf16 and the kernel reproduces MLX's expm1f.

Cross-generation

Hardware off to on delta
M1 Ultra (documented) 83.4 to 85.7 +2.7%
M5 Max (this PR) 112.0 to 114.2 +1.9%

Changes

  • src/models/apertus.rs: fused_xielu_enabled() is default-on via a new pure,
    unit-tested fused_xielu_enabled_from() opt-out helper. Adds
    fused_xielu_gate_defaults_on_with_opt_out.
  • docs/environment-variables.md: updated the MLXCEL_FUSED_XIELU row (default
    on, opt-out semantics, M5 Max number).

Apertus-only; non-Metal back-ends keep the equivalent elementwise fallback.

Flip MLXCEL_FUSED_XIELU to default-on with `0`/`false`/`off`/`no` as the
case-insensitive opt-out, mirroring the MLXCEL_FUSED_MOE default-on
convention (#282). #409 (PR #414) shipped the fused single-launch Metal
xIELU kernel for the Apertus MLP activation default-off, explicitly
pending M5 Max validation; this completes that follow-up.

M5 Max (Apple M5 Max, 128GB), Apertus-8B-Instruct-2509-4bit,
mlxcel-bench-decode, 12 interleaved off/on rounds of 256-token greedy
decode:

  off (elementwise): 112.0 tok/s
  on  (fused):       114.2 tok/s
  delta: +1.9% mean (+2.05% median), 11/12 paired wins, paired t ~ 8.9

Greedy temp-0 decode is byte-identical between the two paths on M5 Max
(end-to-end sha256 match over a full generation, plus the committed
bit-for-bit unit test over the full activation domain). With the
documented M1 Ultra result (+2.7%), the fused path is a byte-identical,
positive-throughput, no-regression win on both validated Apple Silicon
generations.

Apertus-only; non-Metal back-ends keep the equivalent elementwise
fallback. Set MLXCEL_FUSED_XIELU=0 to force the elementwise path.

Adds fused_xielu_enabled_from() as a pure, unit-tested opt-out decision
and updates docs/environment-variables.md.
@inureyes inureyes added type:performance Performance improvements area:models Model architectures, weights, loading, metadata area:inference Generation, sampling, decoding (incl. speculative, DRY) platform:macos macOS (Apple Silicon) specific labels Jun 24, 2026
@inureyes
inureyes merged commit edb4295 into main Jun 24, 2026
4 checks passed
@inureyes
inureyes deleted the perf/fused-xielu-default-on branch June 24, 2026 04:29
@inureyes inureyes self-assigned this Aug 31, 2026
@inureyes inureyes added the status:done Completed label Sep 6, 2026
be-free-snowboy pushed a commit to freestylejs/snowbrain-mlxcel that referenced this pull request Oct 27, 2026
…ablup#417)

Flip MLXCEL_FUSED_XIELU to default-on with `0`/`false`/`off`/`no` as the
case-insensitive opt-out, mirroring the MLXCEL_FUSED_MOE default-on
convention (lablup#282). lablup#409 (PR lablup#414) shipped the fused single-launch Metal
xIELU kernel for the Apertus MLP activation default-off, explicitly
pending M5 Max validation; this completes that follow-up.

M5 Max (Apple M5 Max, 128GB), Apertus-8B-Instruct-2509-4bit,
mlxcel-bench-decode, 12 interleaved off/on rounds of 256-token greedy
decode:

  off (elementwise): 112.0 tok/s
  on  (fused):       114.2 tok/s
  delta: +1.9% mean (+2.05% median), 11/12 paired wins, paired t ~ 8.9

Greedy temp-0 decode is byte-identical between the two paths on M5 Max
(end-to-end sha256 match over a full generation, plus the committed
bit-for-bit unit test over the full activation domain). With the
documented M1 Ultra result (+2.7%), the fused path is a byte-identical,
positive-throughput, no-regression win on both validated Apple Silicon
generations.

Apertus-only; non-Metal back-ends keep the equivalent elementwise
fallback. Set MLXCEL_FUSED_XIELU=0 to force the elementwise path.

Adds fused_xielu_enabled_from() as a pure, unit-tested opt-out decision
and updates docs/environment-variables.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:inference Generation, sampling, decoding (incl. speculative, DRY) area:models Model architectures, weights, loading, metadata platform:macos macOS (Apple Silicon) specific status:done Completed type:performance Performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant