Archived
libxe2: w2a8 head -- 64 threads share the staged activation, a group's codes one load: 1.66 -> 0.74 ms
Work-groups of 16 threads staged the 40 KB activation into local memory for 16 tiles each; 64 threads amortise it over four times the columns (16: 1.66 ms, 32: 0.96), and a group of 128 reads its four steps' codes as one 512-byte block load (32: 0.77, 64: 0.74 ms in the round, unitrace -d). Checked as before: 20 calls on the engine's inputs against the SIMT GEMV, 0 of 1738240 outputs differ each; greedy output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
This commit is contained in:
1 parent
34ae231e97
commit
2a5e815a95
1 file changed
+25
-7
@@ -1,9 +1,9 @@
|
||||
/* xe2_gemm_zp_esimd.cpp -- the w2a8 head (the DFlash2 drafter's 2-bit vocabulary head, N = 248320)
|
||||
* in ESIMD, over the u2 codes stored tiled (xe2_ops.h, zp_tiled). Int8 DPAS takes 2-bit B operands
|
||||
* on this card, 16 codes a dword from the low end (probe dpas_u2.cpp), so the tiled codes are the B
|
||||
* operand as they lie: no decode. A thread owns 16 columns; a group is group / 32 DPAS steps of one
|
||||
* 128-byte block load each, against the activation staged once a work-group in local memory as the
|
||||
* A operand's [step][row][32 bytes]. Each group's integer sum is exact in int32, and its term
|
||||
* operand as they lie: no decode. A thread owns 16 columns; a group is group / 32 DPAS steps (a
|
||||
* group of 128 one 512-byte block load), against the activation staged once a work-group of 64
|
||||
* threads in local memory as the A operand's [step][row][32 bytes]. Each group's integer sum is exact in int32, and its term
|
||||
* ((is - zero * a_sum) * a_scale) * scale is added in group order: zp_dpas's (and libref's) chain,
|
||||
* so the result is the same bit for bit. Rows past M are staged as zeros and not stored. */
|
||||
#include "xe2_common.h"
|
||||
@@ -20,12 +20,10 @@ namespace {
|
||||
namespace esimd = sycl::ext::intel::esimd;
|
||||
namespace xmx = sycl::ext::intel::esimd::xmx;
|
||||
|
||||
constexpr int kWg = 16; /* threads a work-group */
|
||||
constexpr int kSlm = 8 * 8192; /* the staged activation: 8 rows of up to 8192 */
|
||||
|
||||
} // namespace
|
||||
|
||||
int zp_esimd(sycl::queue& q, const int8_t* ab, int64_t ars, const float* sa, int64_t sa_rs, const float* asum,
|
||||
template <int kWg, bool G4>
|
||||
int launch(sycl::queue& q, const int8_t* ab, int64_t ars, const float* sa, int64_t sa_rs, const float* asum,
|
||||
int64_t mpad, const uint32_t* bt, const char* bsb, char* yb, uint32_t ydt, int64_t ys_r, int64_t ys_c,
|
||||
int64_t N, int64_t K, int64_t group, int mm) {
|
||||
const int64_t ntile = N / 16, ng = (ntile + kWg - 1) / kWg;
|
||||
@@ -64,6 +62,15 @@ int zp_esimd(sycl::queue& q, const int8_t* ab, int64_t ars, const float* sa, int
|
||||
const uint32_t* tb = bt + tile * steps * 32;
|
||||
for (int64_t g = 0; g < G; ++g) {
|
||||
simd<int32_t, 128> c = 0;
|
||||
if constexpr (G4) { /* group = 128: its four steps' codes one 512-byte load */
|
||||
simd<uint32_t, 128> B4 = block_load<uint32_t, 128>(tb + g * 128);
|
||||
_Pragma("unroll") for (int s = 0; s < 4; ++s) {
|
||||
const simd<int32_t, 64> A = slm_block_load<int32_t, 64>((uint32_t)((g * 4 + s) * 256));
|
||||
const simd<uint32_t, 32> B = B4.template select<32, 1>(s * 32);
|
||||
c = xmx::dpas<8, 8, int32_t, int32_t, uint32_t, int32_t, xmx::dpas_argument_type::u2,
|
||||
xmx::dpas_argument_type::s8>(c, B, A);
|
||||
}
|
||||
} else
|
||||
for (int64_t s = 0; s < gs; ++s) {
|
||||
const int64_t st = g * gs + s;
|
||||
const simd<uint32_t, 32> B = block_load<uint32_t, 32>(tb + st * 32);
|
||||
@@ -112,4 +119,15 @@ int zp_esimd(sycl::queue& q, const int8_t* ab, int64_t ars, const float* sa, int
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int zp_esimd(sycl::queue& q, const int8_t* ab, int64_t ars, const float* sa, int64_t sa_rs, const float* asum,
|
||||
int64_t mpad, const uint32_t* bt, const char* bsb, char* yb, uint32_t ydt, int64_t ys_r, int64_t ys_c,
|
||||
int64_t N, int64_t K, int64_t group, int mm) {
|
||||
/* 64 threads a work-group share one staging of the activation (16: 1.66 ms a call, 32: 0.96,
|
||||
* and with a group's codes one 512-byte load, 32: 0.77, 64: 0.74) */
|
||||
if (group == 128) return launch<64, true>(q, ab, ars, sa, sa_rs, asum, mpad, bt, bsb, yb, ydt, ys_r, ys_c, N, K, group, mm);
|
||||
return launch<64, false>(q, ab, ars, sa, sa_rs, asum, mpad, bt, bsb, yb, ydt, ys_r, ys_c, N, K, group, mm);
|
||||
}
|
||||
|
||||
} // namespace xe2
|
||||
Reference in new issue
Block a user