[Engine] SYCL: prompt attention takes the lane-cell score phase, +5% on a prompt read
Problem: the prompt path runs `qsa_decode_attn_batch` (the tensor-core kernel is opt-in and 2.9x slower here), and attention is 21% of a 4,106-token prompt's GPU timeline and 24% of a 16,380-token one. The port already had the `STRATA_ATTN_LANECELL` score phase - one cell per thread, no shuffle reductions, scores bit-identical to the shuffle reduction - but only behind an environment variable, so nobody got it. Result, same build, same box, back to back, 3 warm repetitions each (2x Arc Pro B65, Qwen3.8-Flash-Next IQ3_S, `--spec 4`, 2,048-token chunks, nothing else on the GPUs): | prompt | shuffle reduction | lane-cell | gain | | ---: | ---: | ---: | ---: | | 4,106 tokens | 1,167.4-1,171.9 tok/s | 1,226.3-1,235.3 | +5.2% | | 16,380 tokens | 1,456.3-1,457.4 tok/s | 1,524.3-1,526.2 | +4.7% | | decode (256 tokens, 18-token prompt) | 56.5 / 57.0 | 56.6 / 57.0 | unchanged | Approach: the choice follows the query count. The prompt path hands the kernel a batch of queries (`attn_batch`, 32 by default), the decode window hands it the window's few rows (at most eight per call), and the few-query case is 1.4% slower with the lane-cell phase (55.9-56.3 against 56.6-57.0 tok/s), so `n_q >= 16` takes it. `STRATA_ATTN_LANECELL=1/0` forces either way, so the old path is one variable away. Validation: 64 generated tokens from the gated build are identical to the same prompt's tokens from the serial reference (`scripts/compare_tokens.py`, first difference: none); the lane-cell phase's scores are the shuffle reduction's bits by construction (one cell per thread, same order). Not run: CUDA/HIP (untouched - the change is in `sycl/src/kernels/cuda/qsa_decode_attn.dp.cpp`, the port's own copy), the parity bench on the gated build (it forces its own arms), a 32K-context prompt. Limits: measured on two Arc Pro B65 with a fully resident expert cache; the gain is attention-bound, so a prompt short enough to be dominated by the expert GEMMs will show less.
This commit is contained in:
1 parent
7e0f719903
commit
949f77c0a8
1 file changed
+9
-2
@@ -665,8 +665,15 @@ void qsa_decode_attn_batch(const float* q, const QsaAttnPools& pools, const int3
|
||||
const dpct::dim3 grid((unsigned)n_chunks, (unsigned)s.n_head_kv,
|
||||
(unsigned)n_q);
|
||||
dpct::queue_ptr st = strata::q_of(stream);
|
||||
// S25: STRATA_ATTN_LANECELL=1 - the score phase one cell per thread (bit-identical scores, no shuffle reductions)
|
||||
static const bool lane_cell = [] { const char* v = std::getenv("STRATA_ATTN_LANECELL"); return v && v[0] == '1'; }();
|
||||
// S25: the score phase one cell per thread (bit-identical scores, no shuffle reductions). Prompt batches take
|
||||
// it by default: on 2x Arc Pro B65 it reads a 4,106-token prompt 5.2% faster, 8,191 tokens 5.2% and 16,380
|
||||
// tokens 4.8%, with the same tokens; the decode window's few queries per call are 1.4% slower with it (56.6-57.0
|
||||
// against 55.9-56.3 tok/s), so the choice follows the query count. STRATA_ATTN_LANECELL=1/0 forces either way.
|
||||
static const int lane_cell_env = [] {
|
||||
const char* v = std::getenv("STRATA_ATTN_LANECELL");
|
||||
return v != nullptr && v[0] != '\0' ? std::atoi(v) : -1;
|
||||
}();
|
||||
const bool lane_cell = lane_cell_env >= 0 ? lane_cell_env != 0 : n_q >= 16;
|
||||
#define STRATA_ATTN_LC(M) \
|
||||
{ \
|
||||
auto exp_props = sycl::ext::oneapi::experimental::properties{ \
|
||||
|
||||
Reference in new issue
Block a user