Archived
libxe2: the skinny bf16 GEMM at M <= 8 in ESIMD -- ssm_ab 38.6 -> 4.7 us, the MTP block's GEMVs up to 2x
A thread a (16-column tile, K split): W^T comes straight from the weight rows by one transposed 2D load a 16-column step (the bf16 DPAS's VNNI B operand as it arrives), the activation by a 2D load (rows past M as zeros), one DPAS of RC = 1, 2, 4 or 8 rows; a work-group is one tile's splits, summed in split order in local memory. S is the smallest divisor of K/16 giving ~8192 threads, at most 40. Probe bfg.cpp: the DeltaNet's N = 96 projection at M = 4 38.6 -> 4.7 us (launch_dpas8 staged all 8 rows x K in each of 6 work-groups); the MTP block at M = 1, N 5120 K 6144 ~206 -> 110, N 5120 K 10240 ~370 -> 180, N 12288 ~375 -> 214, N 34816 ~682 -> 595 (synthetic bf16, which compresses a little). rad-kbench: fixture gemm_nt + logits_gemm 686/686; qwen3.8-27b-w4a16-rtn gemm_nt 622/622 (the new rows' worst rel_l2 1.5e-4, tolerance 8e-3). A first version reduced only rows below S, so rows 4-7 of an 8-row call over 4 splits were never stored (kbench caught it: rel_l2 0.71). Decode proxy (dec_quick.py): a round ~2-3 ms shorter, 45.5 -> 46.3 tok/s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dd0ee312a4
commit
d63d1bc8a5
2 files changed
+111
-1
No files matched your search
+16
-1
@@ -25,6 +25,11 @@
|
||||
|
||||
namespace xe2 {
|
||||
|
||||
/* xe2_gemv_esimd.cpp */
|
||||
int gemv_esimd_splits(int64_t N, int64_t K);
|
||||
int gemv_esimd(sycl::queue& q, int rc, const uint16_t* a, int64_t ars, int mm, const uint16_t* w, int64_t wrs, char* yb,
|
||||
uint32_t ydt, int64_t yrs, int64_t N, int64_t K, int S);
|
||||
|
||||
bool exact_only() {
|
||||
static const bool on = [] {
|
||||
const char* e = std::getenv("XE2_EXACT");
|
||||
@@ -253,6 +258,17 @@ int gemv(const RadArgs* a, RadStream st, const char* nkey, const char* kkey, int
|
||||
const int mm = (int)M;
|
||||
sycl::queue* q = queue_of(st);
|
||||
if (!q) return RAD_E_DEVICE;
|
||||
static const bool simt = std::getenv("XE2_GEMV_SIMT") != nullptr;
|
||||
/* M <= 8 in ESIMD (xe2_gemv_esimd.cpp) where its 2D loads can read the operands: a thread a
|
||||
* (tile, K split), W^T by transposed loads, the splits summed in order in local memory. */
|
||||
if (mm <= 8 && N % 16 == 0 && K % 16 == 0 && ycs == 1 && !simt && rad_ptr_aligned(ab, 64) &&
|
||||
rad_ptr_aligned(bb, 64) && rad_ptr_aligned(yb, 64) && (brs * 2) % 64 == 0 && (ars * 2) % 64 == 0 &&
|
||||
(yrs * (ydt == RAD_F32 ? 4 : 2)) % 64 == 0) {
|
||||
const int S = gemv_esimd_splits(N, K);
|
||||
if (S > 0)
|
||||
return gemv_esimd(*q, mm == 1 ? 1 : (mm <= 2 ? 2 : (mm <= 4 ? 4 : 8)), ab, ars, mm, bb, brs, yb, ydt, yrs,
|
||||
N, K, S);
|
||||
}
|
||||
/* Decode (M = 1) takes the lean form with kCols columns a sub-group; M up to 16 one column a
|
||||
* sub-group with a partial sum a row. Sizing the accumulators by the band keeps them in
|
||||
* registers (four columns at sixteen rows spilled and ran slower than one). */
|
||||
@@ -265,7 +281,6 @@ int gemv(const RadArgs* a, RadStream st, const char* nkey, const char* kkey, int
|
||||
if (S > 1) return launch_split<kCols>(*q, ab, bb, yb, ydt, N, K, brs, ycs, S);
|
||||
return launch<kCols, 1>(*q, ab, bb, yb, ydt, N, K, ars, brs, yrs, ycs, 1);
|
||||
}
|
||||
static const bool simt = std::getenv("XE2_GEMV_SIMT") != nullptr;
|
||||
if (mm <= 8 && N % 16 == 0 && K % 16 == 0 && K <= 6144 && !simt)
|
||||
return launch_dpas8(*q, ab, bb, yb, ydt, N, K, ars, brs, yrs, ycs, mm);
|
||||
return launch<1, kMaxM>(*q, ab, bb, yb, ydt, N, K, ars, brs, yrs, ycs, mm);
|
||||
|
||||
Reference in new issue
Block a user