Archived
libxe2, arch/common: the 28 Oct pending set, the bf16 cast fused, the vectorized norm, a draft-vocab prefix
- gdn_kkt_solve on DPAS (~0.4 ms at 2048 tokens against 7.7), the int8 head's DPAS forms at 9-16 rows (verify past depth 7), the plain block norm (RadBuildCtx::plain_norm, set on the SYCL backend: `add` + `rmsnorm` where no reader takes the E4M3 codes) with the fast rmsnorm rows. - rmsnorm's bf16 rows up to 8192 wide: a work-item eight elements by one 16-byte load (the generic form walked 20 dependent loads a work-item): 24.7 -> 3.3 us a decode norm, ~3.5 ms a round. - w4a16: a bf16 activation narrowed to fp16 at the kernel's own load (the separate cast launch before every GEMM is gone), bit for bit the same. - RADIANCE_MTP_DRAFT_VOCAB=N: the 2-bit draft head over the vocabulary's first N ids (a prefix shortlist, GRIMOIRE's idea); the u2 layout hook takes an op N below the weight's rows. 131072: greedy acceptance identical on the decode proxy, draft head 650 -> 351 us a pass. KL against the exact-kernel reference (2002 positions): 0.002386, top-1 97.30% (was 0.002376 / 96.80%). Decode proxy (greedy, depth 5, mtp4): 72.0 -> 74.3 tok/s with the prefix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7580ec3d17
commit
726e532114
18 files changed
+472
-54
No files matched your search
@@ -46,8 +46,17 @@ inline esimd::simd<uint16_t, 16> to_bf16(esimd::simd<float, 16> v) SYCL_ESIMD_FU
|
||||
* K 6144 35 (+ the reduction) -> 32, N 1024 10 (+) -> 7.4: the weight's bytes at the card's ~560 GB/s. */
|
||||
constexpr int kMaxSplits = 32;
|
||||
|
||||
template <int RC, bool A2D>
|
||||
int launch16(sycl::queue& q, const half* a, int64_t ars, int mm, const uint32_t* ct, const uint32_t* sz, int64_t N,
|
||||
/* bf16 codes to fp16, through f32 and rounded to nearest even: sycl::half(float), bit for bit */
|
||||
template <int W>
|
||||
inline esimd::simd<half, W> bf16_to_half(esimd::simd<uint16_t, W> v) SYCL_ESIMD_FUNCTION {
|
||||
using namespace esimd;
|
||||
simd<uint32_t, W> u = simd<uint32_t, W>(v) << 16;
|
||||
return simd<half, W>(u.template bit_cast_view<float>().read());
|
||||
}
|
||||
|
||||
/* ABF: the activation is bf16, narrowed to fp16 at its load (the cast upstream dropped, fused). */
|
||||
template <int RC, bool A2D, bool ABF>
|
||||
int launch16(sycl::queue& q, const void* av, int64_t ars, int mm, const uint32_t* ct, const uint32_t* sz, int64_t N,
|
||||
int64_t K, int S, char* yb, uint32_t ydt, int64_t yrs) {
|
||||
const int64_t ntile = N / 16, G = K / 128;
|
||||
const int64_t per = G / S;
|
||||
@@ -61,6 +70,8 @@ int launch16(sycl::queue& q, const half* a, int64_t ars, int mm, const uint32_t*
|
||||
const uint32_t* cb = ct + tile * (K / 8) * 16;
|
||||
const uint32_t* sb = sz + tile * G * 16;
|
||||
const unsigned sw = (unsigned)(K * 2 - 1), sh = (unsigned)(mm - 1), spt = (unsigned)(ars * 2 - 1);
|
||||
const half* a = (const half*)av;
|
||||
const uint16_t* ab = (const uint16_t*)av;
|
||||
simd<float, RC * 16> tot = 0.0f;
|
||||
for (int64_t g = g0; g < g1; ++g) {
|
||||
simd<uint32_t, 256> cw;
|
||||
@@ -70,13 +81,23 @@ int launch16(sycl::queue& q, const half* a, int64_t ars, int mm, const uint32_t*
|
||||
simd<half, RC * 128> Ar; /* A2D: [pair of steps][step][row][16]; else [row][128] */
|
||||
if constexpr (A2D) {
|
||||
#pragma unroll
|
||||
for (int j2 = 0; j2 < 4; ++j2)
|
||||
Ar.template select<RC * 32, 1>(j2 * RC * 32) =
|
||||
load_2d<half, 16, RC, 2, false>(a, sw, sh, spt, (int)(g * 128 + j2 * 32), 0);
|
||||
for (int j2 = 0; j2 < 4; ++j2) {
|
||||
if constexpr (ABF)
|
||||
Ar.template select<RC * 32, 1>(j2 * RC * 32) = bf16_to_half<RC * 32>(
|
||||
load_2d<uint16_t, 16, RC, 2, false>(ab, sw, sh, spt, (int)(g * 128 + j2 * 32), 0));
|
||||
else
|
||||
Ar.template select<RC * 32, 1>(j2 * RC * 32) =
|
||||
load_2d<half, 16, RC, 2, false>(a, sw, sh, spt, (int)(g * 128 + j2 * 32), 0);
|
||||
}
|
||||
} else {
|
||||
#pragma unroll
|
||||
for (int m = 0; m < RC; ++m) {
|
||||
if (m < mm) Ar.template select<128, 1>(m * 128) = block_load<half, 128>(a + m * ars + g * 128);
|
||||
if (m < mm) {
|
||||
if constexpr (ABF)
|
||||
Ar.template select<128, 1>(m * 128) = bf16_to_half<128>(block_load<uint16_t, 128>(ab + m * ars + g * 128));
|
||||
else
|
||||
Ar.template select<128, 1>(m * 128) = block_load<half, 128>(a + m * ars + g * 128);
|
||||
}
|
||||
else Ar.template select<128, 1>(m * 128) = 0;
|
||||
}
|
||||
}
|
||||
@@ -244,15 +265,19 @@ int launch_i8(sycl::queue& q, const uint8_t* ap, const int32_t* asumt, const flo
|
||||
|
||||
} // namespace
|
||||
|
||||
int w4a16_esimd(sycl::queue& q, int rc, const half* a, int64_t ars, int mm, const uint32_t* ct, const uint32_t* sz,
|
||||
int64_t N, int64_t K, int splits, char* yb, uint32_t ydt, int64_t yrs) {
|
||||
int w4a16_esimd(sycl::queue& q, int rc, const void* a, bool a_bf16, int64_t ars, int mm, const uint32_t* ct,
|
||||
const uint32_t* sz, int64_t N, int64_t K, int splits, char* yb, uint32_t ydt, int64_t yrs) {
|
||||
if (splits < 1 || splits > kMaxSplits || (K / 128) % splits) return RAD_E_UNSUPPORTED;
|
||||
switch (rc) {
|
||||
case 1: return launch16<1, false>(q, a, ars, mm, ct, sz, N, K, splits, yb, ydt, yrs);
|
||||
case 2: return launch16<2, false>(q, a, ars, mm, ct, sz, N, K, splits, yb, ydt, yrs);
|
||||
case 4: return launch16<4, false>(q, a, ars, mm, ct, sz, N, K, splits, yb, ydt, yrs);
|
||||
default: return launch16<8, true>(q, a, ars, mm, ct, sz, N, K, splits, yb, ydt, yrs);
|
||||
#define XE2_W4_RC(ABF) \
|
||||
switch (rc) { \
|
||||
case 1: return launch16<1, false, ABF>(q, a, ars, mm, ct, sz, N, K, splits, yb, ydt, yrs); \
|
||||
case 2: return launch16<2, false, ABF>(q, a, ars, mm, ct, sz, N, K, splits, yb, ydt, yrs); \
|
||||
case 4: return launch16<4, false, ABF>(q, a, ars, mm, ct, sz, N, K, splits, yb, ydt, yrs); \
|
||||
default: return launch16<8, true, ABF>(q, a, ars, mm, ct, sz, N, K, splits, yb, ydt, yrs); \
|
||||
}
|
||||
if (a_bf16) XE2_W4_RC(true)
|
||||
XE2_W4_RC(false)
|
||||
#undef XE2_W4_RC
|
||||
}
|
||||
|
||||
int w4a8i8_esimd(sycl::queue& q, const uint8_t* ap, const int32_t* asumt, const float* sat, int64_t mpad,
|
||||
|
||||
Reference in new issue
Block a user