Skip to content

sycl: guard DMMV reads at row tails - #29338

Merged
Titaniumtown merged 1 commit into
ggml-org:masterfrom
newjordan:sycl/dmmv-tail-ready-20260923
Oct 12, 2026
Merged

Titaniumtown merged 1 commit into
ggml-org:masterfrom
newjordan:sycl/dmmv-tail-ready-20260923

Conversation

@newjordan

@newjordan newjordan commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Overview

  • Skip DMMV lanes past ncols before reading quantized weights and activations, fixing the 96-column row-tail read.
  • Test shared-weight decode, batch, and decode reuse.

Tested and reviewed: 2026-09-23

Results

Intel Arc Pro B70, oneAPI 2026.1.1. Baseline -> patch; SYCL optimizations disabled.

  • Reuse: 16/16 cases pass in four runs. The unpatched control fails the 96-column case (15/16).
  • Quantized MUL_MAT_ID: 239/241 pass. The two high-amplitude NaN cases also fail on pristine upstream.
  • Aligned-row DMMV (m=4096, k=14336, n=1): 432.19 -> 434.63 us (+0.56% latency); baseline runs span 430.10-434.28 us.

Additional information

This PR and #29337 add the same reuse fixture; refresh the second PR after the first merges.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES - Codex assisted with implementation, testing, and benchmark analysis.

@github-actions github-actions Bot added testing Everything test related ggml changes relating to the ggml tensor library for machine learning SYCL https://en.wikipedia.org/wiki/SYCL - GPU programming language labels Sep 23, 2026
@newjordan
newjordan marked this pull request as ready for review September 23, 2026 18:20
@newjordan
newjordan requested review from a team and ggerganov as code owners September 23, 2026 18:20

@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.

I test it:
Qwen3.6-14B-A3B-FableVibes-Q4_K_M.gguf on Arc770:

Test fa Base t/s Primary t/s Increase Rate (Primary vs Base)
pp512 0 739.41 740.75 0.18%
pp512 1 763.79 762.26 -0.20%
tg128 0 51.05 51.13 0.16%
tg128 1 52.18 52.09 -0.17%

UT is passed too.

Comment thread tests/test-backend-ops.cpp Outdated
Comment on lines +10216 to +10224
for (bool broadcast : {false, true}) {
for (int k : {96, 256}) {
for (int n : {1, 4, 8, 32}) {
test_cases.emplace_back(new test_mul_mat_id_reuse(
GGML_TYPE_Q8_0, GGML_TYPE_F32, 4, 2, broadcast, 64, n, k));
}
}
}

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.

Move the code for new cases behind the cases of mul_mat_id.
It will avoid the MUL_MAT_ID_REUSE appear in the middle of MUL_MAT_ID in the log.

Thank you!

@Titaniumtown

Copy link
Copy Markdown
Contributor

Please rebase!

@newjordan
newjordan force-pushed the sycl/dmmv-tail-ready-20260923 branch from 9fb047e to a538fe4 Compare September 27, 2026 02:37

@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 Sep 29, 2026
Comment thread tests/test-backend-ops.cpp Outdated
Comment on lines +5307 to +5335
struct test_mul_mat_id_reuse : public test_mul_mat_id {
using test_mul_mat_id::test_mul_mat_id;
std::vector<ggml_tensor *> outputs;

std::string op_desc(ggml_tensor *) override {
return "MUL_MAT_ID_REUSE";
}

ggml_tensor * build_graph(ggml_context * ctx) override {
ggml_tensor * batch = test_mul_mat_id::build_graph(ctx);
ggml_tensor * weights = batch->src[0];
ggml_tensor * act = batch->src[1];
ggml_tensor * ids = batch->src[2];
ggml_tensor * act_one = ggml_view_3d(ctx, act, k, act->ne[1], 1, act->nb[1], act->nb[2], 0);
ggml_tensor * ids_one = ggml_view_2d(ctx, ids, n_used, 1, ids->nb[1], 0);
ggml_tensor * first = ggml_mul_mat_id(ctx, weights, act_one, ids_one);
ggml_tensor * last = ggml_mul_mat_id(ctx, weights, act_one, ids_one);

// Reuse the weights across decode, batch, and decode dispatch.
outputs = {first, batch, last};
for (ggml_tensor * out : outputs) {
ggml_build_forward_expand(gf, out);
}
return last;
}

bool run_whole_graph() override { return true; }
std::vector<ggml_tensor *> fusion_test_nodes() override { return outputs; }
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand the purpose of this test. What does "reuse" mean in this context?

Most likely it's better to not add the test - just narrow down to the SYCL changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed — it was meant to exercise the same expert weights through decode → batch → decode dispatch to catch stale reorder state, but the SYCL fix doesn't depend on it. Removed; the PR is now SYCL-only and rebased on master.

@ggerganov ggerganov removed the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Sep 29, 2026
@arthw

arthw commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

@newjordan
Could you reply the comments of new UT case test_mul_mat_id_reuse?

Thank you!

@arthw

arthw commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@newjordan
Could you check the review comments?

Thank you!

Skip lanes whose column falls outside the row, so rows whose length is not
a multiple of the per-iteration stride do not read past the end.

Assisted-by: Codex
@newjordan
newjordan force-pushed the sycl/dmmv-tail-ready-20260923 branch from a538fe4 to 610852b Compare October 7, 2026 13:30
@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 12, 2026
@Titaniumtown
Titaniumtown merged commit f9a95ae into ggml-org:master Oct 12, 2026
21 of 22 checks passed
@BrewTestBot BrewTestBot mentioned this pull request Oct 15, 2026
1 task done
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
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 testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants