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

+17 -5
View File
@@ -345,7 +345,15 @@ int VideoDriver::submit(std::unique_ptr<VideoRequest> r, std::string* why) {
* pack lays those slots between the text and the target streams (RadVideoGenBatch::ref_tab).
* Every kind the declaration allows is consumed; the guard below is only about a container
* lacking its vision tower, which could encode nothing. */
if (!r->refs.empty() && max_enc_ == 0)
/* Reference media need the vision tower (their identity soft tokens). Endpoint keyframes do not:
* they condition through the VAE-latent pin, so a container converted without its tower can still
* render them -- the server simply lays no `media` for them and the pin-only path runs. (Keyframes
* still need the VAE encoders, checked just below.) */
bool has_ref_media = false;
for (const VideoRefMedia& m : r->refs)
if (m.kind != VideoRefMedia::FIRST_FRAME && m.kind != VideoRefMedia::LAST_FRAME)
has_ref_media = true;
if (has_ref_media && max_enc_ == 0)
return no("this container was converted without its vision tower, so no request can "
"carry reference media");
/* A reference video, soundtrack or standalone audio reaches the model only through the VAE
@@ -358,12 +366,16 @@ int VideoDriver::submit(std::unique_ptr<VideoRequest> r, std::string* why) {
if (m.kind != VideoRefMedia::IMAGE)
return no("'" + m.name + "' is a reference " +
(m.kind == VideoRefMedia::VIDEO ? "video"
: m.kind == VideoRefMedia::VIDEO_AUDIO ? "soundtrack" : "audio") +
: m.kind == VideoRefMedia::VIDEO_AUDIO ? "soundtrack"
: m.kind == VideoRefMedia::FIRST_FRAME ||
m.kind == VideoRefMedia::LAST_FRAME ? "keyframe" : "audio") +
", but this container was converted without its VAE encoders, so nothing "
"can condition on it");
/* Only reference images add language-model soft-token rows, so only they need processed media.
* A reference video or audio reaches the model purely through the VAE encode rows the pack lays
* from the reference table, so a request of those alone carries no `media` and needs none. */
/* Only pictures (reference images and endpoint keyframes) add language-model soft-token rows, so
* only they need processed media. A reference video or audio reaches the model purely through the
* VAE encode rows the pack lays from the reference table, so a request of those alone carries no
* `media` and needs none. A keyframe with no tower also carries no `media` — that is the deliberate
* pin-only fallback, not a silent weakening (its VAE pin still conditions the DiT). */
bool has_image = false;
for (const VideoRefMedia& m : r->refs)
if (m.kind == VideoRefMedia::IMAGE) has_image = true;