Archived
minimaxh3+r4d+driver: the prompt's vision pads are modulated as video, not as text
The reference modulates by a per-token TAG: token_tags_from_embeds_info tags every image embed span (with one flanking token on each side) 0 -- video -- inside the prompt, while audio pads keep tag 1 (parallel PR #236, point 3). Our port modulated the whole prompt span as text, so every reference photo's pad tokens read the text ada projection where the reference reads the video one. The tags arrive in the prompt itself and nothing else carries them, so the denoiser could not know, and the look drifted with the reference count. The driver now writes each image item's token span into a tail of ref_tab -- one count, then {start, length} per run, audio items excluded (the reference tags images only). The tail rides inert through the pack and ref_parts, and is present exactly when the reference table is, so an i2va request keeps its old bytes. ref2va_mod_groups grows a runs argument: it cuts the prompt at the runs' edges and gives the pad pieces the VIDEO cell -- the video projection on the video-schedule block; the prompt's own timestep row never changes, only the projection. Cells stay few however many photos interleave, but groups no longer equal cells: two prompt pieces separated by a pad share one cell non-adjacently. So the merged-group output gains a per-group column map, and the modulated- norm kernels -- libr4d and libref alike -- accept an optional trailing colmap (slot 9 quant, 7 bf16, past every other arch's last operand) that redirects sequence -> table column, relaxing the row-count checks it binds. rad_arch_video_mod_segs exports boundaries then map, the plugin stages both only for a reference request -- the plain path still stages boundaries alone, byte-identical -- and the half-split keeps its single video row by taking the target's column instead of the last one. max_ref_segs now bounds the DISTINCT CELLS, its old meaning was the group count. ABI 28; no struct's shape moved, the layout table is re-stamped. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
c5483e3241
commit
8a6a1180ce
14 files changed
+548
-139
No files matched your search
+1
-1
@@ -18,7 +18,7 @@ extern "C" {
|
||||
* kind of plugin reports it, and a plugin that does not report exactly this version is refused at
|
||||
* load with both versions printed. A new optional export (e.g. rad_plugin_reference) is not a
|
||||
* change of shape: a plugin without it gets the default. */
|
||||
#define RAD_ABI_VERSION 27u
|
||||
#define RAD_ABI_VERSION 28u
|
||||
|
||||
/* ================================================================== plugin identity */
|
||||
/* One value per plugin, not flags (QUANT is 3). RAD_PLUGIN_QUANT is a quantiser plugin:
|
||||
|
||||
+17
-12
@@ -1311,17 +1311,20 @@ typedef struct RadVideoGenDecl {
|
||||
* denoiser reads `ref_tab`, so this flag is what makes staging and consumption flip together. */
|
||||
int32_t ref_rows;
|
||||
|
||||
/* 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. */
|
||||
/* The largest number of DISTINCT MODULATION CELLS 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) and, since ABI 28, of a prompt vision-pad run's
|
||||
* tag: runs of consecutive same-cell rows collapse into one GROUP, and groups that share a cell
|
||||
* read it through the column map staged with the group boundaries (`rad_arch_video_mod_segs`),
|
||||
* so the table is sized by the DISTINCT-CELL count -- not the group count and not the reference
|
||||
* count. 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 and its prompt pads change through. The driver refuses a request whose
|
||||
* merged cells exceed 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; its meaning was the merged GROUP count
|
||||
* until ABI 28 made the cells and the groups separate. */
|
||||
int32_t max_ref_segs;
|
||||
|
||||
/* Debug introspection of the encoder outputs (diagnostics only, not part of the serving
|
||||
@@ -1851,7 +1854,9 @@ int64_t rad_arch_encode_geom(int32_t kind, const int64_t* in, int32_t* out, int6
|
||||
* of rad_arch_video_segs. `g` is the target's geometry and `ref_tab` the request's keyframes
|
||||
* and VAE references -- RadVideoGenBatch::ref_tab, its int32 table verbatim -- or null when the
|
||||
* request conditions on no VAE media, which lays out the plain [text | soundtrack | video]
|
||||
* sequence. Returns the packed sequence's total rows -- the rows RAD_VPOS_STEP positions -- or
|
||||
* sequence. Since ABI 28 the table may carry a trailing list of prompt vision-pad tag runs; the
|
||||
* PAD LAYOUT is untouched by them (they ride inside the prompt's rows), so this export reads only
|
||||
* the counts, references and keyframes and answers identically with or without the tail. Returns the packed sequence's total rows -- the rows RAD_VPOS_STEP positions -- or
|
||||
* a negative status for counts the model cannot present or caps too small to write into. With
|
||||
* `seg` non-null it writes the segment boundaries (seg[k] the first row of segment k, of the n
|
||||
* it needs) when `cap_seg` int32s hold them; with `pos` non-null the rotary positions (f32
|
||||
|
||||
+22
-12
@@ -623,20 +623,30 @@ typedef struct RadVideoGenBatch {
|
||||
* reference's `kind` is 0 a picture, 1 a standalone audio, 2 a video, 3 a video's
|
||||
* soundtrack; `slot` is its 1-based number within its kind -- the slot its encode pass
|
||||
* wrote. The counts are latent units: a reference's own latent grid (height, width), its
|
||||
* 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. */
|
||||
* latent frames and its audio latents, 0 where the kind carries neither. Since ABI 28 the
|
||||
* table then carries the prompt's VISION-PAD TAG RUNS, which lay out nothing but DO change
|
||||
* the modulation cells the pad rows read: one int32 count, then 2 words per run {start,
|
||||
* length} — token spans inside the prompt where the image pads (the vision_start, tiles and
|
||||
* vision_end of one visual reference) carry the video tag instead of the text tag. A table
|
||||
* written by an ABI 28 driver always has the word count (0 when the prompt has no pads); 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. */
|
||||
/* ---- The modulated-norm's group boundaries -- and, since ABI 28, its group->column MAP --
|
||||
* 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: runs of consecutive rows that share a
|
||||
* modulation cell merge into one GROUP, a cell being a pure function of a segment's kind and
|
||||
* (since ABI 28) of a prompt vision-pad's tag, so pad runs cut the text group. This operand is
|
||||
* the merged table's boundaries -- every boundary that is also a cell change, a superset of
|
||||
* `seg_cu`'s subset once pads cut -- followed, since ABI 28, by one i32 per group: the
|
||||
* modulation-table COLUMN that group reads. Groups that share a cell share a column, so the
|
||||
* table is sized by the DISTINCT-CELL count however many groups the pads and kinds cut: that
|
||||
* is what lets a wide reference request ride a fixed table. On a plain request it is exactly
|
||||
* `seg_cu` -- boundaries alone, no map -- and the arch reads no map either: a driver stages a
|
||||
* map only for the merged (reference-conditioned) table, and the plain path keeps the
|
||||
* byte-identical pre-ABI-28 bytes. Trailing since ABI 23. */
|
||||
const int32_t* mod_cu;
|
||||
|
||||
/* ---- The sampler that advances the latents: RAD_SAMPLER_* above. Trailing since ABI 24. */
|
||||
|
||||
Reference in new issue
Block a user