sycl: contiguous fast path + 32-bit index math for unary elementwise ops - #25946
Conversation
arthw
left a comment
There was a problem hiding this comment.
It's good job!
With Qwen3.6-27B-UD-Q4_K_XL.gguf on B60:
| Test | fa | Base t/s | Primary t/s | Increase Rate (Primary vs Base) |
|---|---|---|---|---|
| pp512 | 0 | 186.00 | 189.34 | 1.80% |
| pp512 | 1 | 184.17 | 187.44 | 1.78% |
| tg128 | 0 | 16.91 | 16.99 | 0.47% |
| tg128 | 1 | 16.90 | 17.00 | 0.59% |
Thank you!
|
@Titaniumtown |
|
Ok, no problem! |
|
Have you considered using common.hpp:fast_div_modulo()? Could be another half-percent for you to grab if my test of your approach applied to gated_op_fused_swiglu() is good metric.
¹ mode1 pp512 sd inflated by one 848 t/s rep in block 2 (DVFS blip); its other 7 samples ≈ 876. |
|
@mndodd Cool find! I don't have the time in the next few days to do this, but I will definitely check this out when I can. |
|
@Titaniumtown Thank you! |
7e614b9 to
bc72017
Compare
|
@mndodd Thanks for the suggestion, I added this! |
|
Ready for review! |
Overview
Every op routed through ggml_sycl_op_unary (silu, sigmoid, gelu*, exp, softplus, ETC) ran a generic strided kernel doing three int64 div/mod per element to reconstruct 4-D indices.
Intel's Xe cores has no native 64-bit integer divide op. So when compiling the kernels, ICPX adds its own implementation. The extra index math then dominates the kernel's compute time: SILU measured 3.2 ms/call on {2048,17408} f32 activations vs a ~0.63 ms bandwidth floor. This path is called 96x per qwen 3.6 ubatch, which results in 13% of profiled op time during prefill.
But, when src0 and dst are both contiguous, we can skip the index reconstruction as the reconstruction of indices is wasteful compute-wise when it can be easily calculated.
So what I ended up doing is adding a fast path that allows the skipping of those very very performance heavy division and 4-D index reconstruction operations.
Additional information
Benchmarks on an Arc B70 Pro
llama-bench -m Qwen3.6-27B-UD-Q4_K_XL.gguf -ngl 999 -fa 1-ctk q8_0 -ctv q8_0 -p 512,2048 -n 128 -r 4
master @ 571d0d5:
This PR:
TL;DR 4.3-3.9% uplift on pp bandwidth with no effect on decode.
Requirements