Skip to content

sycl : accelerate MXFP4 MoE with arithmetic decoding and weight reordering - #29809

Merged
Titaniumtown merged 1 commit into
ggml-org:masterfrom
Captain-Tripps:sycl-mxfp4
Oct 10, 2026
Merged

Titaniumtown merged 1 commit into
ggml-org:masterfrom
Captain-Tripps:sycl-mxfp4

Conversation

@Captain-Tripps

Copy link
Copy Markdown
Contributor

Overview

Results:
Speeds up MXFP4 MoE inference in the SYCL backend:

  • gpt-oss-20b: 55.84 → 106.64 tok/s (1.91×) decode, 5 repetitions
  • gpt-oss-120b on two cards: 33.27 → 67.14 tok/s (2.02×) decode, 2 repetitions
  • gpt-oss-120b prompt processing: 594.5 → 600.1 tok/s
  • gpt-oss-20b (8 × 2048 tokens) perplexity: 14.5148 → 14.5129

Changes:

  • Replaces table-based MXFP4 decoding with bit-identical 32-bit arithmetic, avoiding costly permute emulation.
  • Adds lazy, per-expert weight reordering to enable aligned vector loads, with reorder-aware decode, multi-token, and prefill paths.
  • Limits temporary reorder memory to 32 MiB and preserves the generic fallback for misaligned tensors.

Additional information

This was tested and benchmarked on Intel Arc Pro B70 GPUs running Windows 11 and oneAPI 2026.0 and AMD EPYC 7402P, with flash attention enabled. Gpt-oss-20b ran on one card and gpt-oss-120b on two cards.

All MXFP4 backend tests pass on both devices: MUL_MAT 39/39 and MUL_MAT_ID 74/74. gpt-oss-20b perplexity remains within noise of the baseline.

Arithmetic decoding is the prerequisite for the weight-reordering optimization. Other GPUs and Linux have not been tested.

Prior to this change, the SYCL backend never created reorder metadata for the MXFP4 tensors, so the existing MXFP4 MUL_MAT_ID tests never exercised a reordered kernel.

Requirements

  • I have read and agree with the contributing guidelines - YES

  • AI usage disclosure: YES - Opus 5.5 has been helping me hill-climb efficiencies with the Intel Arc platform. This seems like one the rest of the community would benefit from.

@Captain-Tripps
Captain-Tripps requested a review from a team as a code owner October 1, 2026 15:52
@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning SYCL https://en.wikipedia.org/wiki/SYCL - GPU programming language labels Oct 1, 2026
@Asahi-Prv

Copy link
Copy Markdown
Contributor

Excelent!

I tested your PR on Intel Arc B570 (Windows 11).

Environment:

  • GPU: Intel Arc B570
  • Driver: 32.0.101.9033
  • oneAPI: 2026.1.1
  • OS:Windows 11 25H2

Correctness:

  • test-backend-ops (SYCL0): 2069/2069 passed on both baseline and PR
  • No correctness regression observed

MUL_MAT_ID MXFP4 kernel benchmark (2880x2880, 32 experts, 4 used):

  • n=1: 286.92 us -> 58.31 us (4.92x faster)
  • n=4/8: essentially unchanged
  • n=512: essentially unchanged

gpt-oss-20b MXFP4, -ngl 16:

  • tg128: 24.54 -> 34.56 tok/s (+40.8%)
  • pp512: 173.37 -> 169.21 tok/s (no meaningful change observed)

Perplexity (8x2048):

  • baseline: 679.50
  • PR: 676.15
  • no degradation observed

The MXFP4 MUL_MAT_ID decode optimization therefore reproduces on Arc B570 as well as the reported B70 results. The model-level gain is smaller than the kernel-level gain due to partial GPU offloading on the B570's 10GB VRAM.

Thank you!

P.S.
@arthw I tested this PR on an Arc B570 and confirmed a 4.92x speedup. Please take a look!

@Captain-Tripps

Copy link
Copy Markdown
Contributor Author

Hi all - Let me know if you need anything else on this one. I have more improvements to submit for the Intel Arc community, but know we aren't supposed to submit more than 1 pr at a time. LMK if you need anything else on this one.

@Captain-Tripps

Copy link
Copy Markdown
Contributor Author

Hi @arthw - Can I get this one reviewed? This was also tested successfully by @Asahi-Prv on an Arc B570.

@arthw arthw left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Arc 770:
There are regression issue of FA=OFF:

GGUF Test fa Base t/s Primary t/s Increase Rate (Primary vs Base)
gpt-oss-20b-mxfp4.gguf pp1024 0 772.86 689.14 -10.83%
gpt-oss-20b-mxfp4.gguf pp1024 1 736.49 748.08 1.57%
gpt-oss-20b-mxfp4.gguf pp2048 0 758.67 680.45 -10.31%
gpt-oss-20b-mxfp4.gguf pp2048 1 698.80 709.56 1.54%
gpt-oss-20b-mxfp4.gguf pp4096 0 725.53 652.83 -10.02%
gpt-oss-20b-mxfp4.gguf pp4096 1 638.20 648.35 1.59%
gpt-oss-20b-mxfp4.gguf pp512 0 784.34 699.39 -10.83%
gpt-oss-20b-mxfp4.gguf pp512 1 753.38 767.10 1.82%
gpt-oss-20b-mxfp4.gguf tg128 0 20.28 26.17 29.04%
gpt-oss-20b-mxfp4.gguf tg128 1 23.80 33.15 39.29%

@arthw

arthw commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

On B60, the result is good:

GGUF Test fa Base t/s Primary t/s Increase Rate (Primary vs Base)
gpt-oss-20b-mxfp4.gguf pp1024 0 566.53 799.02 41.04%
gpt-oss-20b-mxfp4.gguf pp1024 1 602.81 605.15 0.39%
gpt-oss-20b-mxfp4.gguf pp2048 0 554.44 769.21 38.74%
gpt-oss-20b-mxfp4.gguf pp2048 1 591.80 594.01 0.37%
gpt-oss-20b-mxfp4.gguf pp512 0 585.30 839.20 43.38%
gpt-oss-20b-mxfp4.gguf pp512 1 597.88 600.26 0.40%
gpt-oss-20b-mxfp4.gguf tg128 0 29.98 72.46 141.69%
gpt-oss-20b-mxfp4.gguf tg128 1 30.83 77.59 151.67%

@arthw

arthw commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

@Captain-Tripps
Could you check the regression issue on Arc770?
I can support you verify the solution on Arc770.

Thank you!

…ight reordering

Speeds up MXFP4 MoE inference in the SYCL backend, delivering 1.91x faster token generation for gpt-oss-20b and 2.02× for gpt-oss-120b on Intel Arc Pro B70.
- Replaces table-based MXFP4 decoding with bit-identical 32-bit arithmetic, avoiding costly permute emulation.
- Adds lazy, per-expert weight reordering to enable aligned vector loads, with reorder-aware decode, multi-token, and prefill paths.
- Limits temporary reorder memory to 32 MiB and preserves the generic fallback for misaligned tensors.

Assisted-by: Claude Opus 5.5
@Captain-Tripps

Copy link
Copy Markdown
Contributor Author

Hi @arthw -
I've rebased this onto master (4f92965) and added a fix so MXFP4 experts are reordered before the multi-token per-expert loop.

Previously, the reorder only happened in the fused single-token decode path. That meant the first set of prompt-processing tests ran before the experts were reordered, while later tests used the reordered layout. Swapping -fa 0,1 to -fa 1,0 confirmed that the pp results depended on which mode ran first.

With the fix, I’m seeing roughly 20–33% higher pp throughput on my Arc Pro B70 with gpt-oss-20b-Q8_0 (in this unsloth file the expert tensors are MXFP4), in both FA modes and both test orders. Decode improves by about 13–16% with FA off and roughly doubles with FA on. Both builds (stock master and this PR) pass all MUL_MAT_ID and MUL_MAT backend tests, and the perplexity results are within the reported uncertainty.

The rebase also picks up the corrected Metal fusion test baseline from #29812, which should address the earlier CI failure.
This is ready to retest on your A770. I can confirm the order-dependent behavior on the B70, but I can’t verify the earlier 10% pp drop on your hardware here.

Please give the updated version another run with both FA settings when you have a chance.

@arthw

arthw commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

I test with the rebased PR.
The result is good:

  • FA=1 can get same perf increase of FA=0.
  • Switch FA 1 and 0 has a little impact.
  • Small PP size can get big perf increase.
  • Arc770 has perf increase with small PP, but drop with big PP.

Arc 770

FA 0,1

GGUF Test fa Base t/s Primary t/s Increase Rate (Primary vs Base)
gpt-oss-20b-mxfp4.gguf pp16 0 73.48 80.00 8.87%
gpt-oss-20b-mxfp4.gguf pp16 1 76.82 87.98 14.53%
gpt-oss-20b-mxfp4.gguf pp32 0 120.31 128.82 7.07%
gpt-oss-20b-mxfp4.gguf pp32 1 125.22 134.86 7.70%
gpt-oss-20b-mxfp4.gguf pp1024 0 799.30 714.82 -10.57%
gpt-oss-20b-mxfp4.gguf pp1024 1 773.70 692.85 -10.45%
gpt-oss-20b-mxfp4.gguf pp2048 0 783.32 699.67 -10.68%
gpt-oss-20b-mxfp4.gguf pp2048 1 743.81 668.02 -10.19%
gpt-oss-20b-mxfp4.gguf tg128 0 20.26 26.89 32.72%
gpt-oss-20b-mxfp4.gguf tg128 1 23.48 32.51 38.46%

FA 1,0

GGUF Test fa Base t/s Primary t/s Increase Rate (Primary vs Base)
gpt-oss-20b-mxfp4.gguf pp16 0 74.04 82.85 11.90%
gpt-oss-20b-mxfp4.gguf pp16 1 77.55 83.45 7.61%
gpt-oss-20b-mxfp4.gguf pp32 0 120.82 128.64 6.47%
gpt-oss-20b-mxfp4.gguf pp32 1 125.86 131.55 4.52%
gpt-oss-20b-mxfp4.gguf pp1024 0 796.48 709.03 -10.98%
gpt-oss-20b-mxfp4.gguf pp1024 1 780.61 692.10 -11.34%
gpt-oss-20b-mxfp4.gguf pp2048 0 780.61 695.66 -10.88%
gpt-oss-20b-mxfp4.gguf pp2048 1 748.78 667.21 -10.89%
gpt-oss-20b-mxfp4.gguf tg128 0 20.10 26.49 31.79%
gpt-oss-20b-mxfp4.gguf tg128 1 23.65 33.13 40.08%

B60:
FA 0,1

GGUF Test fa Base t/s Primary t/s Increase Rate (Primary vs Base)
gpt-oss-20b-mxfp4.gguf pp16 0 81.73 169.69 107.62%
gpt-oss-20b-mxfp4.gguf pp16 1 83.63 178.00 112.84%
gpt-oss-20b-mxfp4.gguf pp32 0 120.64 244.72 102.85%
gpt-oss-20b-mxfp4.gguf pp32 1 121.15 244.43 101.76%
gpt-oss-20b-mxfp4.gguf pp1024 0 591.21 830.67 40.50%
gpt-oss-20b-mxfp4.gguf pp1024 1 614.89 882.75 43.56%
gpt-oss-20b-mxfp4.gguf pp2048 0 572.22 789.95 38.05%
gpt-oss-20b-mxfp4.gguf pp2048 1 611.43 871.59 42.55%
gpt-oss-20b-mxfp4.gguf tg128 0 29.98 72.40 141.49%
gpt-oss-20b-mxfp4.gguf tg128 1 30.86 77.53 151.23%

FA 1,0

GGUF Test fa Base t/s Primary t/s Increase Rate (Primary vs Base)
gpt-oss-20b-mxfp4.gguf pp16 0 83.56 177.33 112.22%
gpt-oss-20b-mxfp4.gguf pp16 1 81.90 170.13 107.73%
gpt-oss-20b-mxfp4.gguf pp32 0 120.86 244.25 102.09%
gpt-oss-20b-mxfp4.gguf pp32 1 121.54 246.76 103.03%
gpt-oss-20b-mxfp4.gguf pp1024 0 588.15 828.07 40.79%
gpt-oss-20b-mxfp4.gguf pp1024 1 621.23 893.58 43.84%
gpt-oss-20b-mxfp4.gguf pp2048 0 568.67 788.83 38.71%
gpt-oss-20b-mxfp4.gguf pp2048 1 616.13 876.02 42.18%
gpt-oss-20b-mxfp4.gguf tg128 0 29.97 72.33 141.34%
gpt-oss-20b-mxfp4.gguf tg128 1 30.88 77.49 150.94%

@arthw arthw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good job!

Thank you!

@arthw arthw added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Oct 9, 2026
@Captain-Tripps

Copy link
Copy Markdown
Contributor Author

The only failing check is webgpu-nvidia — test-llama-archs -s 1 segfaults (exit 139) on the Tesla T4 runner right after the llama | WebGPU | Dense row: https://github.com/ggml-org/llama.cpp/actions/runs/37786212628/job/113693910664

This PR only touches ggml/src/ggml-sycl/*, so it should not affect the WebGPU build/tests, and the same workflow has failed recently on unrelated PRs. Could someone with rights rerun the failed job? Happy to rebase if it fails again. Thank you!

@Titaniumtown
Titaniumtown merged commit 1e6f04a into ggml-org:master Oct 10, 2026
21 of 22 checks passed
@Titaniumtown

Copy link
Copy Markdown
Contributor

@Captain-Tripps Thank you for your diligance checking the exact build failure and making sure your changes didn't break anything. I appreciate it!

ckti pushed a commit to ckti/llama.cpp-consolidated that referenced this pull request Oct 12, 2026
@BrewTestBot BrewTestBot mentioned this pull request Oct 15, 2026
1 task done
iki007 pushed a commit to iki007/llama.cpp that referenced this pull request Oct 21, 2026
…ight reordering

Port of ggml-org/llama.cpp PR ggml-org#29809 (commit 97987dc9b) onto this branch. Adapted: the MoE reorder launcher takes this branch's multi-token arguments, the reorder multi-column switch goes to 16 columns, MXFP4 joins the fused gate + up + GLU launcher and the type lists that had more entries here.

gpt-oss-20b on one Arc Pro B70 (Linux): tg128 53.72 -> 137.7 t/s, pp512 1671 -> 1690 t/s. MUL_MAT_ID 32 experts / 4 used, 2880 x 2880: 1 token 159 -> 34.7 us, 8 tokens 1446 -> 280 us.

Assisted-by: Claude Opus 5.5
iki007 added a commit to iki007/llama.cpp that referenced this pull request Oct 21, 2026
…does

Upstream merged ggml-org#29809 (MXFP4 MoE with arithmetic decoding and weight reordering, 1e6f04a), which this branch
carried as a port. The replay onto it kept the port where the two differ: up to 16 columns, the token strides of
this branch's MoE kernel, its fused GLU launch and its reorder gate. Upstream's version also reorders MXFP4
experts at the top of the per-expert path of ggml_sycl_mul_mat_id(), so a prompt batch does not depend on a
single-token decode having run first. That call is taken here; with it the tree is the merge of this branch
with master f2918ca.

Assisted-by: Claude Opus 5.5
iki007 pushed a commit to iki007/llama.cpp that referenced this pull request Oct 22, 2026
…ight reordering

Port of ggml-org/llama.cpp PR ggml-org#29809 (commit 97987dc9b) onto this branch. Adapted: the MoE reorder launcher takes this branch's multi-token arguments, the reorder multi-column switch goes to 16 columns, MXFP4 joins the fused gate + up + GLU launcher and the type lists that had more entries here.

gpt-oss-20b on one Arc Pro B70 (Linux): tg128 53.72 -> 137.7 t/s, pp512 1671 -> 1690 t/s. MUL_MAT_ID 32 experts / 4 used, 2880 x 2880: 1 token 159 -> 34.7 us, 8 tokens 1446 -> 280 us.

Assisted-by: Claude Opus 5.5
iki007 added a commit to iki007/llama.cpp that referenced this pull request Oct 22, 2026
…does

Upstream merged ggml-org#29809 (MXFP4 MoE with arithmetic decoding and weight reordering, 1e6f04a), which this branch
carried as a port. The replay onto it kept the port where the two differ: up to 16 columns, the token strides of
this branch's MoE kernel, its fused GLU launch and its reorder gate. Upstream's version also reorders MXFP4
experts at the top of the per-expert path of ggml_sycl_mul_mat_id(), so a prompt batch does not depend on a
single-token decode having run first. That call is taken here; with it the tree is the merge of this branch
with master f2918ca.

Assisted-by: Claude Opus 5.5
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 24, 2026
auRose94 pushed a commit to auRose94/llama.cpp that referenced this pull request Oct 28, 2026
iki007 pushed a commit to iki007/llama.cpp that referenced this pull request Oct 29, 2026
…ight reordering

Port of ggml-org/llama.cpp PR ggml-org#29809 (commit 97987dc9b) onto this branch. Adapted: the MoE reorder launcher takes this branch's multi-token arguments, the reorder multi-column switch goes to 16 columns, MXFP4 joins the fused gate + up + GLU launcher and the type lists that had more entries here.

gpt-oss-20b on one Arc Pro B70 (Linux): tg128 53.72 -> 137.7 t/s, pp512 1671 -> 1690 t/s. MUL_MAT_ID 32 experts / 4 used, 2880 x 2880: 1 token 159 -> 34.7 us, 8 tokens 1446 -> 280 us.

Assisted-by: Claude Opus 5.5
iki007 added a commit to iki007/llama.cpp that referenced this pull request Oct 29, 2026
…does

Upstream merged ggml-org#29809 (MXFP4 MoE with arithmetic decoding and weight reordering, 1e6f04a), which this branch
carried as a port. The replay onto it kept the port where the two differ: up to 16 columns, the token strides of
this branch's MoE kernel, its fused GLU launch and its reorder gate. Upstream's version also reorders MXFP4
experts at the top of the per-expert path of ggml_sycl_mul_mat_id(), so a prompt batch does not depend on a
single-token decode having run first. That call is taken here; with it the tree is the merge of this branch
with master f2918ca.

Assisted-by: Claude Opus 5.5
iki007 pushed a commit to iki007/llama.cpp that referenced this pull request Nov 4, 2026
…ight reordering

Port of ggml-org/llama.cpp PR ggml-org#29809 (commit 97987dc9b) onto this branch. Adapted: the MoE reorder launcher takes this branch's multi-token arguments, the reorder multi-column switch goes to 16 columns, MXFP4 joins the fused gate + up + GLU launcher and the type lists that had more entries here.

gpt-oss-20b on one Arc Pro B70 (Linux): tg128 53.72 -> 137.7 t/s, pp512 1671 -> 1690 t/s. MUL_MAT_ID 32 experts / 4 used, 2880 x 2880: 1 token 159 -> 34.7 us, 8 tokens 1446 -> 280 us.

Assisted-by: Claude Opus 5.5
iki007 added a commit to iki007/llama.cpp that referenced this pull request Nov 4, 2026
…does

Upstream merged ggml-org#29809 (MXFP4 MoE with arithmetic decoding and weight reordering, 1e6f04a), which this branch
carried as a port. The replay onto it kept the port where the two differ: up to 16 columns, the token strides of
this branch's MoE kernel, its fused GLU launch and its reorder gate. Upstream's version also reorders MXFP4
experts at the top of the per-expert path of ggml_sycl_mul_mat_id(), so a prompt batch does not depend on a
single-token decode having run first. That call is taken here; with it the tree is the merge of this branch
with master f2918ca.

Assisted-by: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. SYCL https://en.wikipedia.org/wiki/SYCL - GPU programming language

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants