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
@@ -119,15 +119,33 @@ void ref2va_ada_cell(const Ref2VAPack& p, double t_v, double t_a, std::vector<in
|
||||
* fine per-reference segments. The modulation table is then sized by the group count, not the
|
||||
* reference count -- which is what lets a wide reference request (up to nine photos) ride a fixed
|
||||
* table. Groups cover the whole sequence: boundaries start at 0 and end at `rows`. Empty segments
|
||||
* (end <= start) carry no rows and open no boundary. `md`/`r0` are per group, for the table writer. */
|
||||
* (end <= start) carry no rows and open no boundary.
|
||||
*
|
||||
* The reference implementation modulates by a per-token TAG, not by segment: the prompt span's
|
||||
* vision-pad rows -- the `vision_start` / tiles / `vision_end` run that wraps every reference
|
||||
* photo -- carry the video tag (0), not the text tag (1), so they modulate with the video ada
|
||||
* projection while staying on the text segment's timestep row. `runs` replays that: each run cuts
|
||||
* the text segment at its edges, and a run's piece reads (md = tag, r0 = 0). The number of GROUPS
|
||||
* then grows with the media count, but the distinct CELLS never exceed the handful of (md, r0)
|
||||
* pairs -- text, pad, each reference kind's pinned cell, the two target cells -- so the table is
|
||||
* sized by DISTINCT CELLS while the groups address it through `col`. */
|
||||
struct Ref2VATagRun {
|
||||
int64_t start, end; /* rows [start, end) inside the text segment */
|
||||
int tag; /* the ada projection the run reads (vision pads: 0) */
|
||||
};
|
||||
struct Ref2VAModGroups {
|
||||
std::vector<int64_t> bound; /* [count + 1]: cumulative row boundaries, [0 .. rows] */
|
||||
std::vector<int> md; /* [count]: the group's ada projection (0 video, 1 text, 2 audio) */
|
||||
std::vector<int64_t> r0; /* [count]: the timestep-embedding block the group's cell reads */
|
||||
std::vector<int> col; /* [count]: which cell (index into md/r0) the group reads */
|
||||
std::vector<int> md; /* [cells]: the cell's ada projection (0 video, 1 text, 2 audio) */
|
||||
std::vector<int64_t> r0; /* [cells]: the timestep-embedding block the cell reads */
|
||||
};
|
||||
/* `S` is the sampler's step count (the embedding's per-schedule row span); it fixes the pinned
|
||||
* blocks at [2S,3S) video / [3S,4S) audio, exactly as the arch's ref_cell_of does. */
|
||||
void ref2va_mod_groups(const Ref2VAPack& p, int64_t S, Ref2VAModGroups* out);
|
||||
* blocks at [2S,3S) video / [3S,4S) audio, exactly as the arch's ref_cell_of does. `runs` are the
|
||||
* tag runs inside the text segment -- sorted is not required (they are normalised here), anything
|
||||
* outside the text span is dropped. An empty `runs` gives exactly the segment-kind merge: cells
|
||||
* then never repeat, so `col` is the identity and the output matches the pre-tag-run tables. */
|
||||
void ref2va_mod_groups(const Ref2VAPack& p, int64_t S, const std::vector<Ref2VATagRun>& runs,
|
||||
Ref2VAModGroups* out);
|
||||
|
||||
/* Lay the sequence out. Returns 0, or -1 on a negative dimension (the driver has already bounded
|
||||
* media against the arch's ceilings; this only refuses nonsense). */
|
||||
|
||||
Reference in new issue
Block a user