libxe2, arch/common: silu_mul for 4-bit down projections, float exp at the tie rule; head-row norms vectorized; attention SLM by gqa

- Under Geom::plain_norm a down projection that reads the bf16 plane and no codes (w4a16 /
  w4a8i8 quantise their own activation) takes `silu_mul` instead of gated_quant_fp8 (the E4M3
  pass nobody read: 17 us a call, 64 a round).
- silu_mul: float exp, libref's double chain again only near a bf16 tie (near_bf16_tie, as the
  gdn activations): op oracle 300/300 bit-identical at tolerance 0.
- rmsnorm's bf16 head rows (n = 128..512): a lane its contiguous slice by 16-byte loads (16 us ->
  a few us a q / k norm call). rad-kbench rmsnorm 240/240.
- the flash kernel's staged queries sized for gqa <= 8 (24 of 64 KiB a work-group).

Greedy decode proxy (depth 5, mtp4, draft vocab 131072): 74.3 -> 81.2 tok/s. KL against the
exact reference 0.00231 (was 0.00239), top-1 96.70%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
claudeandClaude Opus 5.5 committed 2026-11-02 02:32:05 +01:00
1 parent 2d2356ad4b
commit f26eec2633
4 files changed
+63 -7

No files matched your search

+7 -5
View File
@@ -41,7 +41,9 @@ inline esimd::simd<uint16_t, 128> bf16_of(esimd::simd<float, 128> v) SYCL_ESIMD_
* (row block, kv head, partition) -- one 8-row block alone is kv_heads work-groups of gqa threads,
* each walking the whole context. A partition's unnormalised state (m, l, O) goes to scratch,
* [row][head][P] of (m, l) in `ml` and of HD floats in `op`, and merge_parts adds them. */
template <int HD, bool SPLIT>
/* MAXG: the staged queries' local memory, a thread each (16 x 4 KiB was 64 KiB a work-group, two
* work-groups an Xe-core) */
template <int HD, bool SPLIT, int MAXG = kMaxGqa>
int launch(sycl::queue& q, const uint16_t* qb, int64_t q_rs, int64_t q_hs, const uint16_t* cb, int64_t sb,
int64_t sh, int64_t so, const char* btb, uint32_t btdt, int64_t bt_cs, const char* sub, uint32_t sudt,
int64_t rows, int64_t kv_heads, int gqa, float scale, int64_t jcap, uint16_t* ob, int64_t o_rs,
@@ -55,7 +57,7 @@ int launch(sycl::queue& q, const uint16_t* qb, int64_t q_rs, int64_t q_hs, const
q.parallel_for(sycl::nd_range<1>{(size_t)(nqb * kv_heads * NP * gqa), (size_t)gqa}, props,
[=](sycl::nd_item<1> it) SYCL_ESIMD_KERNEL {
using namespace esimd;
slm_init<kMaxGqa * kQBytes>();
slm_init<MAXG * kQBytes>();
const int t = (int)it.get_local_id(0);
const int64_t wg0 = (int64_t)it.get_group(0);
const int part = (int)(wg0 % NP);
@@ -222,7 +224,7 @@ int attn_flash_esimd(sycl::queue& q, int64_t head_dim, const uint16_t* qb, int64
if (!scratch || scratch_bytes < need || !rad_ptr_aligned(scratch, 64)) return RAD_E_UNSUPPORTED;
float* op = (float*)scratch;
float* ml = op + n * 256;
int rc = launch<256, true>(q, qb, q_rs, q_hs, cb, sb, sh, so, btb, btdt, bt_cs, sub, sudt, rows, kv_heads,
int rc = (gqa <= 8 ? launch<256, true, 8> : launch<256, true, kMaxGqa>)(q, qb, q_rs, q_hs, cb, sb, sh, so, btb, btdt, bt_cs, sub, sudt, rows, kv_heads,
(int)gqa, scale, jcap, ob, o_rs, o_hs, kMaxP, ml, op);
if (rc != RAD_OK) return rc;
return submit([&] {
@@ -252,8 +254,8 @@ int attn_flash_esimd(sycl::queue& q, int64_t head_dim, const uint16_t* qb, int64
});
});
}
return launch<256, false>(q, qb, q_rs, q_hs, cb, sb, sh, so, btb, btdt, bt_cs, sub, sudt, rows, kv_heads, (int)gqa,
scale, jcap, ob, o_rs, o_hs);
return (gqa <= 8 ? launch<256, false, 8> : launch<256, false, kMaxGqa>)(q, qb, q_rs, q_hs, cb, sb, sh, so, btb, btdt, bt_cs, sub, sudt, rows, kv_heads, (int)gqa,
scale, jcap, ob, o_rs, o_hs, 1, nullptr, nullptr);
}
} // namespace xe2