ref2va: merged-cell modulation lifts the reference-photo ceiling from five to nine

A modulation cell is a pure function of a segment's kind -- (modality ada,
timestep block) -- so all reference photos share one cell. Runs of consecutive
same-cell segments collapse to a group; group boundaries are a subset of the
fine segment boundaries and the merge is sequence-length independent (the key
is kind alone). The modulated norm now reads COARSER group boundaries via a new
trailing RadVideoGenBatch::mod_cu while attention keeps the fine seg_cu, and the
fixed-width table is pitched by GROUP count. Nine photos therefore occupy four
groups (prompt / all-photos / soundtrack / video); buffer sizes and the arena
are unchanged (kMaxSegs stays 8, no kernel change, no re-convert).

No regression for <=5 photos: each photo cell already filled its own column from
the same input rows and weights, so it was bit-identical to the others; merging
issues it once instead of N times and yields the same per-row value. Only the
previously-rejected sixth through ninth photos change, by being allowed.

Driver: rad_arch_video_mod_segs (trailing plugin export) computes the merged
groups host-side; the driver stages them into R_MOD, guards the GROUP count
against max_ref_segs at submit (a clean refusal beats a step-loop fault), and
the plain path stages the fine table into both operands.

Device-verified on dual gfx1201 / TP2 with a CONTROLLED same-seed battery
(task=ref2va, seed fixed on every job, so neither the seed nor the token count
is a confounder): same prompt, same seed, same ref-count, DIFFERENT image
content give DIFFERENT outputs -- the reference is genuinely consumed. Nine
photos complete (the case the pinned build refused at submit), whole-run fault
scan clean.

Adds docs/NOTE-REF2VA.md: what this port reproduces of the DaSiWa workflow and
what it does not -- the residual 8-group ceiling under heavy interleaved mixed
refs, the reference-token / row budget, continuity tail (unimplemented), the
video/audio reference paths (plumbed, not yet device-verified), references x
latent-upscale exclusion, and open conditioned-step parity.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
gearwave00001andClaude committed 2026-10-19 12:31:55 -05:00
1 parent 490d4c604a
commit 72624973ad
15 files changed
+454 -59

No files matched your search

+11 -6
View File
@@ -958,12 +958,17 @@ typedef struct RadVideoGenDecl {
* denoiser reads `ref_tab`, so this flag is what makes staging and consumption flip together. */
int32_t ref_rows;
/* The largest segment count this generator's modulation table holds: its denoiser lays out one
* modulation cell per pack segment, and the table is sized `kMaxSegs` columns. A conditioned
* pack whose segments exceed this cannot be built -- the step would abort the engine. The driver
* refuses such a request at submit (it lays the pack out itself, so it knows the count before
* dispatch) rather than letting the arch fail mid-generation. 0 = no reference consumption, so
* no such limit. Trailing since ABI 23: an older plugin declares none and keeps the 0 default. */
/* The largest MODULATION-GROUP count this generator's modulation table holds -- its denoiser's
* `kMaxSegs`. A modulation cell is a pure function of a segment's KIND (its modality and its
* timestep-embedding block), so runs of consecutive segments that share a cell collapse into one
* group and the table is sized by the GROUP count, not the reference count: nine reference photos
* pack into four groups (prompt, all-photos, soundtrack, video). The attention still takes the
* FINE per-segment table (which may hold far more segments than this), so this is not a limit on
* how many references ride -- only on how many DISTINCT cells the sequence changes through. The
* driver refuses a request whose merged group count exceeds it at submit (it lays the pack out and
* merges it itself, via `rad_arch_video_mod_segs`, so it knows before dispatch) rather than letting
* the arch abort mid-generation. 0 = no reference consumption, so no such limit. Trailing since
* ABI 23: an older plugin declares none and keeps the 0 default. */
int32_t max_ref_segs;
} RadVideoGenDecl;
+12
View File
@@ -506,6 +506,18 @@ typedef struct RadVideoGenBatch {
* latent frames and its audio latents, 0 where the kind carries neither. A batch without
* the field laid out is one an older engine built: no references. Trailing since ABI 23. */
const int32_t* ref_tab;
/* ---- The modulated-norm's segment boundaries, device i32. The denoiser's attention reads the
* FINE `seg_cu` -- one segment per reference block, which the block-sparse attention needs to
* give each reference its own prefix sink -- but the modulated norm reads a COARSER table:
* consecutive segments that share a modulation cell (the same modality and the same
* timestep-embedding block) merge into one, because a cell is a pure function of a segment's
* kind. This is that merged table's boundaries, a subset of `seg_cu`'s -- every fine boundary
* that is also a cell change. Sizing the modulation table by the GROUP count, not the reference
* count, is what lets a wide reference request (up to nine photos, which pack into four groups)
* ride a fixed table. On a plain request (or one that merges nothing) it is exactly `seg_cu`; a
* driver stages the same bytes into both. Trailing since ABI 23. */
const int32_t* mod_cu;
} RadVideoGenBatch;
/* RadVideoGenBatch::enc_kind: which reference media an encode pass carries. A plugin's latent