diff --git a/abi/rad_builder.h b/abi/rad_builder.h index 870a75f3..02b57052 100644 --- a/abi/rad_builder.h +++ b/abi/rad_builder.h @@ -1412,10 +1412,12 @@ typedef struct RadVideoGenDecl { int64_t dbg_dit_hn_bytes; rad_buf dbg_dit_nout; /* [1, 3 * 2 * D] f32: this step's norm_out shift/scale row */ int64_t dbg_dit_nout_bytes; - /* #63 video-decoder value parity: f32 PERSIST windows of the ViT decoder's chain, read with the - * same R4D_DIT_SEL as the DiT dump (the decoder has no step; chunk 0 of one request carries it). - * The decoder is the one stage never parity-harnessed, and a pinned keyframe frame renders fried, - * which convicts decode, not denoise. blk/n/pix are PERSIST f32 twins of bf16 sources (the + /* #63 video-decoder value parity: f32 PERSIST windows of the video decoder's chain, read with + * the same R4D_DIT_SEL as the DiT dump (the decoder has no step; chunk 0 of one request carries + * it). The decoder was the one stage never parity-harnessed; this dump closes that gap. (An + * early fried-output hunt suspected decode from the keyframe pins -- the true culprit was the + * velocity head's modulation table, since fixed; the harness stands as the parity check.) + * blk/n/pix are PERSIST f32 twins of bf16 sources (the * widening cast); lat/x0 shadow f32 sources through the f32-bf16 narrowing cast (the only cast * row that reads f32), so those two files are raw bf16 (read as uint16, viewed as bfloat16) -- * a few mantissa bits lost, far under the bf16 chain's own noise. lat is the latent window diff --git a/core/gen/video.h b/core/gen/video.h index b6872f56..0a5f4001 100644 --- a/core/gen/video.h +++ b/core/gen/video.h @@ -93,8 +93,9 @@ struct VideoRefMedia { * vae.encode): the VAE-latent pin above, AND -- when the container carries a vision tower -- a * anchor block through the tower (its `data` bytes are prepared as media and its * soft tokens interleaved into the text conditioning). That anchor is the semantic counterpart - * to the low-level VAE pin; without it the DiT reconstructs the frame from pixels alone and - * over-saturates. `index` is the keyframe's ordinal (first = 1, last = 2), not a + * to the low-level VAE pin; without it the DiT reconstructs the frame from pixels alone -- a + * weaker conditioning than the reference's two-channel feed. `index` is the keyframe's + * ordinal (first = 1, last = 2), not a * per-kind count, so the block is labelled the way the source workflow names it. On a towerless * container the anchor channel is absent and the pin-only path runs unchanged. */ enum Kind : int32_t { IMAGE = 0, VIDEO = 1, VIDEO_AUDIO = 2, AUDIO = 3, FIRST_FRAME = 4, LAST_FRAME = 5 }; diff --git a/data/recipes/minimax-h3-w8a8.recipe b/data/recipes/minimax-h3-w8a8.recipe index 06db1a16..f0699190 100644 --- a/data/recipes/minimax-h3-w8a8.recipe +++ b/data/recipes/minimax-h3-w8a8.recipe @@ -2,13 +2,17 @@ # # This is minimax-h3-fp8.recipe with the DiT's four per-token linears (qkv, output, gate_up, down) # quantised to symmetric int8 on a per-row 128-column grid instead of E4M3, and read by the w8a8 -# GEMMs. The point is the denoiser's OUTPUT QUALITY: E4M3 has three mantissa bits and clamps the -# activation at 448, so the fp8a8 denoiser banded smooth gradients (a watercolour look) and clipped -# highlights (oversaturated colour). int8 is 126 uniform levels a group with no clamp -- far finer on -# the smooth per-token activations that carry detail -- at the same one byte a weight, so the -# container's footprint and the served memory are unchanged. The text encoder, the token refiner and -# the modulation (ada) projections stay E4M3: they are read once or a few times a step, not on every -# token, so they are not the fidelity limit. Serve with the minimaxh3 plugin's W8A8 DiT path. +# GEMMs. The point is the denoiser's OUTPUT FIDELITY: E4M3 has three mantissa bits and clamps the +# activation at 448, while int8 is 126 uniform levels a group with no clamp -- far finer on the +# smooth per-token activations that carry detail -- at the same one byte a weight, so the +# container's footprint and the served memory are unchanged. The uniform int8 grid is also the +# closest radiance gets to the int8-convrot releases the community's H3 finetunes ship in, so +# W8A8 is the fidelity pick on that lineage. (Color and contrast artifacts once blamed on the +# fp8 denoiser were NOT its quantisation: they were a modulation-table staging bug in the +# velocity head, since fixed -- no quant was ever seen to band once that was repaired.) The text +# encoder, the token refiner and the modulation (ada) projections stay E4M3: they are read once +# or a few times a step, not on every token, so they are not the fidelity limit. Serve with the +# minimaxh3 plugin's W8A8 DiT path. # # rad-convert --recipe data/recipes/minimax-h3-w8a8.recipe \ # -o minimax-h3-w8a8.rad diff --git a/docs/ARCHITECTURES.md b/docs/ARCHITECTURES.md index bbb802b0..2720c900 100644 --- a/docs/ARCHITECTURES.md +++ b/docs/ARCHITECTURES.md @@ -30,7 +30,7 @@ plugin claims. | `arch/minimaxmusic3` | `minimaxmusic3` | *(empty)* | MiniMax-Music3, songs from a description and lyrics: a Qwen3-8B frame model, a depth decoder, a flow-matching DiT and a DAC vocoder, from the diffusers pipeline directory, bf16 | | `arch/breeze` | `breeze` | *(empty)* | Breeze-TTS-2, speech from text and a description of the voice: a T5Gemma 2 text encoder, a Qwen3 backbone with a 16-codebook depth decoder and the Qwen3-TTS 12 Hz codec, from the release directory, bf16, one card | | `arch/fishomni` | `fishomni` | `bsgemm-moe` | Fish Audio drama-3, speech from text with speaker tags and inline direction, its voices cloned from reference clips: the Qwen3.5-35B-A3B backbone with its routed experts block fp8 at f32 scales and everything else bf16, a 13-layer codebook tower over the backbone's full-attention cache, and Fish S2's modified DAC, encoder and decoder (`codec.pth`, read as data); from the release directory, two cards | -| `arch/minimaxh3` | `minimaxh3` | *(empty)* | MiniMax-H3, a video with its stereo soundtrack from text: Qwen3-VL-32B's language model as the text encoder, a 33B single-stream diffusion transformer, a tiled ViT video decoder and a BigVGAN audio decoder, from the diffusers pipeline directory; linears block fp8 (`data/recipes/minimax-h3-fp8.recipe`) | +| `arch/minimaxh3` | `minimaxh3` | *(empty)* | MiniMax-H3, a video with its stereo soundtrack from text, between keyframes or from reference media: Qwen3-VL-32B's language model as the text encoder, a 33B single-stream diffusion transformer, a tiled ViT video decoder and a BigVGAN audio decoder, from the diffusers pipeline directory; linears block fp8 (`data/recipes/minimax-h3-fp8.recipe`) | | `arch/ltx2` | `ltx2` | *(empty)* | LTX-2.5 (base and distilled), a video with its stereo soundtrack from text or from text and a first frame: Gemma 4's language model and two text connectors, the duration head, a dual-stream audio-video DiT with four-way guidance, the causal video VAE (tiled past the default canvas) or the diffusion decoder, the audio VAE with a BigVGAN vocoder and bandwidth extension, the x2 latent upsampler; bf16 or block fp8, one card | The traps below are readings that are wrong without any error: the model produces fluent output. @@ -1809,7 +1809,7 @@ denoising step of one request's packed sequence, ADECODE plays the soundtrack, V one temporal chunk of frames. A request is a lane; two hold state at once (one denoising, one conditioned and waiting). It is served on `/v1/videos` ([GUIDE §5.16](GUIDE.md)), block fp8 on two cards with `--vision-tower-placement ram`. The checkpoint is the diffusers pipeline directory, -read as one; only workflow t2va is served. +read as one; the workflows t2va, i2va, l2va, fl2va and ref2va are served. ``` text Qwen3-VL-32B's language model: 64 layers of 5120 (64 q / 8 kv heads of 128, ff 25600, diff --git a/docs/GUIDE.md b/docs/GUIDE.md index c5546bb1..f6454e64 100644 --- a/docs/GUIDE.md +++ b/docs/GUIDE.md @@ -2971,8 +2971,18 @@ curl -s http://localhost:8000/v1/videos/video_.../content -o fox.mp4 These reshape the noise schedule the driver stages — they reach the kernels as sigmas, not as a new batch field — and never change the model's trained look, which is fixed by its VAE decode and quantisation, not the schedule. -- Only text is read: `input_reference` and non-empty `conditions` are refused, as is a `task` - other than `t2va`. Fields are JSON or a multipart form (OpenAI's clients send the form). +- **Conditioning.** A text-only request runs `t2va`. A container that carries the VAE encoders also + serves **keyframe completion**: a `first_frame` part (I2VA), a `last_frame` part (L2VA) or both + (FL2VA, generative completion between two pinned endpoint frames — at most one part of each). A + container that carries the encoders and the token refiner serves **REF2VA**: `ref_image_1 … + ref_image_9` pictures, `ref_video_1 … ref_video_3` clips each with its `ref_video_audio_N` + soundtrack, and `ref_audio_1 … ref_audio_3`. Keyframes and reference media are mutually + exclusive: a request either completes between pinned frames or conditions on references. The + media are multipart file parts (`curl -F first_frame=@start.png -F prompt=...`); a named `task` + (`t2va`/`i2va`/`l2va`/`fl2va`/`ref2va`) is optional and inferred from the parts, and a named + task missing its media is refused. `input_reference` and non-empty `conditions` are refused. + Fields are JSON or a multipart form (OpenAI's clients send the form; a request with media + parts is multipart by necessity). **FastH3.** FastVideo's FastH3 8-Step V2 (`FastVideo/FastVideo-FastH3-8-Step-V2`) is the same model distilled to eight steps with video sparse attention; it is converted with the same recipe, its text diff --git a/docs/NOTE-REF2VA.md b/docs/NOTE-REF2VA.md index b34109fa..08dcba59 100644 --- a/docs/NOTE-REF2VA.md +++ b/docs/NOTE-REF2VA.md @@ -39,7 +39,8 @@ sibling notes (`NOTE-P3-PACK.md`, `NOTE-P2-ENCODE.md`); this one is about capabi content-live, not collapsed. - **Audio-encoder numeric value-parity — measured and now matched.** Against a device-input-anchored fp32 reference, the audio latent used to sit at ~0.25–0.39× the reference spread. The cause was a - **pre_block `norm1`/`norm3` swap** (the projection branch read the wrong LayerNorm — see #14 below). After + **pre_block `norm1`/`norm3` swap** (the projection branch read the wrong LayerNorm — see the + video-encoder parity section below). After the fix the pre_block output and the final latent both track the reference (ratio ~0.97 / ~0.93, R² 0.98– 0.99, no remaining systematic gain); the ~0.10 residual-after-affine is bounded by low-precision execution (a full-bf16 reference itself moves 55% from its fp32). **The video / image encoder is a @@ -48,8 +49,9 @@ sibling notes (`NOTE-P3-PACK.md`, `NOTE-P2-ENCODE.md`); this one is about capabi is the previous clip's tail fed back as a `ref_video_N` (+ `ref_video_audio_N`), not a special engine mode. Two requests reproduce it: generate clip A, cut its tail, request clip B with `ref_video_1` = the tail. A fixed-seed control confirms the tail conditions B (with-tail vs without-tail differ). The - pack's exact keyframe-pin rows (`kR2VCond`) remain unimplemented — a separate mechanism for FL2VA-style - start/end-frame pinning, which FL2VA itself reaches with two image references (see point 3). + pack's exact keyframe-pin rows (`kR2VCond`) are a **distinct mechanism, and they have since + shipped**: I2VA/L2VA/FL2VA arrive as `first_frame`/`last_frame` parts whose pins are + device-verified (see the keyframe-pin section below), separate from this chaining path. - **The modulation-cell merge** that lifts the count ceiling (next section). ## The reference-count ceiling: how it went from ≤5 to ≤9 @@ -142,8 +144,8 @@ as point 6 / point 4. Nothing here claims to match ComfyUI's timings. merge removes the *table-per-reference* growth, not the *per-reference token* cost. Raise `--max-model-len`, or use smaller / fewer references. -3. **Continuity chaining works through the reference paths; the bespoke keyframe-pin mechanism is - separate and still pending.** The DaSiWa "3-second lead-in" is *not* a special engine mode: per the +3. **Continuity chaining works through the reference paths; the keyframe-pin mechanism ships + separately.** The DaSiWa "3-second lead-in" is *not* a special engine mode: per the source-verified brief (`docs/NOTE-CONTINUITY.md` §1) the director feeds the previous keeper clip's last ~3 s back as a **video + audio reference** (`media_mode: video_audio`, `slot 0`, `start: 0`) — *conditioning media, not content*; the next scene simply continues from that tail and never replays @@ -154,18 +156,18 @@ as point 6 / point 4. Nothing here claims to match ComfyUI's timings. engine additionally regenerates a leading overlap window as target rows and then trims it; here the reference rows are fixed conditioning held outside the sampler and every output frame is new (no overlap to trim), so the net "continues from the tail" semantics match but the seam may differ - subtly. What is *not* wired is the **engine consumption** of the pack's *keyframe* rows - (`kR2VCond` / `kR2VCondAudio`) — a distinct exact-pin mechanism for FL2VA-style start/end-frame - conditioning (which FL2VA itself reaches with two image references — see §2 of the continuity brief). - **The pack layer is done and reference-verified**: `ref2va_build` emits `kR2VCond` / `kR2VCondAudio` + subtly. The pack's *keyframe* rows (`kR2VCond` / `kR2VCondAudio`) are a **distinct exact-pin + mechanism, and it ships**: I2VA/L2VA/FL2VA reach start/end-frame conditioning through the + `first_frame`/`last_frame` parts, not through reference images (see the keyframe-pin section + below for the shipped mechanism). + **The pack layer was reference-verified first**: `ref2va_build` emits `kR2VCond` / `kR2VCondAudio` segments, and the golden `fl2va` (two keyframes) and `chain` (one keyframe) cases assert their segment order, sizes, positions, `img_pos`/`audio_pos` and modulation rows **bit-exact** against the - reference (they re-baked byte-identical here). What remains is three engine pieces, none touching - the sampler (cond rows sit ahead of the targets, so the sampler ignores them by construction): the - driver never populates a keyframe row (its keyframe count stays 0 today), `step_dit` scatters the - reference rows but not the cond rows, and there is no continuation-tail *input* to persist a prior - clip's tail. Seam frame-equality is the wrong metric to gate on: the brief states it is imperfect - **by construction**, because the first new frame is the tail's temporal *successor*, not a replay of + reference (they re-baked byte-identical here). The engine pieces the first pass left open — the + driver populating a keyframe row, `step_dit` scattering the cond rows — landed with that section; + a prior clip's tail needs no bespoke persistence since it rides in as a `ref_video_N`. Seam + frame-equality is the wrong metric to gate on: the brief states it is imperfect **by + construction**, because the first new frame is the tail's temporal *successor*, not a replay of its last frame. 4. **Reference videos and audios steer the output — through the VAEs, not the text encoder.** A @@ -382,7 +384,7 @@ as point 6 / point 4. Nothing here claims to match ComfyUI's timings. (video-ref determinism + content-control), `chain.sh` (tail-as-`ref_video` chaining), `fullshape.sh` (this max-shape control) under the build tree. -## #14 video-encoder value-parity — **RESOLVED** (2026-10-19): shortcut-after-norm1 ordering bug +## Video-encoder value-parity — **RESOLVED** (2026-10-19): shortcut-after-norm1 ordering bug The video/image VAE encoder was device-live and content-sensitive but its folded latent sat at roughly **0.49× the reference's scale** with a large structural residual. Root cause found and **fixed**: in @@ -430,7 +432,7 @@ but confined to one op-order, and the frame-0 bisection made it golden-verifiabl shadows + the full tail now read ratio ~1.0 against the reference. Strict end-to-end numeric parity of the whole pipeline (benchmarks, multi-frame) remains #10/P6. #20 stays closed (norm already per-frame). -## #10 / P6 — Radiance TP2 engine-throughput + ComfyUI comparison (2026-10-19) +## Engine-throughput vs ComfyUI: Radiance TP2 wall-clock and card-seconds (2026-10-19) FFmpeg is now present on this box (the §6.1 "no libav → encoding_failed at t≈0" blocker is gone — clips mux to mp4 and generate to completion). The encoder **value-parity** half of P6 is done (both encoders at the @@ -519,7 +521,7 @@ before any VRAM was claimed (cards stayed at 61 MB), so no benchmark rows were p `--max-num-batched-tokens` might coax it up, but that changes the batch config and is no longer apples-to-apples with the 215 W baseline. Log: `build/tmp/ex10/server_vemb.log`. -## #8 kR2VCond keyframe-pin (FL2VA) — disposition: SHIPPED + device-verified (2026-10-19) +## The kR2VCond keyframe-pin (FL2VA) — SHIPPED + device-verified (2026-10-19) **Supersedes the earlier "left optional, not wired" disposition.** The user elevated FL2VA from optional to a **hard requirement**, so the keyframe path was implemented and shipped (commit `98ecbeb`, placeholder author, @@ -556,10 +558,11 @@ 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). -**Was a remaining fidelity gap; now CLOSED (2026-10-21, task #52).** The pins-only path used to **skip +**Was a remaining fidelity gap; now CLOSED (2026-10-21).** 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 +so a prompt that *contradicts* the pinned image could let the text win. (The over-saturated/posterized +look these renders also showed was a **separate** bug — the velocity head's modulation-table staging, +since fixed; the missing anchors were not its root cause.) This is now shipped: an endpoint keyframe is fed the DiT on BOTH channels the reference uses — the VAE-latent pin AND a `` vision-tower anchor block interleaved into the text conditioning. Mechanism: `videos.cpp` now runs the media/`` block for keyframe requests (first_frame→``, last_frame→``), @@ -605,7 +608,7 @@ step·seed 1234, `first`=standing, `last`=riding; `index.tsv` records status/wal Each has a matching `.thumb.webp`. These are SEQUENCE clips (single generated run), not loops. -## cont.20 (2026-10-21) — per-request `shift`, and the "fried" look localized to decode/quant +## 2026-10-21 — per-request `shift`, and the "fried" look hunt — **resolved later: the velocity-head modulation table, NOT decode/quant** The full-resolution frames of a workflow-prompt review batch showed a **blown-highlight / crushed-black "watercolor" look** (the user's "fried"). Measured with HSV + Laplacian-variance across time on native-512 @@ -618,7 +621,8 @@ frames, versus the reference clips (same `dasiwaHybridV4` finetune, via ComfyUI) | Radiance snow T2VA (old ex10) | 13.7 | 51 | Key facts established by this pass: -1. **It is in the text-only T2VA control too** — so it is NOT the keyframe/vision-tower path (#52), and +1. **It is in the text-only T2VA control too** — so it is NOT the keyframe/vision-tower path (the + TE-anchor work below), and the old ex10 T2VA has the same clip% → **not a regression**. The earlier "T2VA is clean" read was an artifact of judging 256² downscaled strips; at native res it was never clean. 2. **Sampler is not the lever**: same-seed euler vs res_multistep gives clip 53–61% vs 56–65% — no @@ -628,9 +632,13 @@ Key facts established by this pass: lever either. CFG is not implemented (single conditioning pass = CFG 1), which already matches the reference's BasicGuider scale-1. 4. With sampler, shift and CFG all matched, Radiance still blows ~55% where the reference blows ~4.5% on - the same content ⇒ the gap is **downstream of the schedule: the video VAE decode (scale/shift factor - value parity) and/or the DiT int8 quant**, i.e. #37/#44/#45 — the deep fidelity work, needing the stock - / golden-latent box (#44). Not a schedule, keyframe, downscale or source-compression issue. + the same content ⇒ the gap is downstream of the schedule. *(This pass localised it to "the video VAE + decode and/or the DiT int8 quant" — **that localisation was wrong.** The cause was the velocity head's + modulation table: the norm_out shift/scale row was staged at the staging call's narrow pitch instead of + the declared row width, so the table arrived all zeros at t>0 and both heads ran un-modulated. Two + lines fixed it and the fried look vanished at every quant; no quantisation was ever implicated, and + the decode-vs-denoise framing of this item is kept only as measured history.)* What this pass did + establish stands: not a schedule, sampler, keyframe, downscale or source-compression issue. **Shipped anyway** (the user asked for it, and it is correct and useful for other checkpoints/workflows): `shift` (video) and `audio_shift` (soundtrack) are now per-request `/v1/videos` fields, `(0,100]`, each @@ -638,7 +646,7 @@ defaulting to the model's trained shift; echoed in the video object and advertis `video_shift`/`video_audio_shift`. Implementation is **ABI-invisible**: `VideoRequest` carries the two doubles, `video_schedule()` re-shifts that stream's sigma grid, and the shifted sigmas are staged through `RadVideoGenBatch::sched` — the plugin reads only sigmas/timesteps, never a shift scalar, so -`RAD_ABI_VERSION` stays 24 and no plugin rebuilds. Files: `core/gen/video.h`, `core/gen/video_driver.cpp`, +`RAD_ABI_VERSION` stayed 24 then (it is 27 now) and no plugin rebuilt. Files: `core/gen/video.h`, `core/gen/video_driver.cpp`, `core/server/iface.h` (`VideoGenInfo` shift), `core/engine.cpp` (populate), `core/server/videos.cpp` (allowlist/parse/echo/caps); tests in `videos_test.cpp`, `video_gen_test.cpp` (host, green). Device: `shift=4` accepted+echoed+renders. diff --git a/docs/PORT-REF2VA.md b/docs/PORT-REF2VA.md deleted file mode 100644 index 20ec04b9..00000000 --- a/docs/PORT-REF2VA.md +++ /dev/null @@ -1,1461 +0,0 @@ -# PORT-REF2VA — reference-media conditioning for MiniMax-H3 (working brief, community PR) - -> Scratch planning doc (untracked). Started 2026-10-18 from a ComfyUI-side analysis session -> (`/home/main/AI/ComfyUI`). Owner: community contributor on dual Radeon AI PRO R9700 -> (RDNA4, gfx1201, 32 GB each). Per the author's call for community PRs, this is the -> implement/test/PR plan. Nothing here is committed yet. - -## 1. Goal - -Make Radiance's MiniMax-H3 path serve **Ref2VA**: the full official conditioning envelope — -up to **9 reference images, 3 reference videos (each optionally with its own soundtrack), -3 standalone reference audios** — prompt-addressable as `` / `