Update h3_split_blocks.py
Browse files11 unmodified lines1213141516151718192021222324252324262728292830303132333412 unmodified lines47484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361375313813914014114 unmodified lines1561571587475761591601611621631649 unmodified lines1741751769217717817918018118218318418518618718848 unmodified lines23723823914724024124224324424524624724811 unmodified linesframe count is aligned to `17 * n + 5` before the call, since that arithmetic lives on the denoising side of the cut."""
import torch
from diffusers.modular_pipelines.minimax_h3.before_encoder import MiniMaxH3Ref2VASetupStepfrom diffusers.modular_pipelines.minimax_h3.before_encoder import MiniMaxH3ResizeStep, MiniMaxH3Ref2VASetupStepfrom diffusers.modular_pipelines.minimax_h3.decoders import MiniMaxH3AfterDenoiseStepfrom diffusers.modular_pipelines.minimax_h3.encoders import ( MiniMaxH3KeyframeVaeEncoderStep, MiniMaxH3Ref2VAReferenceEncoderStep, MiniMaxH3Ref2VATextEncoderStep, MiniMaxH3TextEncoderStep,)from diffusers.modular_pipelines.minimax_h3.modular_blocks_minimax_h3 import ( MiniMaxH3AutoKeyframeVaeEncoderStep, MiniMaxH3AutoResizeStep, MiniMaxH3CoreDenoiseStep, MiniMaxH3DecodeStep, MiniMaxH3FL2VACoreDenoiseStep, MiniMaxH3Ref2VACoreDenoiseStep, _generation_outputs,)from diffusers.modular_pipelines.modular_pipeline import SequentialPipelineBlocksfrom diffusers.modular_pipelines.modular_pipeline import ConditionalPipelineBlocks, SequentialPipelineBlocksfrom diffusers.modular_pipelines.modular_pipeline_utils import OutputParam
12 unmodified lines ]
class MiniMaxH3SplitBeforeEncodeStep(ConditionalPipelineBlocks): """Media preparation block for the split deployment's `t2va` / `fl2va` half — no `ref2va` branch.
Narrower than main's own `MiniMaxH3AutoBeforeEncodeStep`, the same way `MiniMaxH3A2VAutoBeforeEncodeStep` is in the audio-conditioned Space: the upstream auto wrapper's `ref2va` branch declares `MiniMaxH3Ref2VASetupStep`, which this half never needs — `MiniMaxH3Ref2VAConditionerBlocks` already owns that, on its own `transformer_ref`-side classes. """
model_name = "minimax-h3" block_classes = [MiniMaxH3ResizeStep] block_names = ["keyframes"] block_trigger_inputs = ["image", "last_image"] default_block_name = None
def select_block(self, **kwargs) -> str | None: if kwargs.get("image") is not None or kwargs.get("last_image") is not None: return "keyframes" return None
@property def description(self): return ( "Media preparation block.\n" " - `MiniMaxH3ResizeStep` runs when a keyframe is provided (`fl2va`), putting it onto the target " "canvas.\n" " - a text-only request (`t2va`) skips this block, and the layout step falls back to MiniMax-H3's own " "16:9 canvas." )
class MiniMaxH3SplitVaeEncoderStep(ConditionalPipelineBlocks): """VAE encoder block for the split deployment's `t2va` / `fl2va` half — no `ref2va` branch, for the same reason `MiniMaxH3SplitBeforeEncodeStep` has none."""
model_name = "minimax-h3" block_classes = [MiniMaxH3KeyframeVaeEncoderStep] block_names = ["keyframes"] block_trigger_inputs = ["image", "last_image"] default_block_name = None
def select_block(self, **kwargs) -> str | None: if kwargs.get("image") is not None or kwargs.get("last_image") is not None: return "keyframes" return None
@property def description(self): return ( "VAE encoder block.\n" " - `MiniMaxH3KeyframeVaeEncoderStep` runs when a keyframe is provided (`fl2va`).\n" " - a text-only request (`t2va`) skips this block." )
class MiniMaxH3SplitDenoiseStep(ConditionalPipelineBlocks): """Denoise block for the split deployment's `t2va` / `fl2va` half.
`MiniMaxH3CoreDenoiseStep` is `t2va`-only as of the diffusers 0.40.0 refactor (it opens with `MiniMaxH3NoKeyframeAnchorsStep`); keyframe-anchored generation moved to the separate `MiniMaxH3FL2VACoreDenoiseStep`. This selects between them the same way `MiniMaxH3A2VAutoDenoiseStep` selects between its own audio-conditioned pair — no `ref2va` branch, since that would declare `transformer_ref`, the partition this half must never load. """
model_name = "minimax-h3" block_classes = [MiniMaxH3FL2VACoreDenoiseStep, MiniMaxH3CoreDenoiseStep] block_names = ["fl2va", "t2va"] block_trigger_inputs = ["image", "last_image"] default_block_name = "t2va"
def select_block(self, **kwargs) -> str | None: if kwargs.get("image") is not None or kwargs.get("last_image") is not None: return "fl2va" return None
@property def description(self): return ( "Denoise block.\n" " - the `fl2va` core runs when a keyframe is provided, against the `transformer` partition.\n" " - the `t2va` core runs otherwise, against the same partition." )
class MiniMaxH3ConditionerBlocks(SequentialPipelineBlocks): """The conditioner half of a split MiniMax-H3: the keyframes on the canvas plus the Qwen3-VL read at layer 50."""
model_name = "minimax-h3" block_classes = [MiniMaxH3AutoResizeStep, MiniMaxH3TextEncoderStep] block_classes = [MiniMaxH3SplitBeforeEncodeStep, MiniMaxH3TextEncoderStep] block_names = ["resize", "text_encoder"]
@property14 unmodified lines
model_name = "minimax-h3" block_classes = [ MiniMaxH3AutoResizeStep, MiniMaxH3AutoKeyframeVaeEncoderStep, MiniMaxH3CoreDenoiseStep, MiniMaxH3SplitBeforeEncodeStep, MiniMaxH3SplitVaeEncoderStep, MiniMaxH3SplitDenoiseStep, MiniMaxH3AfterDenoiseStep, MiniMaxH3DecodeStep, ]9 unmodified lines
@property def outputs(self): return _generation_outputs() return [ OutputParam.template("videos", description="The generated video."), OutputParam( "audio", type_hint=torch.Tensor, description="The soundtrack of the packed sequence, of shape `(1, 2, num_samples)`.", ), OutputParam("sampling_rate", type_hint=int, description="Sample rate of the soundtrack in Hz."), ]
class MiniMaxH3Ref2VAConditionerBlocks(SequentialPipelineBlocks):48 unmodified lines
@property def outputs(self): return _generation_outputs() return [ OutputParam.template("videos", description="The generated video."), OutputParam( "audio", type_hint=torch.Tensor, description="The soundtrack of the packed sequence, of shape `(1, 2, num_samples)`.", ), OutputParam("sampling_rate", type_hint=int, description="Sample rate of the soundtrack in Hz."), ]h3_split_blocks.py+112-11