Archived
nemotron 3.5 implementation
This commit is contained in:
1 parent
33108e488b
commit
94c90b17ad
59 files changed
+6046
-76
No files matched your search
@@ -435,6 +435,23 @@ static const RadParamSpec pRope[] = { P_INT("M"), P_INT("head_dim"), P_INT("n_he
|
||||
P_F64O("llama3_orig") };
|
||||
static const RadOperandSpec oRope[] = { INOUT("qkv"), OPD("positions") };
|
||||
|
||||
static const RadParamSpec pPositionScale[] = { P_INT("M"), P_INT("n"), P_INT("original"),
|
||||
P_F64("beta"), P_STR("dtype") };
|
||||
static const RadOperandSpec oPositionScale[] = { INOUT("x"), OPD("positions") };
|
||||
|
||||
static const RadParamSpec pEmbedAttn[] = { P_INT("M"), P_INT("head_dim"), P_INT("gqa"),
|
||||
P_INT("causal"), P_INTO("max_seqlen"), P_STR("dtype"), P_F64O("scale") };
|
||||
static const RadOperandSpec oEmbedAttn[] = { OPD("q"), OPD("k"), OPD("v"), OPD("cu_seqlens"), OUT("out") };
|
||||
static const RadParamSpec pMinistralRope[] = { P_INT("M"), P_INT("head_dim"), P_INT("n_head"),
|
||||
P_INT("n_head_kv"), P_F64("theta"), P_STR("dtype"), P_F64O("yarn_factor"),
|
||||
P_F64O("yarn_low"), P_F64O("yarn_high"), P_F64O("yarn_magnitude") };
|
||||
static const RadOperandSpec oMinistralRope[] = { INOUT("qkv"), OPD("pos") };
|
||||
static const RadParamSpec pPixtralRope[] = { P_INT("M"), P_INT("head_dim"), P_INT("n_head"),
|
||||
P_F64("theta"), P_STR("dtype") };
|
||||
static const RadOperandSpec oPixtralRope[] = { INOUT("qkv"), OPD("coord") };
|
||||
static const RadParamSpec pPixtralMerge[] = { P_INT("M"), P_INT("n"), P_INT("merge"), P_STR("dtype") };
|
||||
static const RadOperandSpec oPixtralMerge[] = { OPD("x"), OPD("coord"), OUT("y") };
|
||||
|
||||
/* The cos/sin plane a fused prologue reads instead of theta, at each position's own row of a
|
||||
* [max_ctx, rot] table. `rot`, `theta` and `scale` are spelled as on `rope`, which must compute the
|
||||
* same angles. */
|
||||
@@ -1457,6 +1474,17 @@ static const RadOpSchema kSchemas[] = {
|
||||
"cos/sin for the positions a step names, at each position's own row of a [max_ctx, rot] plane: "
|
||||
"rot values a row, cos for the first half and sin for the second. The angles are `rope`'s "
|
||||
"exactly. A row no position names is not written; a negative position writes nothing." },
|
||||
{ "embed_attn", ARR(pEmbedAttn), ARR(oEmbedAttn),
|
||||
"Whole noncausal segments with QK, scaled scores and probabilities rounded to activation dtype." },
|
||||
{ "ministral_rope", ARR(pMinistralRope), ARR(oMinistralRope),
|
||||
"Ministral NeoX rotary with BF16 cos/sin and separately rounded products; V is unchanged." },
|
||||
{ "pixtral_rope", ARR(pPixtralRope), ARR(oPixtralRope),
|
||||
"Pixtral axial rotary with interleaved height/width frequencies and BF16 product rounding." },
|
||||
{ "pixtral_merge", ARR(pPixtralMerge), ARR(oPixtralMerge),
|
||||
"Pack full raster patch grids into channel-major spatial merge blocks, without mixing images." },
|
||||
{ "position_scale", ARR(pPositionScale), ARR(oPositionScale),
|
||||
"Scale query row p by 1 + beta * log(1 + floor(position[p] / original)), rounding the scale "
|
||||
"to x's dtype before multiplication. Positions are nonnegative i32." },
|
||||
{ "qsa_block_key", ARR(pQsaBlockKey), ARR(oQsaBlockKey),
|
||||
"QSA's compressed key, one vector per `ratio` rows of k: the block's mean accumulated in f32 and "
|
||||
"rounded to k's dtype, RMS-normed with gain (wadd + w), then NeoX-rotated over `rotary_dim` at "
|
||||
@@ -2380,6 +2408,11 @@ ROW("ref_kv_store_streamed", "kv_store_streamed", "attn",
|
||||
"scatter k and v into the host mirror always and into the resident ring slot", DT_ANY,
|
||||
nullptr, 0, nullptr, nullptr, ref_kv_store_streamed, nullptr),
|
||||
SIMPLE("ref_rope", "rope", "attn", "rotary embedding in place", DT_FLOAT, ref_rope),
|
||||
SIMPLE("ref_embed_attn", "embed_attn", "attn", "BF16 materialized encoder attention", "bf16/f32, i32 cu", ref_embed_attn),
|
||||
SIMPLE("ref_ministral_rope", "ministral_rope", "attn", "Ministral BF16 rotary", "bf16/f32 inout, i32 positions", ref_ministral_rope),
|
||||
SIMPLE("ref_pixtral_rope", "pixtral_rope", "attn", "Pixtral interleaved axial rotary", "bf16/f32 inout, i32 coordinates", ref_pixtral_rope),
|
||||
SIMPLE("ref_pixtral_merge", "pixtral_merge", "vision", "channel-major patch merger packing", "bf16/f32, i32 coordinates", ref_pixtral_merge),
|
||||
SIMPLE("ref_position_scale", "position_scale", "attn", "Ministral position-dependent query scale", "bf16/f32 inout, i32 positions", ref_position_scale),
|
||||
SIMPLE("ref_qk_norm_rope", "qk_norm_rope", "attn", "per-head QK norm then rotary embedding",
|
||||
DT_FLOAT, ref_qk_norm_rope),
|
||||
|
||||
|
||||
Reference in new issue
Block a user