Skip to content

[Metal] Prefer qmm_nax over legacy split-k on NAX devices - #4793

Closed
arian262785-cell wants to merge 1 commit into
ml-explore:mainfrom
arian262785-cell:fix-nax-splitk-heuristic
Closed

arian262785-cell wants to merge 1 commit into
ml-explore:mainfrom
arian262785-cell:fix-nax-splitk-heuristic

Conversation

@arian262785-cell

Copy link
Copy Markdown
Contributor

Fixes #4720.

  • In qmm_splitk: When NAX is available and N, K are 64-aligned, routes to qmm (which invokes qmm_nax) instead of falling back to the legacy non-NAX split-K kernel when weights lack biases.

  • In QuantizedMatmul::eval_gpu: Routes mid-size rows (M >= 8, M < vector_limit, M * N >= 16384) through qmm_splitk when NAX is available and aligned so unbiased projections reach qmm_nax.

  • Retains existing split-K logic on pre-NAX devices (M1/M2/M3) and unaligned shapes.

  • Adds test coverage in python/tests/test_quantized.py (test_qmm_nax_unbiased_shapes).

  • ☑️ I understand it is strictly prohibited to use AI to write PR description

  • AI usage disclosure: None

On NAX-capable Apple Silicon hardware, qmm_splitk previously fell back
to the legacy non-NAX 32x32 split-K kernel whenever weights lacked linear
biases, cutting memory throughput on projections such as down and q/o.

Route aligned quantized matrix-matrix multiplications to qmm (which
invokes qmm_nax) when NAX is available, both in qmm_splitk and for
mid-size rows in QuantizedMatmul::eval_gpu.
@zcbenz

zcbenz commented Nov 1, 2026

Copy link
Copy Markdown
Member

I'm closing this in favor of #4781 which solves the issue by finishing missing kernels.

@zcbenz zcbenz closed this Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] qmm_splitk is chosen over qmm_nax on M5 for N=4096 projections M=16-64

2 participants