Archived
ref2va: wire video and audio reference conditioning end-to-end (all three ref kinds live on device)
Follows the merged-cell pin (c725a2d). That commit proved reference IMAGE
conditioning consumed on device; reference VIDEO and AUDIO were plumbed
through the pack and step but still refused at submit — only their decode
and encoder-enqueue were missing. This lands them.
Server (videos.cpp): `task ref2va` now decodes `ref_video_N` and
`ref_audio_N` (and a video's paired `ref_video_audio_N`) into encoder form
via the mm encoders and enqueues them as Vencode/Aencode passes, instead of
the old image-only decode loop that rejected them. A soundtrack is folded
into its video's row (the `audio` word), matching how the pack lays that
pair. Caps stay <=9 images / <=3 videos / <=3 audios.
Driver (video_driver.{h,cpp}): the encode queue `enc_q` now carries VIDEO,
VAUDIO and AUDIO items in presentation order; `ref_tab` stamps each
reference's latent counts straight from the encoder geometry (rad_arch_encode_geom:
a video's frame count eg[24]=its total latent frames, its soundtrack's eg[12]),
so the pack's ref segments are sized by the encoder, not hand arithmetic.
processor.{h,cpp}/iface.h/adapters.h gained the media decode entry points.
Arch (minimaxh3.cpp): step_dit scatters reference rows into the packed step —
picture/video via op_vin from b_evc, audio via op_ain from b_enca, at each
segment start, targets last. A bounds audit confirms the scatter reads exactly
the slot region the encode pass wrote this job (eg[24]=lat = the pass's
written row count = the pack's segment size; no stale-neighbor read).
DEVICE-VERIFIED on dual gfx1201 / TP2, warm server, fixed seed, comparing
DECODED stream md5 (never raw mp4 bytes — the muxer stamps a field): all three
reference kinds are DETERMINISTIC (a rerun of one reference is bit-identical,
including raw bytes) AND CONTENT-LIVE (a different reference at the same seed
gives different output video AND audio). Image (content tokens), audio
(tone/noise/880 distinct) and video (refv_a vs refv_b: both streams differ)
each steered the generation. An earlier "the video step is nondeterministic"
note was a measurement artifact — it compared raw mp4 bytes and straddled the
one-off cold-start outlier; the warm decoded-stream probe is bit-reproducible.
Debug scaffolding (R4D_ENC_DEBUG, 4 trailing RadVideoGenDecl fields + a pinned
driver slab + an FNV digest in done()) is entangled in these files. It is
env-gated and zero-touch when unset; STRIP IT BEFORE ANY PR.
tests: video_gen_test/videos_test/server_fakes cover the video/audio enqueue
paths; abi_layout_rows adds the new trailing rows; ref_audio_sensitivity.py is
a standalone host golden harness (audio reference separates 4/4), not a ctest
case. Host tier green (only mm_test's pre-existing webp demuxer gap fails, and
the GPU card/kbench tests fail solely on VRAM contention with a live server).
NOTE-REF2VA.md updated: continuity tail (#8) remains unimplemented; strict
numeric parity vs the ComfyUI CPU reference remains open.
PLACEHOLDER AUTHOR — repo has no git identity; re-author before any push.
DO NOT PUSH this branch.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
72624973ad
commit
658f7b7214
16 files changed
+1055
-162
No files matched your search
@@ -437,6 +437,81 @@ TEST(ref2va_pictures_are_presented_before_the_prompt) {
|
||||
CHECK(g.tokens == want);
|
||||
}
|
||||
|
||||
/* A generator that carries its VAE encoders (encodes 1): the reference parts are not merely passed
|
||||
* as bytes — the picture, the video and both audios are decoded into the encoder's own form, the
|
||||
* audio's mono tone spread across the encoder's channels — and every reference is spoken before the
|
||||
* prompt in the reference's order: the picture's label and run, the soundtrack's `<Audio j>` right
|
||||
* before its video's `<Video k>`, then the standalone `<Audio j>`. This is the server half; the
|
||||
* driver half (padding, slots, the pack table) is tests/video_gen_test.cpp. */
|
||||
TEST(ref2va_videos_and_audios_are_encoded_and_spoken) {
|
||||
FakeMultimodal mm;
|
||||
mm.expand = { 900, 901 };
|
||||
mm.enc_frames = 5; mm.enc_side = 16; mm.enc_n = 850;
|
||||
FakeVideoGen gen;
|
||||
std::unique_ptr<Fixture> f(new Fixture(Fixture::Tweak{ [&](ServerOptions& o, Deps& d) {
|
||||
d.videos = &gen;
|
||||
d.mm = &mm;
|
||||
o.video_model = true;
|
||||
gen.inf.encodes = 1;
|
||||
gen.inf.enc_ratio = 16;
|
||||
gen.inf.max_enc_side = 256;
|
||||
gen.inf.max_enc_frames = 289;
|
||||
gen.inf.max_enc_samples = 500000;
|
||||
} }));
|
||||
HttpRequest q;
|
||||
q.method = "POST";
|
||||
q.path = "/v1/videos";
|
||||
q.form = { FormPart{ "prompt", "", "", "fox" },
|
||||
FormPart{ "size", "", "", "256x256" },
|
||||
FormPart{ "task", "", "", "ref2va" },
|
||||
FormPart{ "ref_image_1", "a.png", "image/png", "PA" },
|
||||
FormPart{ "ref_video_1", "v.mp4", "video/mp4", "ftyp" },
|
||||
FormPart{ "ref_video_audio_1", "s.wav", "audio/wav", "RIFF" },
|
||||
FormPart{ "ref_audio_1", "b.mp3", "audio/mpeg", "ID3" } };
|
||||
HttpResponse r = f->srv->router().dispatch(q);
|
||||
REQUIRE_EQ(r.status, 200);
|
||||
|
||||
/* One image, one video and two audios (the video's soundtrack plus the standalone) reached the
|
||||
* encoder each belongs to. */
|
||||
CHECK_EQ(mm.n_ienc, 1);
|
||||
CHECK_EQ(mm.n_venc, 1);
|
||||
CHECK_EQ(mm.n_aenc, 2);
|
||||
|
||||
const gen::VideoRequest& g = gen.last();
|
||||
REQUIRE_EQ(g.refs.size(), (size_t)4); /* sorted (kind, index): image, video, video_audio, audio */
|
||||
/* The picture: one frame at the encoder grid, its pixels filled for the video VAE. */
|
||||
CHECK_EQ((int)g.refs[0].kind, (int)gen::VideoRefMedia::IMAGE);
|
||||
CHECK_EQ(g.refs[0].enc_frames, 1);
|
||||
CHECK_EQ(g.refs[0].enc_h, 16);
|
||||
CHECK_EQ(g.refs[0].enc_w, 16);
|
||||
CHECK_EQ(g.refs[0].enc_pixels.size(), (size_t)16 * 16 * 3);
|
||||
/* The video: the trimmed natural frame count, concatenated over the grid (the driver pads). */
|
||||
CHECK_EQ((int)g.refs[1].kind, (int)gen::VideoRefMedia::VIDEO);
|
||||
CHECK_EQ(g.refs[1].enc_frames, 5);
|
||||
CHECK_EQ(g.refs[1].enc_pixels.size(), (size_t)5 * 16 * 16 * 3);
|
||||
/* The soundtrack and the standalone audio: the mono tone spread across the generator's two
|
||||
* channels, enc_n the natural (unpadded) count. */
|
||||
CHECK_EQ((int)g.refs[2].kind, (int)gen::VideoRefMedia::VIDEO_AUDIO);
|
||||
CHECK_EQ(g.refs[2].enc_channels, 2);
|
||||
CHECK_EQ(g.refs[2].enc_n, (int64_t)850);
|
||||
CHECK_EQ(g.refs[2].enc_samples.size(), (size_t)2 * 850);
|
||||
CHECK_EQ(g.refs[2].enc_samples[0], g.refs[2].enc_samples[850]); /* both channels the same tone */
|
||||
CHECK_EQ((int)g.refs[3].kind, (int)gen::VideoRefMedia::AUDIO);
|
||||
CHECK_EQ(g.refs[3].enc_n, (int64_t)850);
|
||||
|
||||
/* The prompt speaks every reference before the words, in the reference's order. */
|
||||
std::vector<int32_t> want;
|
||||
auto chars = [&](const std::string& s) { for (unsigned char c : s) want.push_back((int32_t)c); };
|
||||
chars("<v>");
|
||||
chars("<Picture 1>: ");
|
||||
want.insert(want.end(), mm.expand.begin(), mm.expand.end());
|
||||
chars("<Audio 1>: ");
|
||||
chars("<Video 1>: ");
|
||||
chars("<Audio 2>: ");
|
||||
chars("fox");
|
||||
CHECK(g.tokens == want);
|
||||
}
|
||||
|
||||
/* Everything about the parts that cannot be right is refused naming the part (or `task` when
|
||||
* the media themselves are the question), before anything is queued. */
|
||||
TEST(ref2va_requests_are_refused_naming_the_part) {
|
||||
|
||||
Reference in new issue
Block a user