libxe2: the DFlash2 path fast -- exact draft head, DPAS verify GEMV, parallel rerank

- gemm_nt_q over the zero-point grids at M <= 16 (the drafter's 2-bit vocabulary head, N=248320):
  a sub-group a column, the group sums exact integers in f32, libref's group terms added in group
  order through lane broadcasts -- bit-identical to the exact kernel on the live head (checked in
  the engine: 0 differing bytes of 3.5 MB, every round). 252 ms -> well under 1 ms a call.
- m2xfp4 at 2 <= M <= 16 (the verify width) on XMX: a lane a column decodes its codes a 64-byte line
  at a time into its sub-group's VNNI slice of local memory (subnormal-bit fp16 pairs times
  (1 + k/4) * 2^(e - e_max + 14)), eight K16 DPAS a step against the permuted fp16 activation,
  K split for narrow N, partials added in order. On the vector ALUs M = 8 cost five times M = 1;
  gate_up at M = 8 1159 -> ~490 us. rad-kbench on the 27B: 50/50, rel_l2 ~8.5e-4 (tol 4e-2).
- logit_rerank: a work-group a row, a sub-group a candidate along K, libref's double sum as a float
  pair (two-product, two-sum, a fixed lane tree), libref's selection; 136 ms -> negligible a call.
- the gated delta net's gate, beta and decay (libref's double exp / log1p) once a (token, head)
  in a prepass instead of once a column block; still bit-identical (10/10 at rel_l2 0).
- profile_decode.sh: KEEP=DIR keeps the per-geometry tables.

27B on the B65, greedy: 12.1 tok/s plain, 13.2 tok/s with the drafter (device time a token
217 -> 76 ms under speculation). The drafter's text now departs from plain decoding at a
near-tie (byte 246 of 256 tokens): the verify forward runs the M = 8 DPAS path and plain decoding
the M = 1 GEMV, whose roundings differ (~1e-3); with the exact kernels the two were identical.

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-24 04:37:16 +02:00
1 parent 15944be7e3
commit bce0f4db70
7 files changed
+399 -7

No files matched your search

+10
View File
@@ -24,6 +24,7 @@ const RadConstraint cFp8Dtype[] = { RAD_CIN("dtype", "fp8a8 fp8a8f32 fp8a16") };
const RadConstraint cFp8Gated[] = { RAD_CIN("dtype", "fp8a8 fp8a8f32 fp8a16"), RAD_CLE("N", 57344) };
/* The zero-point grids over quant_act_i8's activation (xe2_gemm_zp.cpp). */
const RadConstraint cZpI8Dtype[] = { RAD_CIN("dtype", "w2a8 w4a8_asym") };
const RadConstraint cZpGemv[] = { RAD_CIN("dtype", "w2a8 w4a8_asym"), RAD_CLE("M", 16) };
/* The M2XFP4 grid over givens_dense_quant's fp8 activation (xe2_gemm_m2.cpp). */
const RadConstraint cM2Dtype[] = { RAD_CIN("dtype", "m2xfp4") };
/* The fp8 head's decode band. */
@@ -260,6 +261,15 @@ const RadKernelInfo kKernels[] = {
"sequence",
.shape = "any steps, top_k and rank", .dtypes = "integer candidates, float scores and factors",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::dflash_select },
{ .name = "xe2_gemm_nt_q_zp_gemv", .op = "gemm_nt_q", .family = "gemm",
.computes = "the zero-point grids at M <= 16: a sub-group a column, exact integer group sums, "
"libref's group terms added in order through lane broadcasts -- libref's result",
.shape = "M <= 16; group a multiple of 16 up to 512, at most 64 groups",
.dtypes = "w2a8, w4a8_asym: u2/u4 codes, f16 scale and unsigned zero per (row, group), i8 "
"activation in step order with row scale and group sums",
.domain = RAD_DOMAIN_DEVICE, .priority = 10, .constraints = cZpGemv, .n_constraints = 2,
.launch = xe2::gemm_nt_q_zp_gemv, .layout = xe2::gemm_zp_layout,
.relayout = xe2::gemm_zp_relayout, .unrelayout = xe2::gemm_zp_unrelayout },
{ .name = "xe2_gemm_nt_q_zp_ref", .op = "gemm_nt_q", .family = "gemm",
.computes = "Y = A B^T over an unsigned zero-point grid against quant_act_i8's activation, "
"libref's gemm_zp per output; the correctness-first form",