vllm_omni.diffusion.models.magi2.sampler_magi2 ¶
Native MAGI-2 Preview classifier-free-guidance sampling.
The CFG and denoising math is adapted from SandAI's Apache-2.0 MAGI-2 Preview inference implementation. Model placement is deliberately not managed here: vLLM-Omni's loader/offloader (including DLO) owns placement, while this sampler only prepares tensors and invokes the already placed model.
CFGConfig dataclass ¶
Preview CFG controls, defaulted to the released MAGI-2 recipe.
Magi2PreviewSampler ¶
Bases: CFGParallelMixin
Run MAGI-2 Preview's joint video/audio denoising loop.
cfg_velocity ¶
cfg_velocity(
model_output: tuple[Tensor, Tensor],
video_txt_guidance_scale: Tensor | float,
audio_txt_guidance_scale: Tensor | float,
cfg_config: CFGConfig | None = None,
latent: Tensor | None = None,
audio_latent: Tensor | None = None,
) -> tuple[Tensor | None, Tensor | None]
combine_cfg_noise ¶
combine_cfg_noise(
positive_noise_pred: Tensor | tuple[Tensor, ...],
negative_noise_pred: Tensor | tuple[Tensor, ...],
true_cfg_scale: float,
cfg_normalize: bool = False,
kwargs: dict[str, Any] | None = None,
) -> tuple[Tensor, Tensor]
Preserve MAGI-2's dual-modality guidance under shared CFG dispatch.
precalculate_cfg ¶
precalculate_cfg(
t_list: Sequence[Tensor],
latent_length: int,
cfg_config: CFGConfig,
*,
device: device | str | None = None,
) -> tuple[list[Tensor], list[float]]
predict_noise ¶
predict_noise(
model_input: ModelInput,
) -> tuple[Tensor, Tensor]
Run one conditional or unconditional branch for shared CFG dispatch.
prepare_model_input ¶
prepare_model_input(
latent: Tensor,
audio_latent: Tensor,
txt_feat: Tensor,
null_txt_feat: Tensor,
ref_audio_feat: Tensor | None = None,
ref_video_feat: Tensor | None = None,
ref_image_feat: Tensor | None = None,
ref_image_feat_len: Tensor | None = None,
ref_image_special_token_embedding: Tensor | None = None,
t: Tensor | float | None = None,
cfg_config: CFGConfig | None = None,
) -> ModelInput
step ¶
step(
model_output: tuple[Tensor, Tensor],
latent: Tensor,
audio_latent: Tensor,
video_txt_guidance_scale: Tensor | float,
audio_txt_guidance_scale: Tensor | float,
video_scheduler: SchedulerMixin,
audio_scheduler: SchedulerMixin,
t: Tensor,
cfg_config: CFGConfig | None = None,
) -> tuple[Tensor, Tensor, Tensor | None, Tensor | None]
build_magi2_preview_schedulers ¶
build_magi2_preview_schedulers(
num_inference_steps: int,
*,
device: device | str,
shift: float = 7.0,
) -> tuple[
FlowUniPCMultistepScheduler, FlowUniPCMultistepScheduler
]
Create independent, identically configured video/audio schedulers.