Archived
ops: the column map the modulated pads read through was missing from the SCHEMA tables
8a6a118 gave the rms_mod family an optional trailing colmap -- sequences that share
one modulation cell read the shift/scale (and gate) table through that cell's COLUMN,
so the prompt's vision-pad runs share the video cell's row across non-contiguous
boundaries. It taught the device kernel and libref's implementation to follow the map,
but the operand itself reached only the driver's issue: none of the three operand
tables listed it. The schema is what the loader and the engine check against, and all
three declaring libs must agree, so the battery's first serve died at step 1 --
`rms_mod_quant_i8 ... issued with 10 operands; the op's schema declares 9`.
All three tables now list `colmap` as the trailing optional operand of rms_mod and
both quant producers (past every other arch's last operand), and libref's shape
describers answer an explicit skip for it -- the sweep passes no map. libavx's
rms_mod_run was missing the feature outright: it now reads the tables through the
map's column and drops the `s` and `g` row-count checks when a map is bound -- the
table is sized by columns, not by sequences -- while the map's own bound stays the
issuer's. OPS.md's rows and prose regenerated against the dumped schemas.
Verified: ref_test full suite (the rms_mod sweeps run mapless through the new skip),
rad-avx-check on the plain and quant rows, the device rms_mod and rms_mod_quant_fp8
cases, ops_doc, and full ctest 123/123; on device a serve that died at step 1 now
boots and renders the keyframe tasks end to end.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
69087ce773
commit
fe311c5c80
6 files changed
+30
-14
No files matched your search
+7
-3
@@ -1444,9 +1444,9 @@ bf16 tensor and keeps f32 where it computes in f32; the libref function says whi
|
||||
|
||||
| op | params | operands |
|
||||
|---|---|---|
|
||||
| `rms_mod` | `M`(range) `n` `eps`:f64 `gated`/opt `dtype` `wadd`:f64/opt `norm_once`/opt `norm`/opt | `y`?, `g`?, `s`, `w`w?, `cu_seqlens`, `x`:inout → `z` |
|
||||
| `rms_mod_quant_fp8` | `M`(range) `n` `eps`:f64 `group` `gated` `dtype` `wadd`:f64/opt `norm_once`/opt `norm`/opt | `y`?, `g`?, `s`, `w`w?, `cu_seqlens`, `x`:inout → `q`, `scale`, `z`? |
|
||||
| `rms_mod_quant_i8` | `M`(range) `n` `eps`:f64 `group` `gated` `dtype` `wadd`:f64/opt `norm_once`/opt `norm`/opt | `y`?, `g`?, `s`, `w`w?, `cu_seqlens`, `x`:inout → `q`, `scale`, `z`? |
|
||||
| `rms_mod` | `M`(range) `n` `eps`:f64 `gated`/opt `dtype` `wadd`:f64/opt `norm_once`/opt `norm`/opt | `y`?, `g`?, `s`, `w`w?, `cu_seqlens`, `x`:inout → `z`, `colmap`? |
|
||||
| `rms_mod_quant_fp8` | `M`(range) `n` `eps`:f64 `group` `gated` `dtype` `wadd`:f64/opt `norm_once`/opt `norm`/opt | `y`?, `g`?, `s`, `w`w?, `cu_seqlens`, `x`:inout → `q`, `scale`, `z`?, `colmap`? |
|
||||
| `rms_mod_quant_i8` | `M`(range) `n` `eps`:f64 `group` `gated` `dtype` `wadd`:f64/opt `norm_once`/opt `norm`/opt | `y`?, `g`?, `s`, `w`w?, `cu_seqlens`, `x`:inout → `q`, `scale`, `z`?, `colmap`? |
|
||||
| `flow_x0_step` | `M`(range) `n` `dtype` | `v`, `t`, `sigma`, `sigma_next`, `x`:inout |
|
||||
| `flow_res_multistep` | `M`(range) `n` `dtype` | `v`, `x0`:inout, `sigma`, `r`, `hb1`, `hb2`, `order`, `x`:inout |
|
||||
| `patch_unfold` | `M`(range) `C` `pt` `ph` `pw` `mul` `add` `dtype` | `x`, `geom` → `y` |
|
||||
@@ -1474,6 +1474,10 @@ reads its entry's rows of `s` and `g`.
|
||||
`eps`. Without `w` the norm has no gain and rounds once, `n2 = bf16((x - mean) rsqrt(var +
|
||||
eps))` (FLUX.3's LayerNorm without an affine). `norm` `none` takes no norm and no gain,
|
||||
`n2 = x`, and refuses `w` (LTX-2's text keys and values, modulated as they are).
|
||||
`colmap` (optional, trailing, i32 one per sequence) reads the tables through a column map: every
|
||||
`[e]` above becomes `[colmap[e]]`, so groups that share a modulation cell address one table row
|
||||
across non-contiguous boundaries; when it is bound the `s` and `g` row-count checks drop (the
|
||||
table is sized by columns, not sequences) and the map's own bound is the issuer's.
|
||||
- `rms_mod_quant_fp8` is `rms_mod` with the norm chain in bf16, then `quant_act_fp8` of that bf16
|
||||
row per `group` as `ln_mod_quant_fp8` takes it; `z` written when bound.
|
||||
- `rms_mod_quant_i8` is the same with `quant_act_i8g` in place of `quant_act_fp8`: symmetric int8
|
||||
|
||||
+13
-6
@@ -342,13 +342,18 @@ static int rms_mod_run(const RadArgs* a, bool quant) {
|
||||
const bool once = p_int(a, "norm_once", 0) != 0;
|
||||
const char* nk = p_str(a, "norm", "rms");
|
||||
const bool layer = std::strcmp(nk, "layer") == 0, none = std::strcmp(nk, "none") == 0;
|
||||
/* The optional trailing column map (slot 9 quant, slot 7 plain): each sequence reads the
|
||||
* modulation table through its mapped COLUMN, so `s` and `g` may hold fewer rows than there
|
||||
* are sequences -- the map's own bound is the issuer's, as in libr4d and libref. */
|
||||
const RadTensor* cm = rad_arg_in(a, quant ? 9 : 7);
|
||||
if ((!layer && !none && std::strcmp(nk, "rms") != 0) || (none && W)) return RAD_E_INVAL;
|
||||
if (n <= 0 || grp <= 0 || n % grp || (gated && (!Yv || !G))) return RAD_E_SHAPE;
|
||||
const int64_t rows = rows_of(quant ? Q : Z, n), n_seq = numel(cu) - 1, ngrp = n / grp;
|
||||
if (cm && (cm->dtype != RAD_I32 || numel(cm) < n_seq)) return RAD_E_SHAPE;
|
||||
if (rows <= 0 || n_seq <= 0 || rows_of(X, n) < rows || (W && numel(W) < n) ||
|
||||
numel(S) < n_seq * 2 * n)
|
||||
(!cm && numel(S) < n_seq * 2 * n))
|
||||
return RAD_E_SHAPE;
|
||||
if (gated && (rows_of(Yv, n) < rows || numel(G) < n_seq * n)) return RAD_E_SHAPE;
|
||||
if (gated && (rows_of(Yv, n) < rows || (!cm && numel(G) < n_seq * n))) return RAD_E_SHAPE;
|
||||
if (quant && (numel(SC) < rows * ngrp || (Z && rows_of(Z, n) < rows))) return RAD_E_SHAPE;
|
||||
const uint32_t dt = quant ? (uint32_t)RAD_BF16 : Z->dtype;
|
||||
/* The tables from one scratch_raw call, [gain | shift | gate] a sequence and the weight row:
|
||||
@@ -358,13 +363,15 @@ static int rms_mod_run(const RadArgs* a, bool quant) {
|
||||
{
|
||||
const int64_t s_rs = row_stride(S, 2 * n), s_cs = laststride(S);
|
||||
const int64_t g_rs = gated ? row_stride(G, n) : 0, g_cs = gated ? laststride(G) : 0;
|
||||
for (int64_t e = 0; e < n_seq; ++e)
|
||||
for (int64_t e = 0; e < n_seq; ++e) {
|
||||
const int64_t col = cm ? (int64_t)ldt(cm, e) : e; /* the sequence's table column */
|
||||
for (int64_t i = 0; i < n; ++i) {
|
||||
float* row = tabs + e * tw;
|
||||
row[i] = narrow1(dt, 1.0f + ldt(S, e * s_rs + (n + i) * s_cs));
|
||||
row[n + i] = ldt(S, e * s_rs + i * s_cs);
|
||||
if (gated) row[2 * n + i] = ldt(G, e * g_rs + i * g_cs);
|
||||
row[i] = narrow1(dt, 1.0f + ldt(S, col * s_rs + (n + i) * s_cs));
|
||||
row[n + i] = ldt(S, col * s_rs + i * s_cs);
|
||||
if (gated) row[2 * n + i] = ldt(G, col * g_rs + i * g_cs);
|
||||
}
|
||||
}
|
||||
for (int64_t i = 0; i < n; ++i)
|
||||
tabs[n_seq * tw + i] = W ? ldt(W, i * laststride(W)) + wadd : 1.0f;
|
||||
}
|
||||
|
||||
@@ -562,13 +562,14 @@ static const RadParamSpec pRmsMod[] = { P_INT("M"), P_INT("n"), P_F64("eps"), P
|
||||
P_STR("dtype"), P_F64O("wadd"),
|
||||
P_INTO("norm_once"), P_STRO("norm") };
|
||||
static const RadOperandSpec oRmsMod[] = { OPD_O("y"), OPD_O("g"), OPD("s"), WGT_O("w"),
|
||||
OPD("cu_seqlens"), INOUT("x"), OUT("z") };
|
||||
OPD("cu_seqlens"), INOUT("x"), OUT("z"),
|
||||
OPD_O("colmap") };
|
||||
static const RadParamSpec pRmsModQ[] = { P_INT("M"), P_INT("n"), P_F64("eps"), P_INT("group"),
|
||||
P_INT("gated"), P_STR("dtype"), P_F64O("wadd"),
|
||||
P_INTO("norm_once"), P_STRO("norm") };
|
||||
static const RadOperandSpec oRmsModQ[] = { OPD_O("y"), OPD_O("g"), OPD("s"), WGT_O("w"),
|
||||
OPD("cu_seqlens"), INOUT("x"), OUT("q"), OUT("scale"),
|
||||
OUT_O("z") };
|
||||
OUT_O("z"), OPD_O("colmap") };
|
||||
static const RadOperandSpec oFlowX0[] = { OPD("v"), OPD("t"), OPD("sigma"), OPD("sigma_next"),
|
||||
INOUT("x") };
|
||||
static const RadOperandSpec oFlowRM[] = { OPD("v"), INOUT("x0"), OPD("sigma"), OPD("r"),
|
||||
|
||||
+2
-1
@@ -2620,7 +2620,7 @@ static const RadParamSpec pRmsMod[] = { P_INT("M"), P_INT("n"), P_F64("eps"), P_
|
||||
static const RadOperandSpec oRmsMod[] = {
|
||||
{ "y", RAD_OPD_IN, 1 }, { "g", RAD_OPD_IN, 1 }, { "s", RAD_OPD_IN, 0 },
|
||||
{ "w", RAD_OPD_WEIGHT, 1 }, { "cu_seqlens", RAD_OPD_IN, 0 }, { "x", RAD_OPD_INOUT, 0 },
|
||||
{ "z", RAD_OPD_OUT, 0 },
|
||||
{ "z", RAD_OPD_OUT, 0 }, { "colmap", RAD_OPD_IN, 1 },
|
||||
};
|
||||
static const RadParamSpec pRmsModQ[] = { P_INT("M"), P_INT("n"), P_F64("eps"), P_INT("group"),
|
||||
P_INT("gated"), P_STR("dtype"), P_F64O("wadd"),
|
||||
@@ -2629,6 +2629,7 @@ static const RadOperandSpec oRmsModQ[] = {
|
||||
{ "y", RAD_OPD_IN, 1 }, { "g", RAD_OPD_IN, 1 }, { "s", RAD_OPD_IN, 0 },
|
||||
{ "w", RAD_OPD_WEIGHT, 1 }, { "cu_seqlens", RAD_OPD_IN, 0 }, { "x", RAD_OPD_INOUT, 0 },
|
||||
{ "q", RAD_OPD_OUT, 0 }, { "scale", RAD_OPD_OUT, 0 }, { "z", RAD_OPD_OUT, 1 },
|
||||
{ "colmap", RAD_OPD_IN, 1 },
|
||||
};
|
||||
static const RadOperandSpec oFlowX0[] = {
|
||||
{ "v", RAD_OPD_IN, 0 }, { "t", RAD_OPD_IN, 0 }, { "sigma", RAD_OPD_IN, 0 },
|
||||
|
||||
@@ -769,13 +769,14 @@ static const RadParamSpec pRmsMod[] = { P_INT("M"), P_INT("n"), P_F64("eps"), P
|
||||
P_STR("dtype"), P_F64O("wadd"),
|
||||
P_INTO("norm_once"), P_STRO("norm") };
|
||||
static const RadOperandSpec oRmsMod[] = { OPD_O("y"), OPD_O("g"), OPD("s"), WGT_O("w"),
|
||||
OPD("cu_seqlens"), INOUT("x"), OUT("z") };
|
||||
OPD("cu_seqlens"), INOUT("x"), OUT("z"),
|
||||
OPD_O("colmap") };
|
||||
static const RadParamSpec pRmsModQ[] = { P_INT("M"), P_INT("n"), P_F64("eps"), P_INT("group"),
|
||||
P_INT("gated"), P_STR("dtype"), P_F64O("wadd"),
|
||||
P_INTO("norm_once"), P_STRO("norm") };
|
||||
static const RadOperandSpec oRmsModQ[] = { OPD_O("y"), OPD_O("g"), OPD("s"), WGT_O("w"),
|
||||
OPD("cu_seqlens"), INOUT("x"), OUT("q"), OUT("scale"),
|
||||
OUT_O("z") };
|
||||
OUT_O("z"), OPD_O("colmap") };
|
||||
/* `t`, `sigma` and `sigma_next` are one f32 value each. */
|
||||
static const RadOperandSpec oFlowX0[] = { OPD("v"), OPD("t"), OPD("sigma"), OPD("sigma_next"),
|
||||
INOUT("x") };
|
||||
|
||||
@@ -2597,6 +2597,7 @@ int ref_rms_mod_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out)
|
||||
o.t_idx({ 2 }, 0, -1, (uint32_t)RAD_OPD_F_IDX_CU); /* cu_seqlens */
|
||||
o.t(D, { M, n }); /* x, INOUT */
|
||||
o.t(D, { M, n }); /* z */
|
||||
o.skip(); /* colmap: the sweep passes none */
|
||||
return o.finish("rms_mod", operand, out);
|
||||
}
|
||||
int ref_rms_mod_quant_fp8_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
|
||||
@@ -2620,6 +2621,7 @@ int ref_rms_mod_quant_fp8_shape(const RadParam* p, int n_p, int operand, RadOpdD
|
||||
o.t((uint32_t)RAD_F8E4M3, { M, n }); /* q */
|
||||
o.t((uint32_t)RAD_F32, { M, ng }); /* scale */
|
||||
o.t(D, { M, n }); /* z */
|
||||
o.skip(); /* colmap: the sweep passes none */
|
||||
return o.finish("rms_mod_quant_fp8", operand, out);
|
||||
}
|
||||
/* The sampler's three scalars in (0, 1), the state f32. */
|
||||
|
||||
Reference in new issue
Block a user