Text Generation
Transformers
Safetensors
English
Chinese
Russian
yue2
music-generation
orbitquant
quantization
4-bit precision
custom-code
8-bit precision
Instructions to use WaveCut/YuE2-3B-OrbitQuant-W4A4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use WaveCut/YuE2-3B-OrbitQuant-W4A4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="WaveCut/YuE2-3B-OrbitQuant-W4A4")# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("WaveCut/YuE2-3B-OrbitQuant-W4A4", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use WaveCut/YuE2-3B-OrbitQuant-W4A4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "WaveCut/YuE2-3B-OrbitQuant-W4A4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "WaveCut/YuE2-3B-OrbitQuant-W4A4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/WaveCut/YuE2-3B-OrbitQuant-W4A4
- SGLang
How to use WaveCut/YuE2-3B-OrbitQuant-W4A4 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "WaveCut/YuE2-3B-OrbitQuant-W4A4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "WaveCut/YuE2-3B-OrbitQuant-W4A4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "WaveCut/YuE2-3B-OrbitQuant-W4A4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "WaveCut/YuE2-3B-OrbitQuant-W4A4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use WaveCut/YuE2-3B-OrbitQuant-W4A4 with Docker Model Runner:
docker model run hf.co/WaveCut/YuE2-3B-OrbitQuant-W4A4
| from __future__ import annotations | |
| import pytest | |
| import torch | |
| from orbitquant_packed_matmul import matmul_packed_w4a4_int8, supports_device | |
| def test_decode_against_integer_oracle(rows, n, k, dtype, offset, bias_enabled, k_major): | |
| if not torch.cuda.is_available() or not supports_device("cuda"): | |
| pytest.skip("CUDA kernel required") | |
| torch.manual_seed(42) | |
| x = torch.randint(0, 256, (rows * k // 2 + offset,), dtype=torch.uint8)[offset:] | |
| w = torch.randint(0, 256, (n * k // 2 + offset,), dtype=torch.uint8)[offset:] | |
| # Exercise every code, including signed INT8 extremes and mixed nibble signs. | |
| ac = torch.tensor( | |
| [-128, 127, -1, 0, 1, -64, 64, -32, 32, -16, 16, -8, 8, -4, 4, 2], dtype=torch.int8 | |
| ) | |
| wc = ac.flip(0) | |
| def unpack(values, count): | |
| values = values.reshape(count, k // 2) | |
| return torch.stack((values & 15, values >> 4), -1).reshape(count, k).long() | |
| sums = ac.long()[unpack(x, rows)] @ wc.long()[unpack(w, n)].T | |
| # Transfer whole storage to retain the deliberately unaligned device view. | |
| def device_slice(values): | |
| storage = torch.zeros(values.numel() + offset, dtype=torch.uint8) | |
| storage[offset:] = values | |
| return storage.cuda()[offset:] | |
| xd = device_slice(x).reshape(rows, k // 2) | |
| wd = device_slice(w) | |
| if k_major: | |
| wd = wd.reshape(n, k // 2).T.contiguous() | |
| xn = torch.rand(rows, device="cuda") | |
| wn = torch.rand(n, device="cuda", dtype=torch.bfloat16) | |
| bias = torch.rand(n, device="cuda", dtype=dtype) if bias_enabled else None | |
| # Binary-exact scales isolate the integer accumulation and norm epilogue. | |
| expected = sums.cuda().float() * (xn[:, None] * wn.float()[None, :] * 0.001953125) | |
| alternate = expected | |
| if bias is not None: | |
| # Existing kernels permit both contracted and separate FP32 multiply/ | |
| # add epilogues. Check exactly those two results, not a loose tolerance. | |
| alternate = expected + bias.float() | |
| scale = xn[:, None] * wn.float()[None, :] * 0.001953125 | |
| expected = (sums.cuda().float().double() * scale.double() + bias.double()).float() | |
| expected = expected.to(dtype) | |
| alternate = alternate.to(dtype) | |
| args = (xd, wd, xn, wn, ac.cuda(), wc.cuda()) | |
| kwargs = dict( | |
| activation_scale=0.03125, | |
| weight_scale=0.0625, | |
| out_features=n, | |
| in_features=k, | |
| bias=bias, | |
| output_dtype=dtype, | |
| weight_k_major=k_major, | |
| ) | |
| actual = matmul_packed_w4a4_int8(*args, **kwargs) | |
| assert torch.all((actual == expected) | (actual == alternate)) | |
| stream = torch.cuda.Stream() | |
| stream.wait_stream(torch.cuda.current_stream()) | |
| with torch.cuda.stream(stream): | |
| for _ in range(3): | |
| matmul_packed_w4a4_int8(*args, **kwargs) | |
| torch.cuda.current_stream().wait_stream(stream) | |
| graph = torch.cuda.CUDAGraph() | |
| with torch.cuda.graph(graph): | |
| captured = matmul_packed_w4a4_int8(*args, **kwargs) | |
| graph.replay() | |
| torch.cuda.synchronize() | |
| torch.testing.assert_close(captured, actual, rtol=0, atol=0) | |