keyframes: feed endpoint keyframes through the vision tower (TE-anchor tokens)

Image-conditioned MiniMax-H3 (I2VA/L2VA/FL2VA = first_frame/last_frame) rendered
over-saturated / posterized while T2VA was clean on the same container. Root cause:
the reference conditions a keyframe TWICE -- a vision-tower anchor (clip.tokenize
images=[kf] -> <Picture N> soft-tokens in the text conditioning) AND a VAE-latent pin --
but Radiance did only the VAE pin for endpoint keyframes. The absent semantic anchor
left the DiT reconstructing the frame from low-level VAE pixels alone -> posterize /
black-outline / oversaturation.

Route endpoint keyframes through the existing vision-tower media path, so they produce
<Picture N> anchor soft-tokens in addition to their VAE pin (the reference's dual
channel). No new kernels, no ABI / arena change: build_cond stages r->media generically
and the arch scatter is the generic op_mm.

  - videos.cpp: keyframe index = <Picture> ordinal (first=1,last=2); stable-sort keys
    by kind before merge; run the prepare+placement loops for FIRST/LAST_FRAME as well
    as IMAGE (area-matched tower form, aspect-kept; the exact-canvas VAE pin is a
    separate, unchanged second encode); budget wording covers keyframes.
  - video_driver.cpp: a towerless container no longer refuses a keyframe request (skip
    FIRST/LAST_FRAME in the "needs a vision tower" scan) -> pin-only path runs; the
    encodes guard still requires the VAE encoder and now labels a keyframe correctly.

Device A/B (uncensored w8a8, TP2, seed 1234, 512^2): prompt tokens i2va 27->291,
fl2va 1560->2088 (the +256 / +2*256 keyframe vision tokens + labels), t2va 27->27.
T2VA output is bit-identical across binaries (text path untouched). Image-conditioned
output diverges (cos 0.77/0.80): the realistic I2VA mid-frame recovers foliage
structure (blobs -> trees), softens outlines and shadow detail toward the clean control;
FL2VA gains semantic adherence (prompted "wings spread" now renders). Endpoint-pin
cosine unchanged (0.971 / 0.988 / 0.980, at/above the 0.985 bar). No budget reject.

Tests: fl2va keyframes now feed the tower and still pin the ends (index 1/2, token
stream with both vision blocks); towerless fl2va pins-only; driver-level keyframe
conditions through the tower and needs no tower. NOTE-REF2VA.md #8 closed.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
gearwave00001andClaude committed 2026-10-21 01:06:26 -05:00
1 parent 8785774fc0
commit cd393a0973
6 files changed
+212 -26

No files matched your search

+20 -5
View File
@@ -556,11 +556,26 @@ for debug work on every encode. **Device-verified at 512²:** FL2VA 512×512 com
survives, no band fault); host geom/video/ref2va/encoding tests green. Core ops are within their declared bands
(a 1-frame 512 level plane is `0.235×` the 17·256² they're sized for).
**Remaining fidelity gap (→ #10 / P6 bucket, not a function gap).** The pins-only path **skips `clip.tokenize`
vision tokens** for the keyframe images (the TE-anchor tokens the reference would also feed), so a prompt that
*contradicts* the pinned image can let the text win. Closing this = feed TE-anchor tokens for keyframe rows;
that is a value-fidelity follow-up, and the earlier "no golden engine to diff against" limit applies to it.
Chaining still also works independently via the ref_video slot0 path.
**Was a remaining fidelity gap; now CLOSED (2026-10-21, task #52).** The pins-only path used to **skip
`clip.tokenize` vision tokens** for the keyframe images (the TE-anchor tokens the reference would also feed),
so a prompt that *contradicts* the pinned image could let the text win, and realistic I2VA/FL2VA output
over-saturated/posterized (root cause of #37/#50, see memory `dasiwa-reference-ground-truth`). This is now
shipped: an endpoint keyframe is fed the DiT on BOTH channels the reference uses — the VAE-latent pin AND a
`<Picture k>` vision-tower anchor block interleaved into the text conditioning. Mechanism: `videos.cpp` now
runs the media/`<Picture N>` block for keyframe requests (first_frame→`<Picture 1>`, last_frame→`<Picture 2>`),
preparing each anchor through the SAME `mm::prepare`/`PromptMedia`/`mm_rows` tower path the reference images
use (a second, independent encode of the keyframe — the tower sees the aspect-kept area-matched image, the
pin sees the stretch/cover exact canvas), IN ADDITION to the `enc_pixels` pin at `videos.cpp:709-730`. The
vision tower is optional: a container converted WITHOUT it still renders keyframes pin-only (`video_driver.cpp`
tower guard now skips FIRST/LAST_FRAME; keyframes still require the VAE `encodes`). Host tests
`fl2va_keyframes_feed_the_tower_and_pin_the_output_ends`, `fl2va_without_a_tower_pins_only` (videos_test) and
`a_keyframe_completion_also_conditions_through_the_tower`, `a_keyframe_completion_needs_no_vision_tower`
(video_gen_test) cover both channels and both tower-present/absent paths. The earlier "no golden engine to
diff against" limit still bounds EXACT value-parity (→ #10/P6): the reference embeds `<Picture N>` inline in
its prompt prose while Radiance prepends the vision block before the prompt (the repo's PORT-REF2VA §3
convention, which the reference tokenizer also uses for the block itself); anchor PRESENCE is what this change
delivers. Chaining also still works independently via the ref_video slot0 path. Device qualitative check (does
the posterize drop) is the remaining validation.
**Endpoint parity re-confirmed at 512 (2026-10-19, post-fix).** Same method (frame-0/last-frame cosine vs the
resized anchor, 256² sampling space, RGB-mean-centred), on the fixed binary at 512²·12 s·25 step·seed 1234: