From 9a9c831f7972e0bd08d2f49cdf92b41946ea8cdc Mon Sep 17 00:00:00 2001 From: claude Date: Sat, 24 Oct 2026 16:30:37 +0200 Subject: [PATCH] libxe2: gdn_chunk_scan on 1024 work-items a work-group -- 2.68 -> 0.92 s a 1882-token prefill The chain-parallel scan's ~124 KB of local memory leaves one work-group a Xe core, and at 256 work-items that left three quarters of the core's threads idle. Every phase is a set of independent chains strided by the work-group size, so the work-group is now the core's 1024: the same chains in the same order, fixture 90/90 and 72/72 on the 27B at rel_l2 0. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1 --- libxe2/xe2_gdn.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libxe2/xe2_gdn.cpp b/libxe2/xe2_gdn.cpp index 3bb47982..dc10c023 100644 --- a/libxe2/xe2_gdn.cpp +++ b/libxe2/xe2_gdn.cpp @@ -626,13 +626,15 @@ int gdn_chunk_scan(const RadArgs* a, RadStream st) { sycl::queue* qu = queue_of(st); if (!qu) return RAD_E_DEVICE; if (K == 128 && V % 32 == 0 && chunk == 64 && !std::getenv("XE2_GDN_SCAN1")) { - /* A work-group of 256 a (sequence, v head, block of 32 value columns), the chunk's k, q, + /* A work-group of 1024 a (sequence, v head, block of 32 value columns), the chunk's k, q, * the block's slices of v, S, W, V' and the sA rows R in local memory (~124 KB). Each phase * of a chunk is a set of independent chains -- W[j][e], V'[i][e], R[i][j], O[i][e], S[d][e] * -- each run by one work-item in libref's order, so the scan is libref's; the parallelism * is the chains' (thousands a phase), not one column a work-item. R and the decays depend - * only on q, k, g, so each column block forms them again. */ - constexpr int CB = 32, CK = 64, KK = 128, WG = 256; + * only on q, k, g, so each column block forms them again. Its ~124 KB of local memory + * leaves one work-group a Xe core, so the work-group is the core's 1024 work-items: 256 + * left three quarters of its threads idle (2.68 -> 0.92 s over a 1882-token prefill). */ + constexpr int CB = 32, CK = 64, KK = 128, WG = 1024; constexpr int KP = KK + 1; /* k and q rows padded: the R phase's lanes read different rows */ const int64_t nblk = V / CB; /* e^{g_i - g_j} for every (row i, chunk position j <= i of i's chunk), libref's double exp