feat(minimax-h3): invocations, denoise loop, and audio-video decode (PR 3/5) - #140
Open
lstein wants to merge 1 commit into
Open
feat(minimax-h3): invocations, denoise loop, and audio-video decode (PR 3/5)#140lstein wants to merge 1 commit into
lstein wants to merge 1 commit into
Conversation
Third PR of the MiniMax H3 stack: the six Prototype nodes and the first-party port of the FL2VA sampling machinery. Vendored (byte-faithful, imports rewritten): packing.py — the packed [text | keyframe conditions | audio | video] sequence geometry and the checkpoint constants (fp64 rotary grid, 17n+5 frame grid, keyframe noise-aug 0.999, posterior seed 42). First-party backend ports (from the diffusers modular blocks at the vendored commit): - sampling.py: denoise-state construction — one CPU-seeded generator, three draws in upstream order (keyframe -> video -> audio), two MiniMaxH3Schedulers (video shift 12.0, audio shift 3.0), per-step row-timestep plan with condition rows pinned at t=0.999. - denoise.py: one transformer forward per step over the packed rows; per-modality scheduler steps on generated rows only (anchors survive by construction); guidance-distilled, no CFG; InvokeAI cancellation and step-callback hooks. - text_conditioning.py: Qwen3-VL layer-50 unnormalized hidden state, "<Picture i>: " + vision-block keyframe presentation, LM head never runs. - keyframe_conditioning.py: spatial-only VAE encode, fp16 rounding before normalization, fixed seed-42 posterior sample. Nodes: model loader (6 submodels), text encoder (idle-GPU-offloadable, optional keyframe vision context), frame conditioning (clean rows; denoise node noise-augments them), denoise (joint video+audio latents out), latents-to-video (VAE decode + AAC stereo mux, tiled fallback, duration-trimmed WAV), latents-to-image (still/frame extraction). Plumbing: MiniMaxH3ConditioningInfo (embeds + text token tags travel together), serializer safe-globals, generation modes, grayscale latent-preview fallback (24ch/16x), H3 VAE working-memory estimator. Tests: packed-grid math, frame-count validation (5..345 window plus 5-frame still path), noise determinism and draw-order shifts, and the full loop on a micro-config CPU transformer (shapes, anchor preservation, callback count, cancellation, determinism). Full tests/app + tests/backend sweep green (2871 passed). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR 3 of the MiniMax H3 stack (on top of #139): the six generation nodes, the packed-row denoise loop, and audio+video decode. With this PR a hand-built graph in the Workflow Editor produces a playable MP4 with an AAC stereo soundtrack — no linear UI yet (that's PR 4).
Backend modules (
invokeai/backend/minimax_h3/)packing.py— vendored from diffusers PR #14355 @abc5e9bf71(packed-sequence geometry + checkpoint constants; byte-identical apart from import rewrites).sampling.py— denoise-state construction: packed layout (condition rows lead), twoMiniMaxH3Schedulers (video shift 12.0 / audio shift 3.0), one generator with the upstream draw order (keyframe → video → audio), frame-grid validation (num_frames % 17 == 5, 5–15 s window, plus exactly 5 frames as the still-image mode).denoise.py— the joint audio-video loop: one forward per step (guidance-distilled, no CFG), per-row timestep plans, keyframe rows pinned at t=0.999, condition rows never stepped.text_conditioning.py— Qwen3-VL-32B prompt encoding (unnormalized layer-50 hidden states; keyframes enter the vision context via the processor).keyframe_conditioning.py— keyframe VAE encoding (seed-42 posterior sample, fp16 rounding contract, stretch/cover canvas placement in packed order).Nodes (all
Prototype)minimax_h3_model_loader,minimax_h3_text_encoder(idle-GPU-offloadable),minimax_h3_frame_conditioning,minimax_h3_denoise,minimax_h3_latents_to_video(video VAE decode + audio VAE decode → WAV → AAC mux via PR 1'smake_mp4_writer),minimax_h3_latents_to_image(single-frame extraction = txt2img path).Plus plumbing:
MiniMaxH3ConditioningInfo(+ serializer safe-globals), fields/primitives/metadata generation modes, grayscale 24-channel latent preview fallback, H3 VAE working-memory estimator.Deliberate divergences from upstream
num_framesvalues are rejected, not rounded (InvokeAI validator convention). Effective max is 345 frames = 14.375 s.step_callback.py).Adversarial review fixes (already in)
enable_tiling()/disable_tiling()on the shared cached VAE — the H3 VAE tiles by default and the released frames are the blended-tile ones; toggling would have silently changed every later encode/decode of the cached instance.MiniMaxH3ConditioningInfo) must match the frame-conditioning input.stepsisge=2(the scheduler's contract; N grid points = N−1 model evaluations).Testing
tests/backend/minimax_h3/: grid math, draw-order determinism, full denoise loop on a micro-config CPU transformer (anchor preservation, cancellation, callback counts).tests/app+tests/backend: 2871 passed / 0 failures; post-review-fix sweep oftests/backend+tests/app/util: 1712 passed.ruffclean,pnpm lint:tscgreen,openapi.json/schema.tsregenerated.🤖 Generated with Claude Code