Archived
libxe2: split the ESIMD GEMV along K for wide outputs too
gemv_esimd_splits only aimed at ~8192 threads, so an output wide enough to fill the card at one split (the lm head, N = 248320) ran S = 1: each thread walked all of K alone and was latency-bound at ~350-530 GB/s. The split now also keeps K a thread at ~1024 or less. rad-kbench, B65, cold weights (us): logits_gemm n_vocab 248320 n_embd 5120 M=1 4710 -> 4255 M=4 4674 -> 4289 logits_gemm n_vocab 248320 n_embd 4096 M=1 3652 -> 3418 gemm_nt N 34816 K 5120 M=1 621 -> 605 other gemm_nt shapes unchanged. kbench 1989/1989 replay, model checks pass; Qwen3.8-27B greedy output unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eda5b01708
commit
b52a180141
1 file changed
+8
-3
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#include <sycl/ext/intel/esimd.hpp>
|
#include <sycl/ext/intel/esimd.hpp>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace xe2 {
|
namespace xe2 {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -78,11 +80,14 @@ int launch(sycl::queue& q, const uint16_t* a, int64_t ars, int mm, const uint16_
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
/* The split count for N columns and K: the smallest divisor of K / 16 that gives ~8192 threads, at
|
/* The split count for N columns and K: the smallest divisor of K / 16 that gives ~8192 threads and
|
||||||
* most kMaxS; 0 when K / 16 has none worth taking (the caller then keeps its SIMT form). */
|
* at most ~1024 of K a thread, at most kMaxS; 0 when K / 16 has none worth taking (the caller then
|
||||||
|
* keeps its SIMT form). The K bound is for wide outputs that fill the card at one split: a thread
|
||||||
|
* walking all of a long K alone is latency-bound (probe bfgl.cpp, M = 1, cold weights: logits
|
||||||
|
* N 248320 K 5120 S 1 7.27 ms, 350 GB/s -> S 5 4.21 ms, 604 GB/s; K 4096 S 1 5.78 -> S 4 3.39 ms). */
|
||||||
int gemv_esimd_splits(int64_t N, int64_t K) {
|
int gemv_esimd_splits(int64_t N, int64_t K) {
|
||||||
const int64_t tiles = N / 16, steps = K / 16;
|
const int64_t tiles = N / 16, steps = K / 16;
|
||||||
const int64_t want = (8192 + tiles - 1) / tiles;
|
const int64_t want = std::max<int64_t>((8192 + tiles - 1) / tiles, (K + 1023) / 1024);
|
||||||
int best = 0;
|
int best = 0;
|
||||||
for (int s = 1; s <= kMaxS && s <= steps; ++s) {
|
for (int s = 1; s <= kMaxS && s <= steps; ++s) {
|
||||||
if (steps % s) continue;
|
if (steps % s) continue;
|
||||||
|
|||||||
Reference in new issue
Block a user