--- base_model: m-a-p/YuE2-3B base_model_relation: quantized license: cc-by-nc-4.0 pipeline_tag: text-to-audio library_name: tensorrt tags: - tensorrt - moonbox - yue2 - yue - music-generation - text-to-music - song-generation - lyrics-to-song - non-commercial --- # YuE2-3B TensorRT TensorRT engines of [YuE2-3B](https://huggingface.co/m-a-p/YuE2-3B), made by Moonbox for NVIDIA RTX GPUs. Each precision is one folder holding the engine, `trt_runner.py` (a small numpy runner: TensorRT plus Polygraphy, no PyTorch) and a script that does the rest of the pipeline. What the engine takes and returns is under *How to run*. **Compatibility.** The engines are built *hardware compatible* (Ampere and newer: RTX 30, 40 and 50 series) and *version compatible* (any TensorRT 10.x from 10.13 on, through its lean runtime). That costs a little speed against an engine built for one GPU, but no rebuild is needed. Install the runtime with `pip install "tensorrt-cu12>=10.13,<11" "tensorrt-lean-cu12>=10.13,<11" polygraphy numpy`. ## Files The last column is the benchmark (details under *How to run*). | Precision | File | Size | sha256 | Benchmark | |---|---|---|---|---| | fp16 | [`fp16/LICENSE.txt`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/LICENSE.txt) | 20.3 kB | `060985741d20` | vs ONNX fp16: score KL 0.00001 / top-1 99.8 %; codes KL 0.00003 / top-1 99.3 %; audio from its codes 44.9 / 47.5 dB SNR (pass 26.3 / 33.0) | | fp16 | [`fp16/THIRD_PARTY_NOTICES.md`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/THIRD_PARTY_NOTICES.md) | 0.8 kB | `14d3fd9f6fee` | (the same build: numbers in its first row) | | fp16 | [`fp16/ar_0.engine`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/ar_0.engine) | 800.9 MB | `ed2fafd5c520` | (the same build: numbers in its first row) | | fp16 | [`fp16/ar_1.engine`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/ar_1.engine) | 665.0 MB | `fe5364d0b1ed` | (the same build: numbers in its first row) | | fp16 | [`fp16/ar_2.engine`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/ar_2.engine) | 665.2 MB | `94d094c27ad5` | (the same build: numbers in its first row) | | fp16 | [`fp16/ar_3.engine`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/ar_3.engine) | 664.9 MB | `51df9d4773b8` | (the same build: numbers in its first row) | | fp16 | [`fp16/ar_4.engine`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/ar_4.engine) | 665.0 MB | `0a37f96055a3` | (the same build: numbers in its first row) | | fp16 | [`fp16/ar_5.engine`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/ar_5.engine) | 458.9 MB | `e79c11de804e` | (the same build: numbers in its first row) | | fp16 | [`fp16/ar_6.engine`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/ar_6.engine) | 800.9 MB | `84ac4e2a156d` | (the same build: numbers in its first row) | | fp16 | [`fp16/ar_7.engine`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/ar_7.engine) | 44.3 MB | `78744699634d` | (the same build: numbers in its first row) | | fp16 | [`fp16/ar_split.json`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/ar_split.json) | 4.2 kB | `8751dad24dc1` | (the same build: numbers in its first row) | | fp16 | [`fp16/device_chain.py`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/device_chain.py) | 8.3 kB | `e675d2e7e2d1` | (the same build: numbers in its first row) | | fp16 | [`fp16/licenses/SnakeBeta-NVIDIA-MIT.txt`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/licenses/SnakeBeta-NVIDIA-MIT.txt) | 1.1 kB | `da9858d51604` | (the same build: numbers in its first row) | | fp16 | [`fp16/licenses/stable-audio-tools-MIT.txt`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/licenses/stable-audio-tools-MIT.txt) | 1.1 kB | `a1fac33b7bcd` | (the same build: numbers in its first row) | | fp16 | [`fp16/nar_0.engine`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/nar_0.engine) | 698.6 MB | `fee3de79de23` | (the same build: numbers in its first row) | | fp16 | [`fp16/nar_1.engine`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/nar_1.engine) | 737.2 MB | `2dde1137935d` | (the same build: numbers in its first row) | | fp16 | [`fp16/nar_2.engine`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/nar_2.engine) | 687.5 MB | `e9ad79f29145` | (the same build: numbers in its first row) | | fp16 | [`fp16/nar_3.engine`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/nar_3.engine) | 737.2 MB | `5272a51489cf` | (the same build: numbers in its first row) | | fp16 | [`fp16/nar_4.engine`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/nar_4.engine) | 354.1 MB | `74ca548736a8` | (the same build: numbers in its first row) | | fp16 | [`fp16/nar_split.json`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/nar_split.json) | 1.9 kB | `9540083794c5` | (the same build: numbers in its first row) | | fp16 | [`fp16/pipeline.py`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/pipeline.py) | 16.4 kB | `736b0c3b8b89` | (the same build: numbers in its first row) | | fp16 | [`fp16/pipeline_trt.py`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/pipeline_trt.py) | 5.7 kB | `d929bf06d92c` | (the same build: numbers in its first row) | | fp16 | [`fp16/qwen.tiktoken`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/qwen.tiktoken) | 2.6 MB | `b2b1b8dfb5cc` | (the same build: numbers in its first row) | | fp16 | [`fp16/trt_runner.py`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/trt_runner.py) | 4.4 kB | `cbc9abb1f59c` | (the same build: numbers in its first row) | | fp16 | [`fp16/vae.engine`](https://huggingface.co/moonbox-dev/YuE2-3B-TensorRT/blob/main/fp16/vae.engine) | 335.0 MB | `649aea2f85c4` | (the same build: numbers in its first row) | ## How to run YuE2-3B (M-A-P: text-to-song, style + lyrics -> a full song with vocals at 48 kHz stereo) as TensorRT engines built from this model's fp16 ONNX graphs, plus `pipeline_trt.py`. The pipeline is the ONNX build's `pipeline.py` (a numpy runtime of the official `yue2_infer` 0.1.5 pipeline: the score, the codes, the NAR's 32-step midpoint ODE, the tiled VAE) with every graph run as engines. **Non-commercial use only:** YuE2-3B and YuE2-Vae are licensed CC BY-NC 4.0 (`LICENSE.txt` in the folder; `THIRD_PARTY_NOTICES.md` and `licenses/` for the VAE's code). ```python import sys sys.path.insert(0, "fp16") from pipeline_trt import YuE2Trt, save_audio p = YuE2Trt("fp16") audio, info = p(style="Acoustic folk, warm male vocal, fingerpicked guitar", lyrics="[Verse]\nMorning light on the kitchen floor\n...\n[Chorus]\n...", seed=4242) save_audio("song.flac", audio) # 48 kHz stereo; info["abc"] is the generated score ``` Or `python fp16/pipeline_trt.py "City Pop, upbeat" lyrics.txt song.flac --seed 0`. It needs numpy, tiktoken, TensorRT 10.13 (`tensorrt-cu12` or `tensorrt-lean-cu12`) and Polygraphy, plus soundfile for FLAC. No PyTorch and no ONNX Runtime. The engines are version-compatible and built for Ampere or newer GPUs (RTX 30-series and up). They hold 8.3 GB (AR 4.8, NAR 3.2, VAE 0.3); the towers are loaded one at a time, and the benchmark's process peaked at 6.7 GB of memory, GPU memory included. Everything the ONNX build's card says about the port (the prompt, the sampling rules, the bf16 ODE state, numpy's noise, no CFG) holds here. **The engines.** - `ar_0..7.engine`: the AR tower (28 Qwen3-style layers, the token embedding, lm_head): `input_ids` [1, S], `past_key_values.{0..27}.key / .value` [1, 8, P, 128] (fp16) -> `logits` of the last position [1, 184704] (fp32) and `present.*`. The prompt is prefilled in chunks of 512. - `nar_0..4.engine`: one evaluation of the flow-matching velocity: `x_t` [T, 64], `t` [1], `past.{0..27}.key / .value` (the AR cache of the prompt, score and codes) -> `velocity` [T, 64]. - `vae.engine`: the Oobleck decoder on `pipeline.py`'s tiles (512 latent frames with 16 more on each side). - `ar_split.json` / `nar_split.json`: the order of each tower's pieces and the tensors passed between them. Each tower is cut into pieces of at most 0.7 GB of weights (the embedding and lm_head are pieces of their own), so that each engine builds within the build machine's memory. **Limits.** The AR's cache holds up to 6,144 positions: the prompt (style, lyrics and score) plus the codes. A song's codes stop there, about 3 minutes of music after a typical prompt (the original allows up to 9,000 codes, 6 minutes). A NAR chunk takes up to 5,120 frames. **On the GPU.** The pipeline (`device_chain.py`) keeps the AR's KV cache on the GPU: each step reads one set of buffers and writes the longer cache into the other, so a step allocates nothing. For the NAR, the AR's engines are released and the NAR reads the AR's cache of the prompt and codes where it is. The activations between a tower's pieces never leave the GPU. **Precisions.** `fp16/` is strongly typed: every tensor keeps the precision the ONNX graph gives it (the AR and NAR fp16 with an fp32 residual stream and fp32 RMSNorms, the VAE fp32), with one change. The ONNX NAR's attention is ONNX Runtime's `com.microsoft` MultiHeadAttention, which TensorRT doesn't take. These engines are built from the same NAR exported with plain attention (45.6 dB from the published graph in ONNX Runtime), its softmax computed in fp32 as the fused kernel computes it. No int8: TensorRT's int8 needs calibrated activations, and the ONNX `int8/` build is weight-only `MatMulNBits`, which TensorRT doesn't take. **Benchmark.** The ONNX build's two songs and rules, with the ONNX `fp16/` build in the original's place (the original's runs aren't kept): - *nightcity*: the README demo's style and seed (12300) with its first verse and chorus. 839 score tokens, 1,720 codes, 69 s. - *folk*: our own English lyrics, seed 4242. 851 score tokens, 1,748 codes, 70 s. The ONNX build generated both songs with recorded draws. Measures: - **Teacher forced:** the ONNX build's own score and code streams fed back. The KL divergence between its next-token distribution and the engines' (over the allowed tokens, its top 256), and how often the engines' top token is its top token. - **Audio:** the engines' NAR and VAE from the ONNX build's codes and noise, SNR against its audio. - **Pass mark** (set before the first run): KL <= 0.01 nats and top-1 >= 90 % per stage; audio at least the original's own noise floor - 1 dB. That floor is how far the original's audio moves when its ODE runs in fp32 instead of bf16 (27.3 / 34.0 dB). | | score KL / top-1 | codes KL (p95) / top-1 | latents SNR | audio SNR (nightcity / folk) | |---|---|---|---|---| | pass mark | <= 0.01 / >= 90 % | <= 0.01 / >= 90 % | | >= 26.3 / 33.0 dB | | TensorRT `fp16/` vs ONNX `fp16/` | 0.00001 / 99.8 % | 0.00003 (0.0003) / 99.3 % | 49.5 / 46.8 dB | 44.9 / 47.5 dB | Replaying the ONNX build's draws, the engines regenerate the nightcity score token for token (839 tokens); the codes part ways after 15-16 tokens, where a draw lands close to a boundary, and stay plausible. The VAE alone matches the ONNX build to 69 / 73 dB. **Time.** The nightcity song (69 s of music) on an RTX 3080 Laptop GPU: the score in 19 s, the codes in 52 s, the NAR's ODE in 17 s, the VAE in 7 s: about 95 s in all, plus loading. The ONNX `fp16/` build takes about 2.5 minutes for a song that long (its card); its VAE is faster, 2 s. ## How these were made From [YuE2-3B](https://huggingface.co/m-a-p/YuE2-3B) at revision `8f24312f18`: each engine was built with TensorRT's builder from Moonbox's published ONNX graph of the same model and precision. The network is *strongly typed*: every tensor keeps the precision the ONNX graph gives it, so an fp16 engine computes what the fp16 ONNX build computes. Built on an RTX 3080 Laptop GPU, it was benchmarked against the original before upload, and the `sha256` column above is what the files must hash to. ## License CC-BY-NC-4.0 (weights); code Apache-2.0. These files are a derivative of the original model and carry its license: it is copied in this repository, and it governs your use of these files. The original model card follows unchanged. --- # Original model card
Frontier music generation with editable scores
π§ Demo Β· π³οΈ Music Arena Β· π Quick start Β· ποΈ Cover Β· π€ Edit Β· β‘ Speed Β· π Benchmarks Β· π arXiv Β· PDF Β· π SheetSage2 arXiv Β· π Citation
**YuE2 is an open music generation model with frontier song quality competitive with Suno v5/v6.** Turn lyrics and a style prompt into a complete song with vocals and accompaniment, then shape its melody and chords through an editable score. > **π§ YuE2 needs your ears** > > Help evaluate YuE2 alongside leading proprietary music models in our blind listening arena. Listen to anonymous music clips, choose your preference, and contribute to our listener preference study. > > **[Listen & vote β](https://arena.3-148-255-99.sslip.io:8080)** Β· No account needed. **State-of-the-art results on WildSongBench.** YuE2 (best-of-8) achieves the highest SongBench average among all evaluated open and proprietary models: **6.9632**, compared with **6.8721** for Suno v5, **6.5562** for Suno v6, and **6.4195** for Suno v6 Wild.  *Frontier song quality and text alignment on 192 WildSongBench prompts. YuE2 uses symbolic planning; Bo8 means best-of-8.* September 12, 2026 comparison: 17 settings, including Suno v6 and Suno v6 Wild. [Vector PDF](assets/figure1.pdf) Β· [SVG](assets/figure1.svg) Β· [All nine metrics and protocols](https://huggingface.co/datasets/m-a-p/WildSongBench/blob/main/benchmark/results.md) Β· [Full-precision CSV](https://huggingface.co/datasets/m-a-p/WildSongBench/resolve/main/benchmark/benchmark-results.csv). - **Compose and edit:** melody + chords, melody-only, or direct generation; bring your own ABC score. - **Edit with an agent:** turn musical feedback into score, style and lyric revisions, then let YuE2 render the next version. [Hear the editing process](https://map-yue2.github.io/#agentic-music-editing). - **Run locally:** 48 kHz stereo songs on a 24GB GPU, without quantization. - **Build on it:** Hugging Face loading, text guidance (CFG), and separate planning and synthesis APIs.  *One ARβNAR Mixture-of-Transformers backbone writes the score and semantic tokens, then generates acoustic latents through flow matching. The VAE turns them into stereo audio.* ## π§ Listen to YuE2 ### πΆ Text-to-music Original songs generated from lyrics and a style prompt. **Cyber Metal Β· English Β· 5:00** **δ»ζδΈη Β· Mandarin funk / nu-disco Β· 3:24** **Passion Β· English rock Β· 3:55** *All three songs use [π€ YuE2-Vae](https://huggingface.co/m-a-p/YuE2-Vae).* ### ποΈ Cover songs Existing songs reimagined in a new style. [Make your own cover β](#cover-an-existing-song) **Auld Lang Syne Β· Jazz-funk cover Β· 3:10** **ζη«ζ°ζι£ Β· Ballad cover Β· 4:45** **Jingle Bells Β· Heavy metal cover Β· 1:09** ### π€ Agentic editing **[Explore the agentic editing demo β](https://map-yue2.github.io/#agentic-music-editing)** Follow **The Last Train** through **9 steps and 14 versions**, from Mandarin pop to English jazz with modern harmony and a saxophone solo built around two complete statements of βTwinkle, Twinkle, Little Star.β Hear the full songs and inspect the conversation, scores, prompts and lyrics at each step. [Try editing with an agent β](#export-a-plan-edit-it-and-generate) ## π Quick start Linux Β· Python 3.10+ Β· 24GB NVIDIA GPU with BF16 support. Install the inference package: ```bash python -m pip install huggingface-hub==0.36.2 hf download m-a-p/YuE2-3B yue2_infer-0.1.5-py3-none-any.whl --local-dir . python -m pip install ./yue2_infer-0.1.5-py3-none-any.whl ``` [Create](#generate-a-song) Β· [Cover](#cover-an-existing-song) Β· [Edit & agentic edit](#export-a-plan-edit-it-and-generate) Load the pipeline once for the examples below: ```python from pathlib import Path from yue2 import YuE2Pipeline pipe = YuE2Pipeline.from_pretrained("m-a-p/YuE2-3B", device="cuda") ``` ### πΆ Create Turn a style prompt and lyrics into a complete song with vocals and accompaniment. Use the [style and full lyrics from δ»ζδΈη ](examples/tonight-awake.json), the funk / nu-disco demo above. ```python import json from huggingface_hub import hf_hub_download repo = "m-a-p/YuE2-3B" prompt_path = hf_hub_download(repo, "examples/tonight-awake.json") demo = json.loads(Path(prompt_path).read_text(encoding="utf-8")) style, lyrics = demo["style"], demo["lyrics"] song = pipe(style=style, lyrics=lyrics, cot="full", seed=demo["seed"]) song.save("song.flac") song.save_artifacts("outputs/song") # ABC, tokens, latents, audio and settings ``` Defaults are ready to use: `cot="full"` and [π€ YuE2-Vae](https://huggingface.co/m-a-p/YuE2-Vae). | Option | What it does | |---|---| | `cot="full"` | Melody + chord planning (default) | | `cot="melody"` | Melody-only planning; recommended for covers | | `cot="off"` | Generate without a symbolic plan | | `cfg_scale=1.2` | Experiment with stronger text guidance | ### ποΈ Cover Start from an existing recording and give it a new arrangement. **For covers, we recommend melody-only mode (`cot="melody"`).** 1. **Get the score:** transcribe the existing song with [π€ SheetSage2](https://huggingface.co/m-a-p/SheetSage2) and save its melody ABC **without chord symbols** as `melody.abc`. 2. **Get the lyrics:** ask an agent to find them online, or transcribe the singing with [Qwen3-ASR](https://huggingface.co/Qwen/Qwen3-ASR-1.7B) or the [Gemini API](https://ai.google.dev/gemini-api/docs/audio). Check the words, organize them into sections matching the recording, and save them as `cover_lyrics.txt`. 3. **Choose a target style and generate:** review or edit the score and lyrics, then supply them to YuE2 with `cot="melody"` and your target style prompt. Run the transcription tools in their own environments, then use the YuE2 pipeline: ```python cover = pipe( style="Jazz-funk, warm lead vocal, Rhodes piano, electric bass, tight drums", lyrics=Path("cover_lyrics.txt").read_text(encoding="utf-8"), abc=Path("melody.abc").read_text(encoding="utf-8"), cot="melody", seed=831001, ) cover.save("cover.flac") cover.save_artifacts("outputs/cover") ``` `cot="melody"` does not remove chord symbols automatically. Use `cot="full"` if you want to supply the original or edited harmony as well. ### πΌ Edit & agentic edit Edit the ABC yourself, or give an agent the score, original prompt and lyrics, and your requested changes. The agent can reharmonize, develop a solo, or adapt the lyrics and style; YuE2 renders each revision. [Hear the multi-turn editing demo](https://map-yue2.github.io/#agentic-music-editing). For the song from **Create**, copy `outputs/song/score.abc` to `edited.abc`. To obtain a plan before generating audio, use the same prompt and seed: ```python plan = pipe.plan(style=style, lyrics=lyrics, cot="full", seed=demo["seed"]) plan.save("original_plan") # Keep the original and edit a copy as edited.abc. ``` For strict reharmonization, ask the agent to preserve melody pitches and rhythm and check sustained notes against the new chords. Allow selected melody or lyric changes for a broader adaptation. After reviewing `edited.abc`, regenerate with the revised style; this example keeps the lyrics and seed from **Create**: ```python edited_style = ( "Jazz, expressive lead vocal, piano, tenor saxophone, upright bass, " "brushed drums, no guitar, spacious modern harmony" ) song = pipe(style=edited_style, lyrics=lyrics, cot="full", seed=demo["seed"], abc=Path("edited.abc").read_text(encoding="utf-8")) song.save("edited.flac") song.save_artifacts("outputs/edited") ```