Repository navigation
sycl: guard DMMV reads at row tails - #29338
Conversation
arthw
left a comment
There was a problem hiding this comment.
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.
| 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)); | ||
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
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!
|
Please rebase! |
9fb047e to
a538fe4
Compare
| 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; } | ||
| }; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
@newjordan Thank you! |
|
@newjordan 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
a538fe4 to
610852b
Compare
Overview
ncolsbefore reading quantized weights and activations, fixing the 96-column row-tail read.Tested and reviewed: 2026-09-23
Results
Intel Arc Pro B70, oneAPI 2026.1.1. Baseline -> patch; SYCL optimizations disabled.
MUL_MAT_ID: 239/241 pass. The two high-amplitude NaN cases also fail on pristine upstream.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