ops+minimaxh3+driver: the condition-noise augmentation the reference adds to visual cond rows

The reference's _cond_video_rows runs every visual conditioning latent through
x = aug x + (1 - aug) z at VISUAL_COND_TIMESTEP 0.999, its generator restarted
per item, while audio conditioning is untouched (its aug is 1.0, a no-op). We
staged the clean latent instead, so every image-, keyframe- and reference-
conditioned render started from un-augmented conditioning.

New op cond_aug: x = f32(f32(a x) + f32(oma z)), a the aug parameter and oma
the f32 of the double 1 - aug -- the reference subtracts in double and rounds
once -- with z the (seed, stream) normal stream at element k n + c on stream
2, the reference's noise never sharing the generator that fills x. Seed words
0-1 of the video's seed, per-item restart by per-row offset. Issued once at
the end of step_venc over the conditioning rows: staging once at encode-build
time is equivalent to the reference's per-call restart because each item's
rows are exactly its own, and the driver's build_encode now re-stages the
seed, where a stale lane's words used to ride through.

Reference RNG is MT19937 and ours Philox, so the noise is distributionally
faithful, not bit-exact. ABI unchanged at 28. Device: r4d_selftest 0 failures,
cond_aug rows 1.13e-9/4.42e-8 rel_l2 against libref.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
gearwave00001andClaude committed 2026-10-25 08:45:29 -05:00
1 parent 8c547fe240
commit 47b7aae7a3
16 files changed
+320 -4

No files matched your search

+12
View File
@@ -891,6 +891,11 @@ static const RadOperandSpec oResize[] = { OPD("x"), OPD("geom"), OUT("y") };
static const RadParamSpec pFlowRenoise[] = { P_INT("M"), P_INT("n"), P_INT("stream"),
P_STR("dtype") };
static const RadOperandSpec oFlowRenoise[] = { OPD("sigma"), OPD("seed"), INOUT("x") };
/* `aug` is the condition's kept fraction (the reference's VISUAL_COND_TIMESTEP, 0.999); unlike
* `flow_renoise` the blend weight is a declared recipe constant, not a staged tensor. */
static const RadParamSpec pCondAug[] = { P_INT("M"), P_INT("n"), P_INT("stream"), P_F64("aug"),
P_STR("dtype") };
static const RadOperandSpec oCondAug[] = { OPD("seed"), INOUT("x") };
/* ---- LTX-2 (ref_ltx.cpp) */
static const RadParamSpec pRopeSplit[] = { P_INT("M"), P_INT("n_head"), P_INT("head_dim"),
@@ -1807,6 +1812,11 @@ static const RadOpSchema kSchemas[] = {
{ "flow_renoise", ARR(pFlowRenoise), ARR(oFlowRenoise),
"a clean latent re-noised to sigma s: x = f32(f32(f32(1 - s) x) + f32(s z)), z element "
"k n + c of the normal stream (seed, `stream`) (abi/rad_philox.h)." },
{ "cond_aug", ARR(pCondAug), ARR(oCondAug),
"a visual condition's rows blended with fresh noise, the reference's condition augmentation: "
"x = f32(f32(a x) + f32(oma z)) with a = `aug` and oma the f32 of the f64 1 - aug, z element "
"k n + c of the normal stream (seed, `stream`); the caller issues one media item's rows so "
"every item restarts the same stream, as the reference does." },
{ "rope_split", ARR(pRopeSplit), ARR(oRopeSplit),
"LTX-2's rotary over fractional coordinates: dim/2 pairs over all heads, the first `pad` "
"unrotated, then freq[k] = f32(theta^linspace(0,1,steps)[k] pi/2) with the n_dims coordinates "
@@ -2450,6 +2460,8 @@ SIMPLE("ref_patch_fold", "patch_fold", "elem", "voxel rows to normalised patch r
ref_patch_fold),
SIMPLE("ref_flow_renoise", "flow_renoise", "elem", "a clean latent re-noised to a sigma", DT_FLOAT,
ref_flow_renoise),
SIMPLE("ref_cond_aug", "cond_aug", "elem", "condition rows blended with fresh noise at a fixed aug",
DT_FLOAT, ref_cond_aug),
SIMPLE("ref_rope_split", "rope_split", "elem", "LTX-2's split rotary over coordinates", DT_FLOAT,
ref_rope_split),
SIMPLE("ref_head_gate", "head_gate", "elem", "each head times 2 sigmoid of its logit", DT_FLOAT,