--- base_model: Wan-AI/Wan2.1-T2V-1.3B-Diffusers license: apache-2.0 tags: - orbitquant - quantized - diffusers - diffusion-transformer --- # Wan-AI/Wan2.1-T2V-1.3B-Diffusers OrbitQuant W4A4 This repository contains a compact OrbitQuant transformer-component artifact for the source Diffusers model listed above. It is intended to be loaded into the original pipeline, not used as a standalone Diffusers pipeline repository. OrbitQuant is a calibration-free post-training quantization method for image and video diffusion transformers. This artifact keeps the text encoders, VAE, embeddings, timestep MLP, and final heads in the source precision by default and replaces the transformer linear projections with OrbitQuant modules. ## Usage Install OrbitQuant and the Hugging Face runtime dependencies: ```bash pip install "orbitquant[hf,kernels]>=0.6.0" ``` The optimized native kernel package is provisioned automatically at first model load: OrbitQuant derives the runtime variant (torch minor and CUDA version for CUDA, the torch stable ABI for CPU, plus OS and architecture), downloads the matching prebuilt wheel from the [OrbitQuant kernels release](https://github.com/iamwavecut/OrbitQuant/releases/tag/kernels-v1) with checksum verification, and caches it under `~/.cache/orbitquant/kernels`. Without a matching variant, CUDA inference falls back to the Triton packed path. Run `orbitquant kernels-install` to provision explicitly. For ComfyUI, the [ComfyUI-OrbitQuant](https://github.com/iamwavecut/ComfyUI-OrbitQuant) node pack provisions the same kernels from its install hook. Download this model repository as an OrbitQuant artifact, then load the source Diffusers pipeline with the quantized component patched in: ```python import torch from diffusers.utils import export_to_video from huggingface_hub import snapshot_download from orbitquant import load_quantized_pipeline_from_artifact artifact_id = "WaveCut/Wan2.1-T2V-1.3B-Diffusers-OrbitQuant-W4A4" artifact_dir = snapshot_download(artifact_id, repo_type="model") pipe = load_quantized_pipeline_from_artifact( artifact_dir, torch_dtype=torch.bfloat16, runtime_mode="auto_fused", ) pipe.enable_model_cpu_offload(device="cuda") frames = pipe( prompt="A cinematic shot of a small robot walking through a neon market", height=480, width=832, num_frames=81, num_inference_steps=50, guidance_scale=5.0, ).frames[0] export_to_video(frames, "wan-orbitquant.mp4", fps=16) ``` ### Convert the source checkpoint on load For a safetensors source checkpoint, OrbitQuant can row-stream the denoiser into packed weights through the normal Diffusers loader. Use sequential offload by replacing the final call with `pipe.enable_sequential_cpu_offload()`. ```python import torch import orbitquant from diffusers import DiffusionPipeline from orbitquant import ( OrbitQuantConfig, build_diffusers_pipeline_quantization_config, ) qconfig = build_diffusers_pipeline_quantization_config( OrbitQuantConfig(target_policy="auto"), components="transformer", ) pipe = DiffusionPipeline.from_pretrained( "Wan-AI/Wan2.1-T2V-1.3B-Diffusers", quantization_config=qconfig, torch_dtype=torch.bfloat16, ) pipe.enable_model_cpu_offload() ``` `runtime_mode="auto_fused"` is the default optimized runtime. On CUDA, the `kernels` extra provides the Triton packed fallback; a locally built native CUDA package is preferred automatically when installed. On MPS, build and install the native Metal package from the OrbitQuant source tree. See the [OrbitQuant runtime instructions](https://github.com/iamwavecut/OrbitQuant/blob/main/docs/kernel-audit.md#local-native-package). Use `runtime_mode="dequant_bf16"` only as an explicit compatibility/debug reference path. ## Native Settings Use these settings when comparing this artifact against the BF16 source model or the visual assets below: | Setting | Value | | --- | --- | | Pipeline | `WanPipeline` | | Resolution | `832x480` | | Frames | `81` | | Inference steps | `50` | | Guidance scale | `5.0` | | Export FPS | `16` | | Output | video | | Scope | paper video target | ## Validation Status - Native BF16-vs-OrbitQuant comparison: included when the visual matrix below is present. - Release-grade VBench metrics: not included in this artifact. - The model card reports artifact-level validation status only. ## Native Validation Evidence The compact benchmark summary records native BF16-vs-OrbitQuant evidence for the comparison matrix below. Detailed per-sample generation records are retained outside this compact artifact. | Evidence | Value | | --- | --- | | Comparison matrix | `assets/video_generation_comparison_matrix.webp` | | Paired prompt/seed count | `1` | | BF16 source generated samples | `1` | | BF16 source generated frames | `81` | | BF16 source nonempty outputs | `1` | | OrbitQuant generated samples | `1` | | OrbitQuant generated frames | `81` | | OrbitQuant nonempty outputs | `1` | ## Quantization - Method: `orbitquant` - Bits: `W4A4` - Runtime mode: `auto_fused` - Activation kernel backend: `auto` - Activation normalization epsilon: `1e-10` - Quantization device: `cuda` - Weight quantization backend: `triton_cuda` - Target policy: `wan` - AdaLN policy: `int4_rtn_group64_bf16_activation` - AdaLN group size: `64` - AdaLN group-size note: paper default. - Rotation: `rpbh` - Rotation seed: `0` - Block size: `paper` - Block size policy: `largest_power_of_two_dividing_dim` - Codebook: `lloyd_max` - Codebook version: `2` - Quantized transformer modules: `300` - AdaLN INT4 modules: `0` - Skipped modules: `6` - Calibration data: none - Text encoders and VAE: left in source precision by default ## Visual Comparison The following assets are stored in this artifact and compare the BF16 base generation against the OrbitQuant generation with the same prompt and seed. ![assets/video_generation_comparison_matrix.webp](assets/video_generation_comparison_matrix.webp) ## Source - Model: `Wan-AI/Wan2.1-T2V-1.3B-Diffusers` - Revision: `0fad780a534b6463e45facd96134c9f345acfa5b` - Source license: `apache-2.0` - OrbitQuant paper: https://arxiv.org/abs/2607.02461 ## Artifact Files - `model.safetensors`: packed OrbitQuant/INT4 module tensors. - `quantization_config.json`: serialized OrbitQuant runtime settings. - `orbitquant_manifest.json`: source provenance, policies, module lists, and checksums. - `orbitquant_codebooks.safetensors`: Lloyd-Max codebooks. - `orbitquant_rotations.safetensors`: deterministic RPBH rotation metadata. ## Limitations - This is a transformer-component artifact; load it into the source pipeline as shown above. - Guaranteed on-the-fly bounded-memory conversion requires a safetensors source checkpoint. Unknown architectures have structural coverage only and require policy inspection plus quality validation. - CUDA and MPS `auto_fused` inference requires a packed matmul kernel and fails loudly when the required kernel is unavailable. The explicit `dequant_bf16` reference mode materializes dequantized weights before BF16 matmul. - Quality depends on the source model and bit setting. Very low-bit settings can degrade prompt following or visual detail.