libxe2: m2xfp4 meta and exponents tiled too, each column's max exponent stored at load -- gate_up 222 -> 205 us

Where N % 16 == 0 and K % 512 == 0 the meta bytes (in the codes blob) and the E8M0 plane (b_scale,
tag "xe2.m2.e8m0.t16") are stored in chunks of a tile's 16 groups, [dword][lane], so the ESIMD
kernel reads four steps of them with one block load each instead of gathers across 16 rows. The
exponent plane's stored form appends each column's largest exponent (int32), computed once at
load, so the prepass no longer scans the plane on every call; unrelayout drops it and untiles the
exponents exactly. Every m2 reader reads the tiled forms.

rad-kbench against libref: 70 checked, 70 passed (worst rel_l2 1.2e-3). M = 8: gate_up 222 -> 205,
down 119 -> 113 us; prefill shapes flat to -5%. Greedy output identical; 512-token decode 33.3 ->
33.9 tok/s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
This commit is contained in:
claudeandClaude Opus 5.5 committed 2026-10-26 02:06:52 +01:00
1 parent 68d510b1f4
commit dad30c6b59
4 files changed
+124 -47

No files matched your search

+25 -8
View File
@@ -111,15 +111,32 @@ int launch(sycl::queue& q, const half* ae, const uint8_t* codes0, const uint8_t*
* a step was a third of the kernel's memory messages for an eighth of its bytes); the
* tail of a split that is not 16 groups long a step at a time */
int64_t g0 = g0s;
for (; g0 + 4 * kKs <= g1s; g0 += 4 * kKs) {
simd<uint32_t, 64> E = gather<uint32_t, 64, 4>((const uint32_t*)(expe0 + g0), eoff);
simd<uint32_t, 64> Mt = gather<uint32_t, 64, 4>((const uint32_t*)(meta0 + g0), moff);
_Pragma("unroll") for (int s4 = 0; s4 < 4; ++s4)
step(g0 + kKs * s4, E.template select<16, 1>(s4 * 16), Mt.template select<16, 1>(s4 * 16));
if constexpr (TL) {
/* tiled: a chunk of 16 groups is 256 bytes [step][lane], a step's 64 one block load;
* a split's steps before its first whole chunk and after its last one at a time */
const uint32_t* et = (const uint32_t*)expe0 + tile * (kg / 16) * 64;
const uint32_t* mt = (const uint32_t*)meta0 + tile * (kg / 16) * 64;
for (; g0 < g1s && (g0 & 15); g0 += kKs)
step(g0, block_load<uint32_t, 16>(et + g0 * 4), block_load<uint32_t, 16>(mt + g0 * 4));
for (; g0 + 4 * kKs <= g1s; g0 += 4 * kKs) {
simd<uint32_t, 64> E = block_load<uint32_t, 64>(et + g0 * 4);
simd<uint32_t, 64> Mt = block_load<uint32_t, 64>(mt + g0 * 4);
_Pragma("unroll") for (int s4 = 0; s4 < 4; ++s4)
step(g0 + kKs * s4, E.template select<16, 1>(s4 * 16), Mt.template select<16, 1>(s4 * 16));
}
for (; g0 < g1s; g0 += kKs)
step(g0, block_load<uint32_t, 16>(et + g0 * 4), block_load<uint32_t, 16>(mt + g0 * 4));
} else {
for (; g0 + 4 * kKs <= g1s; g0 += 4 * kKs) {
simd<uint32_t, 64> E = gather<uint32_t, 64, 4>((const uint32_t*)(expe0 + g0), eoff);
simd<uint32_t, 64> Mt = gather<uint32_t, 64, 4>((const uint32_t*)(meta0 + g0), moff);
_Pragma("unroll") for (int s4 = 0; s4 < 4; ++s4)
step(g0 + kKs * s4, E.template select<16, 1>(s4 * 16), Mt.template select<16, 1>(s4 * 16));
}
for (; g0 < g1s; g0 += kKs)
step(g0, gather<uint32_t, 16>((const uint32_t*)(expe0 + g0), eoff),
gather<uint32_t, 16>((const uint32_t*)(meta0 + g0), moff));
}
for (; g0 < g1s; g0 += kKs)
step(g0, gather<uint32_t, 16>((const uint32_t*)(expe0 + g0), eoff),
gather<uint32_t, 16>((const uint32_t*)(meta0 + g0), moff));
const simd_mask<16> ok = (lane + (uint32_t)n0) < (uint32_t)N;
if (splits == 1) {
/* 2^(mx - 127) by bits (mx = 0: the subnormal 2^-127) */