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 | |
| def test_reference_matches_explicit_bf16_dequant(): | |
| torch.manual_seed(3) | |
| m, n, k = 7, 11, 64 | |
| cb = torch.linspace(-0.2, 0.2, 16) | |
| ac = torch.randint(0,16,(m,k),dtype=torch.uint8) | |
| wc = torch.randint(0,16,(n,k),dtype=torch.uint8) | |
| a_s = torch.rand(m) + 0.1 | |
| w_s = torch.rand(n) + 0.1 | |
| bias = torch.randn(n, dtype=torch.bfloat16) | |
| out = w4a4_linear_reference(pack_uint4(ac), a_s, pack_uint4(wc), w_s, cb, k, bias) | |
| a = (cb[ac.long()] * a_s[:,None]).to(torch.bfloat16) | |
| w = (cb[wc.long()] * w_s[:,None]).to(torch.bfloat16) | |
| ref = (a.float() @ w.float().T + bias.float()).to(torch.bfloat16) | |
| assert torch.equal(out, ref) | |