Skip to content

[Feature] MiniMax-H3: image / audio guides at a frame index, usable together with Ref2VA references #2386

Open

Description

@shiwano

Feature Summary

Let a MiniMax-H3 vid_gen request anchor image and audio guides at a frame index of the target video while also passing Ref2VA references, as ComfyUI's MiniMaxH3AddGuide node does.

Detailed Description

ComfyUI's video_minimax_h3_multiframe_reference template chains MiniMaxH3AddGuide after MiniMaxH3ReferenceToVideo (the plain video_minimax_h3_r2v template does not use guides). The template uses image guides only; the node also takes an audio input. One request can then carry all of:

  • reference images / videos / audios (<Picture N> in the prompt),
  • an image guide pinned to the first frame and another to the last frame,
  • an audio guide anchored at a frame, which the generated soundtrack and lip movement follow.

This is the "keyframe completion + reference generation" task, and the audio guide is how a pre-made dialogue track is lip-synced.

In sd.cpp (master, 532d2c1) these cannot be combined:

  1. Keyframes and references are mutually exclusive. src/pipeline/video.cpp rejects the request:
    https://github.com/leejet/stable-diffusion.cpp/blob/532d2c15c4/src/pipeline/video.cpp#L532-L535
    MiniMax-H3 keyframes and Ref2VA references cannot be used together
    
  2. A keyframe is only the first or the last frame (--init-img / --end-img); build_layout places it at one of those two positions.
  3. As far as I can tell from the source there is no audio guide: the MiniMax-H3 target audio latent is always created empty, --ref-audio / --ref-video-audio are references rather than anchors on the target timeline, and --audio is Wan2.2 S2V only.
    https://github.com/leejet/stable-diffusion.cpp/blob/532d2c15c4/src/pipeline/video.cpp#L525-L527

The restriction looks like a property of the layout code rather than of the model. ComfyUI's PackedLayout packs keyframes and references into the same sequence:
https://github.com/Comfy-Org/ComfyUI/blob/995456d018/comfy/ldm/minimax/model.py#L383-L427

  • the cursor first advances over every reference block's span, so the target timeline starts after the references;
  • each keyframe sits at cond_t = cursor + FRAME_RESCALE * resolved_frame_index on the target spatial grid;
  • a keyframe may carry a video latent, an audio latent, or both; the audio rows use the target audio w positions at the same cond_t, one unit per audio latent frame;
  • keyframe rows are condition rows (never denoised), like reference rows.

The node that fills this in:
https://github.com/Comfy-Org/ComfyUI/blob/995456d018/comfy_extras/nodes_minimax_h3.py#L182-L256

sd.cpp's build_layout has the same pieces in two separate branches, reference_blocks.empty() (keyframes) and the reference branch:
https://github.com/leejet/stable-diffusion.cpp/blob/532d2c15c4/src/model/diffusion/minimax_h3.hpp#L1116-L1198

A possible shape for the change:

  • build_layout: one path that emits keyframe condition rows at cursor_after_refs + FRAME_RESCALE * frame_index, then the reference blocks; add a condition-audio segment for a guide's audio latent.
  • video.cpp: drop the exclusivity check for MiniMax-H3; accept guides at an arbitrary frame index (a single image, or a 17k + 5 frame clip as the ComfyUI node allows); encode guide audio with the audio VAE encoder already used for --ref-audio.
  • CLI / sdcpp API: repeatable guide inputs with a frame index, e.g. --guide-image <path>@<frame> and --guide-audio <wav>@<frame>; --init-img / --end-img stay as shorthands for frame 0 and -1.

No change to weights or to the Qwen3-VL side should be needed: ComfyUI does not present guides to the text encoder, only references.

Alternatives you considered

  • Passing the first frame as a reference image instead of a keyframe: a reference has no position on the target timeline, so it cannot be pinned to the first or the last frame.
  • FL2VA with --init-img / --end-img and no references: loses the <Picture N> character and set references.
  • Neither covers anchoring an existing audio track.

Additional context

Use case: shots generated from a storyboard panel (pinned as the first and/or last frame), character reference images, and a pre-rendered dialogue stem the shot must lip-sync to. This is the one MiniMax-H3 workflow I cannot move from ComfyUI to sd.cpp.

I can test builds on an RTX 5090 (CUDA) against ComfyUI output for the same inputs.

Activity

  1. added
    enhancement
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions