Image-Text-to-Video
Diffusers
Safetensors
orbitquant
comfyui
w4
w4a4
native-w4a4-transformer-runtime
text-to-video
audio-video-generation
8-bit precision
Instructions to use WaveCut/MiniMax-H3-OrbitQuant-W4A4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use WaveCut/MiniMax-H3-OrbitQuant-W4A4 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("WaveCut/MiniMax-H3-OrbitQuant-W4A4", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
File size: 1,387 Bytes
fa2d87b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | """Narrow MiniMax-H3 dtype-sentinel compatibility for packed linear modules."""
from __future__ import annotations
from dataclasses import dataclass
import torch
from orbitquant.adaln import RTNInt4Linear
from orbitquant.layers import OrbitQuantLinear
@dataclass(frozen=True)
class _WeightDTypeView:
dtype: torch.dtype
def _attach_dtype_view(module: torch.nn.Module) -> bool:
if hasattr(module, "weight"):
return False
for name in ("bias", "row_norms", "scales"):
tensor = getattr(module, name, None)
if isinstance(tensor, torch.Tensor):
# MiniMax-H3 only reads `.weight.dtype` on these boundary/AdaLN
# projections. Keep that read cheap and never dequantize a weight.
object.__setattr__(module, "weight", _WeightDTypeView(tensor.dtype))
return True
raise RuntimeError(f"cannot infer source dtype for {type(module).__name__}")
def enable_h3_orbitquant_compat(transformer: torch.nn.Module) -> int:
"""Attach dtype-only views to the packed modules H3 inspects directly."""
count = 0
for name, module in transformer.named_modules():
needs_view = name in {"proj_in", "audio_proj_in"} or name.endswith("adaln_proj.linear")
if needs_view and isinstance(module, (OrbitQuantLinear, RTNInt4Linear)):
count += int(_attach_dtype_view(module))
return count
|