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 pathlib import Path | |
| import pytest | |
| import torch | |
| from kernels import get_local_kernel | |
| kernel=get_local_kernel(Path(__file__).resolve().parents[1]/'build','yue2_qkv_fused') | |
| def inputs(rows,scale=1): | |
| torch.manual_seed(51) | |
| x=(torch.randn(rows,2048,device='cuda')*scale).bfloat16() | |
| w=torch.randn(2048,device='cuda').bfloat16() | |
| p=torch.randperm(2048,device='cuda').int() | |
| s=(torch.randint(0,2,(2048,),device='cuda')*2-1).to(torch.int8) | |
| bounds=torch.linspace(-.065,.065,15,device='cuda') | |
| return x,w,p,s,bounds | |
| def test_continuous_formula(rows,scale): | |
| x,w,p,s,b=inputs(rows,scale) | |
| packed,norms=kernel.rmsquant(x,w,p,s,b) | |
| y=x.float()*torch.rsqrt(x.float().square().mean(-1,keepdim=True)+1e-6)*w.float() | |
| expected_norm=y.norm(dim=-1) | |
| y=y/(expected_norm[:,None]+1e-8) | |
| y=y[:,p.long()]*s.float() | |
| width=1 | |
| while width<2048: | |
| z=y.reshape(rows,2048//(2*width),2,width) | |
| a,c=z[:,:,0],z[:,:,1] | |
| y=torch.stack([a+c,a-c],dim=2).reshape(rows,2048) | |
| width*=2 | |
| codes=torch.bucketize(y/(2048**.5),b) | |
| expected=(codes[:,0::2]|(codes[:,1::2]<<4)).byte() | |
| torch.testing.assert_close(norms,expected_norm,rtol=2e-6,atol=1e-9) | |
| # Only boundaries within FP32 reduction noise may differ. | |
| if rows: | |
| assert (expected!=packed).float().mean().item()<.001 | |
| assert torch.isfinite(norms).all() | |
| def test_graph_and_invalid_contract(): | |
| args=inputs(2) | |
| expected=kernel.rmsquant(*args) | |
| stream=torch.cuda.Stream();stream.wait_stream(torch.cuda.current_stream()) | |
| with torch.cuda.stream(stream): | |
| for _ in range(3):kernel.rmsquant(*args) | |
| torch.cuda.current_stream().wait_stream(stream) | |
| graph=torch.cuda.CUDAGraph() | |
| with torch.cuda.graph(graph):result=kernel.rmsquant(*args) | |
| graph.replay();torch.cuda.synchronize() | |
| for a,b in zip(expected,result):torch.testing.assert_close(a,b,rtol=0,atol=0) | |
| with pytest.raises(RuntimeError,match='BF16'): | |
| kernel.rmsquant(args[0].float(),*args[1:]) | |
| with pytest.raises(RuntimeError,match='positive'): | |
| kernel.rmsquant(*args,rms_eps=0) | |
| with pytest.raises(RuntimeError,match='permutation'): | |
| kernel.rmsquant(args[0],args[1],args[2].long(),*args[3:]) | |