Archived
Merge main into laya-arch-plugin
This commit is contained in:
commit
ec243c2a7d
189 files changed
+11212
-7060
No files matched your search
+207
-4
@@ -123,6 +123,18 @@ static const RadOperandSpec oAttnPaged[] = {
|
||||
{ "cu_seqlens", RAD_OPD_IN, 1 }, /* absent = one q_len for the whole batch */
|
||||
{ "out", RAD_OPD_OUT, 0 },
|
||||
};
|
||||
/* attn_paged_qrow with a tree verify's parents (RadBatch::spec_parent, rad_drafter_tree). */
|
||||
static const RadOperandSpec oAttnPagedTree[] = {
|
||||
{ "q", RAD_OPD_IN, 0 },
|
||||
{ "kv_cache", RAD_OPD_IN, 0 },
|
||||
{ "block_table", RAD_OPD_IN, 0 },
|
||||
{ "seqused", RAD_OPD_IN, 0 },
|
||||
{ "k_descale", RAD_OPD_IN, 1 },
|
||||
{ "v_descale", RAD_OPD_IN, 1 },
|
||||
{ "cu_seqlens", RAD_OPD_IN, 1 },
|
||||
{ "out", RAD_OPD_OUT, 0 },
|
||||
{ "spec_parent", RAD_OPD_IN, 0 },
|
||||
};
|
||||
|
||||
/* attn_paged with gate_quant_fp8 folded into its merge: attn_paged's parameters plus the two of
|
||||
* gate_quant_fp8's that are not implied (its `n` is `head_dim`, its rows attn_paged's (token,
|
||||
@@ -700,6 +712,28 @@ static const RadOperandSpec oDflashSelect[] = {
|
||||
{ "succ", RAD_OPD_WEIGHT, 0 },
|
||||
{ "tokens", RAD_OPD_OUT, 0 },
|
||||
};
|
||||
/* dflash_tree: dflash_select's, plus the node count, the softmax temperature and the parents. */
|
||||
static const RadParamSpec pDflashTree[] = {
|
||||
{ "M", RAD_P_INT, RAD_REQUIRED },
|
||||
{ "steps", RAD_P_INT, RAD_REQUIRED },
|
||||
{ "top_k", RAD_P_INT, RAD_REQUIRED },
|
||||
{ "rank", RAD_P_INT, RAD_REQUIRED },
|
||||
{ "n_vocab", RAD_P_INT, RAD_REQUIRED },
|
||||
{ "anchor_stride", RAD_P_INT, RAD_OPTIONAL },
|
||||
{ "nodes", RAD_P_INT, RAD_REQUIRED },
|
||||
{ "temp", RAD_P_F64, RAD_OPTIONAL },
|
||||
{ "dtype", RAD_P_STR, RAD_REQUIRED },
|
||||
};
|
||||
static const RadOperandSpec oDflashTree[] = {
|
||||
{ "cand", RAD_OPD_IN, 0 },
|
||||
{ "unary", RAD_OPD_IN, 0 },
|
||||
{ "hp", RAD_OPD_IN, 1 },
|
||||
{ "anchor", RAD_OPD_IN, 0 },
|
||||
{ "pred", RAD_OPD_WEIGHT, 0 },
|
||||
{ "succ", RAD_OPD_WEIGHT, 0 },
|
||||
{ "tokens", RAD_OPD_OUT, 0 },
|
||||
{ "parents", RAD_OPD_OUT, 0 },
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------ collectives */
|
||||
static const RadParamSpec pAllReduce[] = {
|
||||
@@ -2894,6 +2928,11 @@ static const RadOpSchema kSchemas[] = {
|
||||
SCHEMA("rmsnorm", pRmsNorm, oRmsNorm,
|
||||
"y = x * rsqrt(mean(x^2) + eps) * (w + wadd). `wadd` is GemmaRMSNorm's `1 +`, added in "
|
||||
"f32 after the load because forming it in bf16 first costs 0.3% per channel."),
|
||||
SCHEMA("rmsnorm_rows", pRmsNorm, oRmsNorm,
|
||||
"the same norm, and its launch is the same except at n <= 256 with 1024 or more rows, "
|
||||
"where a wave a row computes the row and sums its squares in rmsnorm_kernel's wave "
|
||||
"order (byte-identical). An op name of its own so a caller that has not asked for it "
|
||||
"keeps the per-row workgroups it always had."),
|
||||
SCHEMA("rmsnorm_p", pLayernorm, oUnary,
|
||||
"y = x * rsqrt(mean(x^2) + eps); an rmsnorm with NO gain tensor at all. Gemma's "
|
||||
"attention normalises the value with a bare RMS (a weightless ggml_rms_norm) and the "
|
||||
@@ -3016,6 +3055,11 @@ static const RadOpSchema kSchemas[] = {
|
||||
"that follow are untouched. The multi-component modes (`mrope`, `imrope`, `axial`) "
|
||||
"take [C, M] component-major positions and `sections`; with [M] positions every "
|
||||
"component is that one, so mrope and imrope over a text batch are neox exactly."),
|
||||
SCHEMA("rope_rows", pRope, oRope,
|
||||
"the same rotation, and its launch is the same except with 64 or more rows and 4 or "
|
||||
"more heads, where a thread owns one (token, pair) angle and turns that pair in every "
|
||||
"head (byte-identical). An op name of its own so a caller that has not asked for it "
|
||||
"keeps a thread a (head, pair), which spreads a decode's single token over the card."),
|
||||
SCHEMA("layernorm", pLayernorm, oLayernorm,
|
||||
"y = (x - mean) * rsqrt(var + eps) * w + b, biased variance, two passes. `b` optional."),
|
||||
SCHEMA("grid_embed", pGridEmbed, oGridEmbed,
|
||||
@@ -3144,6 +3188,11 @@ static const RadOpSchema kSchemas[] = {
|
||||
"attn_paged, parameter for parameter and value for value, with q read at its own row "
|
||||
"pitch: a column slice of a wider row -- the q part of a fused [q|k|v] projection -- read "
|
||||
"where it lies rather than lifted into a dense block first."),
|
||||
SCHEMA("attn_paged_qrow_tree", pAttnPaged, oAttnPagedTree,
|
||||
"attn_paged_qrow over a tree verify (rad_drafter_tree): spec_parent is -2 for an "
|
||||
"ordinary causal row, else the row's parent's index within its sequence's rows (-1 for "
|
||||
"the block's first row). Inside the block such a row sees itself and its ancestors "
|
||||
"only, and its window is measured from the block's first position plus its depth."),
|
||||
SCHEMA("attn_paged_gate_quant", pAttnPagedGq, oAttnPagedGq,
|
||||
"attn_paged followed by gate_quant_fp8 over its output, in the split-KV merge: each "
|
||||
"merged (token, head) row is gated, rounded, written to `out` and quantised to E4M3 "
|
||||
@@ -3250,6 +3299,12 @@ static const RadOpSchema kSchemas[] = {
|
||||
"positions, and the greedy walk that turns a block of independent top-k sets into one "
|
||||
"path. Only the K edges leaving the previous pick are scored, because the walk is "
|
||||
"serial and the other K-1 rows of the score matrix are never read."),
|
||||
SCHEMA("dflash_tree", pDflashTree, oDflashTree,
|
||||
"dflash_select's lattice and edge scores grown best-first into a tree of `nodes` nodes: "
|
||||
"a taken node's children are the valid candidates at the next position, each with log "
|
||||
"probability parent + log_softmax(score / temp) over them; each round takes the largest "
|
||||
"untaken child (ties to the first pushed). tokens and parents list the taken nodes in "
|
||||
"order, a parent as its node index, 0 for the anchor."),
|
||||
SCHEMA("all_reduce", pAllReduce, oAllReduce,
|
||||
"sum over the tensor-parallel group. `exact` separates the exact sum from the "
|
||||
"quantised wire and a caller that does not declare it gets no kernel. At 4 and 8 ranks "
|
||||
@@ -3266,6 +3321,12 @@ static const RadOpSchema kSchemas[] = {
|
||||
"C[M,N] = A[M,K] @ dequant(Bq)[N,K]^T. `dtype` names the operand COMBINATION, so one "
|
||||
"op covers w4a16 through mxfp4a8 and an architecture plugin that changes quant changes "
|
||||
"one string."),
|
||||
SCHEMA("gemm_nt_q_short", pGemmNtQ, oGemmNtQ,
|
||||
"the narrow fp8a8 row of `gemm_nt_q` with the short-prompt split rule: at N <= 512, K "
|
||||
"<= 5120 and 41..64 rows it runs unsplit, where the split's per-slice floors dominate. "
|
||||
"The split COUNT changes, so a row here is not bit-identical to the same row split; "
|
||||
"both are exact. An op name of its own so every other caller keeps the split and "
|
||||
"its bits."),
|
||||
SCHEMA("gemm_nt_q_bias", pGemmNtQBias, oGemmNtQBias,
|
||||
"gemm_nt_q with a per-column bias added to the f32 product before its one rounding."),
|
||||
SCHEMA("dequant_w4", pDequantW4, oDequantW4,
|
||||
@@ -3418,6 +3479,10 @@ static const RadOpSchema kSchemas[] = {
|
||||
"columns) and optionally the bf16 product, and no [M, 2n] tensor is ever written. "
|
||||
"Byte-identical to the two ops it replaces, which is what makes it substitutable "
|
||||
"rather than a second numerical path."),
|
||||
SCHEMA("gemm_nt_q_gated_wide", pGemmNtQGated, oGemmNtQGated,
|
||||
"gemm_nt_q_gated at every M: the narrow tile to 64 rows and the gated prefill tile past "
|
||||
"them, whose accumulators are the unfused prefill GEMM's. An op name of its own so the "
|
||||
"narrow row keeps its M <= 64 band, its kernel and every other caller's path."),
|
||||
SCHEMA("gemm_nt_q_gated_mx", pGemmNtQGated, oGemmNtQGatedMx,
|
||||
"gemm_nt_q_gated over an OCP-MXFP4 [2n, K] gate_up weight: gemm_nt_q at dtype mxfp4a8 "
|
||||
"(`b_ref` the per-row reference exponent) with gated_quant_fp8's pass folded into the "
|
||||
@@ -3920,6 +3985,15 @@ static const RadConstraint cAttnDecodeH256Gqa2Fp8[] = {
|
||||
C_GE("window", 0), C_EQ("head_dim", 256), C_EQ("gqa", 2), C_EQ("block_size", 16),
|
||||
C_GE("causal", 0), C_LE("q_len", 32), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "fp8_e4m3"),
|
||||
};
|
||||
/* attn_paged_qrow_tree on the same kernel: causal only (a tree has no two-sided reading). */
|
||||
static const RadConstraint cAttnTreeDecodeH256Gqa2Fp8[] = {
|
||||
C_GE("window", 0), C_EQ("head_dim", 256), C_EQ("gqa", 2), C_EQ("block_size", 16),
|
||||
C_EQ("causal", 1), C_LE("q_len", 32), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "fp8_e4m3"),
|
||||
};
|
||||
static const RadConstraint cAttnTreeDecodeH256Gqa2Bf16[] = {
|
||||
C_GE("window", 0), C_EQ("head_dim", 256), C_EQ("gqa", 2), C_EQ("block_size", 16),
|
||||
C_EQ("causal", 1), C_LE("q_len", 32), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "bf16"),
|
||||
};
|
||||
static const RadConstraint cAttnDecodeH256Gqa2Bf16[] = {
|
||||
C_GE("window", 0), C_EQ("head_dim", 256), C_EQ("gqa", 2), C_EQ("block_size", 16),
|
||||
C_GE("causal", 0), C_LE("q_len", 32), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "bf16"),
|
||||
@@ -4455,6 +4529,12 @@ static const RadConstraint cDflashSelect[] = {
|
||||
C_GE("steps", 1), C_GE("top_k", 1), C_LE("top_k", 32),
|
||||
C_DIV("rank", 32), C_LE("rank", 512), C_IN("dtype", "bf16"),
|
||||
};
|
||||
/* dflash_tree's frontier (nodes x top_k children) and its node table live in LDS. */
|
||||
static const RadConstraint cDflashTree[] = {
|
||||
C_GE("steps", 1), C_LE("steps", 63), C_GE("top_k", 1), C_LE("top_k", 32),
|
||||
C_DIV("rank", 32), C_LE("rank", 512), C_GE("nodes", 1), C_LE("nodes", 63),
|
||||
C_IN("dtype", "bf16"),
|
||||
};
|
||||
/* The sandwich-norm joins hold 24 elements a thread over a 256-thread block (n <= 6144), and the
|
||||
* route form quantises in whole 128-column groups. pair_argmax takes any row; expert_scale's top_k
|
||||
* is the router's, at most 64. */
|
||||
@@ -4913,6 +4993,14 @@ static const RadConstraint cGemmNtQGatedFp8[] = {
|
||||
C_LE("M", 64), C_DIV("K", 256), C_DIV("N", 256), C_GE("N", 2048),
|
||||
C_EQ("group", R4D_FP8_BLOCK), C_IN("dtype", "fp8a8"), C_IN("act", "silu"),
|
||||
};
|
||||
/* `gemm_nt_q_gated_wide`: the same fold at any M. Past the narrow tile's 64 rows it runs the gated
|
||||
* prefill tile, whose accumulators are the unfused prefill GEMM's, so its bytes are the pair's. An
|
||||
* op name of its own, and one a model declares when it wants the whole prompt in the fold: the
|
||||
* narrow row above keeps its ceiling, its kernel and every other caller's path. */
|
||||
static const RadConstraint cGemmNtQGatedFp8Wide[] = {
|
||||
C_DIV("K", 256), C_DIV("N", 256), C_GE("N", 2048),
|
||||
C_EQ("group", R4D_FP8_BLOCK), C_IN("dtype", "fp8a8"), C_IN("act", "silu"),
|
||||
};
|
||||
/* r4d_gemm_mxfp4a8_gated_gemv: the gemv row's WMMA form (K a multiple of 128, M <= 8) with a block
|
||||
* per 16-column tile pair of the gated output. N/2 is a multiple of 128, so each 128-column
|
||||
* group's eight blocks meet at its last arriver, which quantises the group. */
|
||||
@@ -4933,6 +5021,7 @@ static const RadConstraint cGemmNtQGatedMxWide[] = {
|
||||
static const RadConstraint cGateQuantFp8[] = {
|
||||
C_DIV("n", 4), C_EQ("group", R4D_FP8_BLOCK), C_IN("dtype", "bf16"),
|
||||
};
|
||||
/* `act` none is the plain product (`mul`), for a producer that is not a gate activation. */
|
||||
/* libr4d's cSampleChain. The kernel has no geometry constraint (the radix passes run over a
|
||||
* float's 256 byte buckets), but a row with no predicate would match a query that named nothing. */
|
||||
static const RadConstraint cSampleChain[] = {
|
||||
@@ -5819,6 +5908,18 @@ static const RadKernelInfo kKernels[] = {
|
||||
nullptr, nullptr, r4d_rad_rmsnorm, nullptr, nullptr, nullptr,
|
||||
r4d_shape_rmsnorm },
|
||||
|
||||
/* The same norm, whose launch takes rows of 256 or fewer columns a wave a row once there are
|
||||
* enough of them to fill the part; the chunk sums are rmsnorm_kernel's in wave order. */
|
||||
{ "rmsnorm_rows_bf16", "rmsnorm_rows", "norm",
|
||||
"root-mean-square norm with a gain, two passes over the row, a wave a short row at prefill row "
|
||||
"counts",
|
||||
"any n; the short-row form needs n <= 256 and 1024 or more rows; byte-identical to rmsnorm",
|
||||
"bf16 y, x bf16 or (with a gain) f32, bf16 or f32 gain, fp32 reduction",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
|
||||
ROW(cBf16Row), NOTUNE,
|
||||
nullptr, nullptr, r4d_rad_rmsnorm_rows, nullptr, nullptr, nullptr,
|
||||
r4d_shape_rmsnorm },
|
||||
|
||||
{ "rmsnorm_p_bf16", "rmsnorm_p", "norm",
|
||||
"weightless root-mean-square norm (no gain), two passes over the row",
|
||||
"any n; the sum of squares accumulates in f32 and only the store narrows",
|
||||
@@ -6077,6 +6178,17 @@ static const RadKernelInfo kKernels[] = {
|
||||
nullptr, nullptr, r4d_rad_rope, nullptr, nullptr, nullptr,
|
||||
r4d_shape_rope },
|
||||
|
||||
/* The same rotation with one angle a (token, pair) and every head turned with it, at prefill row
|
||||
* counts: the angle does not depend on the head, so a thread owns one pair of one token. */
|
||||
{ "rope_rows_bf16", "rope_rows", "attn",
|
||||
"rotary embedding in place, one thread a (token, pair) angle, every head turned with it",
|
||||
"the rope row's geometry; the per-angle form needs 64 or more rows and 4 or more heads",
|
||||
"bf16 qkv, i32 positions, fp32 angles through the accurate sincosf; byte-identical to rope",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
|
||||
ROW(cRopeRow), NOTUNE,
|
||||
nullptr, nullptr, r4d_rad_rope_rows, nullptr, nullptr, nullptr,
|
||||
r4d_shape_rope },
|
||||
|
||||
{ "kv_store_bf16", "kv_store", "attn",
|
||||
"scatter k and v into the paged cache, one workgroup a token",
|
||||
"cache exactly [n_blocks, kv_heads, block_size, 2*head_dim]; a negative or out-of-range slot "
|
||||
@@ -6653,6 +6765,28 @@ static const RadKernelInfo kKernels[] = {
|
||||
r4d_rad_attn_qrow_decode_h256_gqa2_scratch,
|
||||
nullptr, nullptr, nullptr },
|
||||
|
||||
/* The same under attn_paged_qrow_tree: a tree verify's mask (O_TREE instances), causal only. */
|
||||
{ "attn_qrow_tree_decode_h256_gqa2_fp8kv", "attn_paged_qrow_tree", "attn",
|
||||
"paged attention over a tree verify, q at its own row pitch, sliding window, split-KV",
|
||||
"head_dim 256, 2 queries per kv head, paged block 16, q_len*gqa <= 64, causal",
|
||||
"bf16 query (any row pitch, a multiple of 4), fp8-e4m3 kv cache with per-(seq,head) descales, "
|
||||
"i32 parents, bf16 out, f16 partials",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ATTN_DECODE,
|
||||
ROW(cAttnTreeDecodeH256Gqa2Fp8), ROW(tAttnSplit), nullptr,
|
||||
nullptr, nullptr, r4d_rad_attn_qrow_tree_decode_h256_gqa2_fp8,
|
||||
r4d_rad_attn_qrow_decode_h256_gqa2_scratch,
|
||||
nullptr, nullptr, nullptr },
|
||||
|
||||
{ "attn_qrow_tree_decode_h256_gqa2_bf16kv", "attn_paged_qrow_tree", "attn",
|
||||
"paged attention over a tree verify, q at its own row pitch, sliding window, split-KV",
|
||||
"head_dim 256, 2 queries per kv head, paged block 16, q_len*gqa <= 64, causal",
|
||||
"bf16 query (any row pitch, a multiple of 4), bf16 kv cache, i32 parents, bf16 out, f16 partials",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ATTN_DECODE,
|
||||
ROW(cAttnTreeDecodeH256Gqa2Bf16), ROW(tAttnSplit), nullptr,
|
||||
nullptr, nullptr, r4d_rad_attn_qrow_tree_decode_h256_gqa2_bf16,
|
||||
r4d_rad_attn_qrow_decode_h256_gqa2_scratch,
|
||||
nullptr, nullptr, nullptr },
|
||||
|
||||
/* Head_dim 128 at gqa 8 under attn_paged_qrow (cAttnQrowH128G8Fp8 says why). */
|
||||
{ "attn_qrow_h128_gqa8_fp8kv", "attn_paged_qrow", "attn",
|
||||
"paged attention, any window, causal or not, split-KV (draft block); q at any row pitch",
|
||||
@@ -6841,6 +6975,27 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
|
||||
#undef R4D_WIN_PAIR
|
||||
#undef R4D_WIN_ROW
|
||||
|
||||
/* ...and under attn_paged_qrow_tree, the scalar kernel with a tree verify's mask (the launch
|
||||
* refuses a non-causal one and never takes the WMMA kernel). */
|
||||
#define R4D_WIN_TREE_ROW(HD, G, KVN, KVS, C, KVDOC) \
|
||||
{ "attn_qrow_tree_h" #HD "_gqa" #G "_" #KVN, "attn_paged_qrow_tree", "attn", \
|
||||
"paged attention over a tree verify, q at its own row pitch, any window, causal", \
|
||||
"head_dim " #HD ", " #G " queries per kv head, paged block 16, any q_len, varlen", \
|
||||
"bf16 query (any row pitch), " KVDOC " kv cache, i32 parents, bf16 out, f32 partials", \
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, \
|
||||
ROW(C), NOTUNE, \
|
||||
nullptr, nullptr, r4d_rad_attn_window_tree_h##HD##_gqa##G##_##KVS, \
|
||||
r4d_rad_attn_window_h##HD##_scratch, \
|
||||
nullptr, nullptr, nullptr },
|
||||
#define R4D_WIN_TREE_PAIR(HD, GQ) \
|
||||
R4D_WIN_TREE_ROW(HD, GQ, bf16kv, bf16, cWinH##HD##G##GQ##Bf16, "bf16") \
|
||||
R4D_WIN_TREE_ROW(HD, GQ, fp8kv, fp8, cWinH##HD##G##GQ##Fp8, "fp8-e4m3 (per-(seq,head) descales)")
|
||||
R4D_WIN_TREE_PAIR(256, 1) R4D_WIN_TREE_PAIR(256, 2) R4D_WIN_TREE_PAIR(256, 4)
|
||||
R4D_WIN_TREE_PAIR(256, 8) R4D_WIN_TREE_PAIR(512, 1) R4D_WIN_TREE_PAIR(512, 2)
|
||||
R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8)
|
||||
#undef R4D_WIN_TREE_PAIR
|
||||
#undef R4D_WIN_TREE_ROW
|
||||
|
||||
{ "attn_prefill_h256_gqa12_fp8kv", "attn_paged", "attn",
|
||||
"paged causal attention, query-tiled (prefill / chunked prefill)",
|
||||
"head_dim 256, 12 queries per kv head, paged block 4, varlen",
|
||||
@@ -7800,6 +7955,22 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
|
||||
r4d_rad_layout_fp8_block, r4d_rad_relayout_fp8_block,
|
||||
r4d_shape_gemm_nt_q, r4d_rad_unrelayout_fp8_block },
|
||||
|
||||
/* The same narrow row with the short-prompt split rule (narrow_ksplit's `short_unsplit`), whose
|
||||
* declaration the model owns: the scratch hook matches, so the split the launch takes is the one
|
||||
* the arena was sized for. */
|
||||
{ "gemm_fp8a8_nt_m16_short", "gemm_nt_q_short", "gemm",
|
||||
"gemm_fp8a8_nt_m16 choosing its split from the short-prompt rule: at N <= 512, K <= 5120 and "
|
||||
"41..64 rows the split's per-slice floors dominate and the row runs unsplit",
|
||||
"the narrow row's: M <= 64; K a multiple of 128; N a multiple of 16",
|
||||
"E4M3 A with an f32 scale per (row, 128 K), E4M3 W with a bf16 scale per 128x128 tile, bf16 C. "
|
||||
"Unsplit sums its K blocks in one order and split its partial planes in another, so a row here "
|
||||
"differs from the split result in its last bits; both are exact",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_GEMM_FP8_M16,
|
||||
ROW(cGemmNtFp8A8M16), NOTUNE,
|
||||
nullptr, nullptr, r4d_rad_gemm_fp8a8_m16_short, r4d_rad_gemm_fp8a8_m16_short_scratch,
|
||||
r4d_rad_layout_fp8_block, r4d_rad_relayout_fp8_block,
|
||||
r4d_shape_gemm_nt_q, r4d_rad_unrelayout_fp8_block },
|
||||
|
||||
{ "gemm_fp8a8_gated_nt_m16", "gemm_nt_q_gated", "gemm",
|
||||
"the narrow fp8 GEMM with the SwiGLU and the fp8 quantiser folded into its epilogue: the block's "
|
||||
"waves split in half over the gate rows and the up rows, so a block emits one whole 128-column "
|
||||
@@ -7819,6 +7990,23 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
|
||||
/* The byte-identity claim above, as a chain of two rows of this plugin (r4d_fuse.cpp). */
|
||||
r4d_fuse_gemm_nt_q_gated },
|
||||
|
||||
/* The same fold at every M: the narrow tile to 64 rows, past them the gated prefill tile (128
|
||||
* gate and 128 up rows against 64 activation rows a block), whose accumulators are the unfused
|
||||
* prefill GEMM's. An op name of its own, which the model declares when it wants the whole prompt
|
||||
* in the fold. */
|
||||
{ "gemm_fp8a8_gated_nt_wide", "gemm_nt_q_gated_wide", "gemm",
|
||||
"gemm_fp8a8_gated_nt_m16 at every M",
|
||||
"any M; K a multiple of 256 and N of 256 for the narrow row's reasons; act silu only; the "
|
||||
"prefill tile past 64 rows needs q_ld and y_ld multiples of 8 and a 16-byte-aligned y",
|
||||
"E4M3 A with an f32 scale per (row, 128 K), E4M3 W with a bf16 scale per 128x128 tile, and the "
|
||||
"QUANTISER's outputs; byte-identical to gemm_nt_q followed by gated_quant_fp8 at every M",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
|
||||
ROW(cGemmNtQGatedFp8Wide), NOTUNE,
|
||||
nullptr, nullptr, r4d_rad_gemm_fp8a8_gated_wide, nullptr,
|
||||
r4d_rad_layout_fp8_block, r4d_rad_relayout_fp8_block,
|
||||
r4d_shape_gemm_nt_q_gated, r4d_rad_unrelayout_fp8_block,
|
||||
r4d_fuse_gemm_nt_q_gated },
|
||||
|
||||
{ "gemm_fp8a8_tiled", "gemm_nt_q", "gemm",
|
||||
"the same GEMM for prefill row counts: 128x128 tile, eight waves of 2 weight x 4 activation "
|
||||
"tiles, the weight read straight into registers and the activation staged through LDS, one K "
|
||||
@@ -8570,16 +8758,16 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
|
||||
{ "gate_quant_fp8", "gate_quant_fp8", "quant",
|
||||
"an elementwise gated product and the fp8 activation quantiser in one pass, with the gate in "
|
||||
"its own operand: a gated attention's gate is a column slice of the [q|gate] projection and "
|
||||
"cannot be packed beside the attention output it scales",
|
||||
"cannot be packed beside the attention output it scales; `act` none is `mul` + `quant_act_fp8`",
|
||||
"n a multiple of 4; gate and x are both [M][n] and may have different pitches; no reduction "
|
||||
"across the row, so no barrier; group 128; strides in elements",
|
||||
"across the row, so no barrier; group 128; strides in elements; `act` silu, sigmoid or none",
|
||||
"bf16 in, E4M3 out with an f32 scale per (row, 128 columns) and an optional bf16 out; the codes "
|
||||
"are taken over the BF16-ROUNDED product",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
|
||||
ROW(cGateQuantFp8), NOTUNE,
|
||||
nullptr, nullptr, r4d_rad_gate_quant_fp8, nullptr, nullptr, nullptr,
|
||||
r4d_shape_gate_quant_fp8, nullptr,
|
||||
/* `sigmoid` + `mul` + `quant_act_fp8`; the silu arm is declined (r4d_fuse.cpp). */
|
||||
/* `sigmoid` + `mul` + `quant_act_fp8`, and `mul` + `quant_act_fp8` for act none (r4d_fuse.cpp). */
|
||||
r4d_fuse_gate_quant_fp8 },
|
||||
|
||||
/* ---------------------------------------------------------------------------------- sampling
|
||||
@@ -9038,6 +9226,16 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
|
||||
nullptr, nullptr, r4d_rad_dflash_select, nullptr, nullptr, nullptr,
|
||||
r4d_shape_dflash_select },
|
||||
|
||||
{ "dflash_tree_bf16", "dflash_tree", "dflash",
|
||||
"DFlash2's candidate lattice grown best-first into a tree (rad_drafter_tree): the selector's "
|
||||
"edge scores for each taken node's children, one workgroup a sequence",
|
||||
"top_k <= 32, rank a multiple of 32 and <= 512, steps and nodes <= 63: the frontier and the "
|
||||
"node table are LDS extents",
|
||||
"i32 candidate ids, f32 unary logits, bf16 hp and both codebooks, i32 tokens and parents out",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
|
||||
ROW(cDflashTree), NOTUNE,
|
||||
nullptr, nullptr, r4d_rad_dflash_tree, nullptr, nullptr, nullptr, nullptr },
|
||||
|
||||
/* pair_argmax, the sandwich-norm joins and expert_scale. The joins and expert_scale have no
|
||||
* opd_shape: libref has no row for them, and tests/r4d_emu holds their source to the replaced chain
|
||||
* bit for bit on the host. pair_argmax is described as libref describes it. */
|
||||
@@ -10057,6 +10255,8 @@ extern "C" int rad_kernel_chain(int i) {
|
||||
* plain, and the backend chains only the kernels named r4dchain* */
|
||||
"attn_decode_h256_gqa2_fp8kv", "attn_decode_h256_gqa2_bf16kv",
|
||||
"attn_qrow_decode_h256_gqa2_fp8kv", "attn_qrow_decode_h256_gqa2_bf16kv",
|
||||
/* ...and their tree verify forms (O_TREE instances, the same launch) */
|
||||
"attn_qrow_tree_decode_h256_gqa2_fp8kv", "attn_qrow_tree_decode_h256_gqa2_bf16kv",
|
||||
/* the fused junction: its tail form (the two-shot with the junction after it) only */
|
||||
"ar_rmsnorm_quant_i8", "ar_rmsnorm_quant_i8_4rank",
|
||||
/* the 31B's full layers: the windowed attention and its merge (r4d_attn_paged_window.hip,
|
||||
@@ -10064,6 +10264,9 @@ extern "C" int rad_kernel_chain(int i) {
|
||||
"attn_qrow_h512_gqa2_fp8kv", "attn_qrow_h512_gqa2_bf16kv",
|
||||
"attn_qrow_h512_gqa4_fp8kv", "attn_qrow_h512_gqa4_bf16kv",
|
||||
"attn_qrow_h512_gqa8_fp8kv", "attn_qrow_h512_gqa8_bf16kv",
|
||||
"attn_qrow_tree_h512_gqa2_fp8kv", "attn_qrow_tree_h512_gqa2_bf16kv",
|
||||
"attn_qrow_tree_h512_gqa4_fp8kv", "attn_qrow_tree_h512_gqa4_bf16kv",
|
||||
"attn_qrow_tree_h512_gqa8_fp8kv", "attn_qrow_tree_h512_gqa8_bf16kv",
|
||||
"quant_act_i8",
|
||||
/* DFlash2's query and context passes: the narrow fp8 GEMMs (the gated gate_up among
|
||||
* them), the activation quantiser, the norms, the conv projection, the opening
|
||||
@@ -10081,7 +10284,7 @@ extern "C" int rad_kernel_chain(int i) {
|
||||
* selector */
|
||||
"sample_temp_f32", "sample_topk_f32", "sample_merge_topk_f32", "sample_pick_f32",
|
||||
"ar_gather_4rank", "gemm_w8a8_nt_m64", "rowtopk_bf16", "rowtopk_merge",
|
||||
"dflash_select_bf16",
|
||||
"dflash_select_bf16", "dflash_tree_bf16",
|
||||
/* the weight read beside a collective (its blocks add before reading, r4d_prefetch.hip) */
|
||||
"prefetch",
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user