Instructions to use ApacheOne/Wan2.2-Animate-2-14B-OrbitQuant-W4A4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use ApacheOne/Wan2.2-Animate-2-14B-OrbitQuant-W4A4 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image, export_to_video # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("ApacheOne/Wan2.2-Animate-2-14B-OrbitQuant-W4A4", dtype=torch.bfloat16, device_map="cuda") pipe.to("cuda") prompt = "A man with short gray hair plays a red electric guitar." image = load_image( "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/guitar-man.png" ) output = pipe(image=image, prompt=prompt).frames[0] export_to_video(output, "output.mp4") - Notebooks
- Google Colab
- Kaggle
| import torch | |
| from orbitquant_wan_a2.nibbles import pack_uint4 | |
| from orbitquant_wan_a2.reference import w4a4_linear_reference | |
| from orbitquant_wan_a2.triton_w4a4 import PackedActivation, w4a4_linear_triton | |
| def test_gemm_native_transposed_weight_layout_cpu_reference(): | |
| torch.manual_seed(17) | |
| m, n, k = 5, 13, 64 | |
| cb = torch.linspace(-0.2, 0.2, 16, dtype=torch.float32) | |
| ac = torch.randint(0, 16, (m, k), dtype=torch.uint8) | |
| wc = torch.randint(0, 16, (n, k), dtype=torch.uint8) | |
| ap = pack_uint4(ac) | |
| wp_row = pack_uint4(wc) | |
| wp_runtime = wp_row.transpose(0, 1).contiguous() | |
| a_scale = torch.rand(m) + 0.1 | |
| w_scale = torch.rand(n) + 0.1 | |
| bias = torch.randn(n, dtype=torch.bfloat16) | |
| packed_a = PackedActivation(ap, a_scale, k) | |
| got = w4a4_linear_triton(packed_a, wp_runtime, w_scale, cb, bias) | |
| ref = w4a4_linear_reference(ap, a_scale, wp_row, w_scale, cb, k, bias) | |
| assert torch.equal(got, ref) | |