Skip to content

[Quantization] SDNQ Minimax H3 loading - #14398

Merged
yiyixuxu merged 1 commit into
mainfrom
minimax-sdnq-fix
Aug 5, 2026
Merged

[Quantization] SDNQ Minimax H3 loading#14398
yiyixuxu merged 1 commit into
mainfrom
minimax-sdnq-fix

Conversation

@asomoza

@asomoza asomoza commented Aug 5, 2026

Copy link
Copy Markdown
Member

The H3 transformer casts activations to a projection's weight dtype in seven places.

With SDNQ, the weight is stored as int8/uint8 or int4/uint4 and dequantized inside forward, so the cast turns the activations into integers:

RuntimeError: mat1 and mat2 must have the same dtype, but got Char and BFloat16

The same issue happens with layerwise casting, where the weight is stored as fp8 and upcast by a hook.

Code to test (this fails without this PR):

import torch

from diffusers import ModularPipeline
from diffusers.hooks import apply_group_offloading
from diffusers.utils import encode_video


MODEL = "OzzyGT/MiniMax_H3_sdnq_dynamic_4bit"
PROMPT = (
    "A red fox trotting through a snowy pine forest at dawn, snow crunching underfoot, "
    "breath visible in the cold air, low winter sun through the trees"
)

pipe = ModularPipeline.from_pretrained(MODEL)
pipe.load_components(workflow="t2va", dtype=torch.bfloat16)

offload = {
    "onload_device": torch.device("cuda"),
    "offload_device": torch.device("cpu"),
    "use_stream": True,
    "low_cpu_mem_usage": True,
}
pipe.transformer.enable_group_offload(offload_type="block_level", num_blocks_per_group=1, **offload)
apply_group_offloading(pipe.text_encoder.model, offload_type="leaf_level", **offload)
apply_group_offloading(pipe.vae, offload_type="leaf_level", **offload)
pipe.audio_vae.to("cuda")

state = pipe(
    prompt=PROMPT,
    num_frames=124,
    height=544,
    width=960,
    num_inference_steps=30,
    generator=torch.Generator("cpu").manual_seed(42),
)

encode_video(
    state.get("videos")[0],
    fps=24,
    audio=state.get("audio")[0],
    audio_sample_rate=state.get("sampling_rate"),
    output_path="h3_768p_group_offload.mp4",
)

@github-actions github-actions Bot added models size/S PR with diff < 50 LOC labels Aug 5, 2026
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@yiyixuxu
yiyixuxu merged commit 9f169d9 into main Aug 5, 2026
15 of 16 checks passed
@yiyixuxu
yiyixuxu deleted the minimax-sdnq-fix branch August 5, 2026 20:14
DN6 pushed a commit that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

models size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants