Text-to-Audio
TensorRT
ONNX
Magenta RT
moonbox
magenta
music-generation
live-music
streaming
48khz
stereo
Run this model with HF Jobs
Run moonbox-dev/magenta-realtime-2-small-TensorRT on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use moonbox-dev/magenta-realtime-2-small-TensorRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- TensorRT
How to use moonbox-dev/magenta-realtime-2-small-TensorRT with TensorRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Magenta RT
How to use moonbox-dev/magenta-realtime-2-small-TensorRT with Magenta RT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
File size: 19,239 Bytes
e8ba9dc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | ---
base_model: google/magenta-realtime-2
base_model_relation: quantized
license: cc-by-4.0
pipeline_tag: text-to-audio
library_name: tensorrt
tags:
- tensorrt
- moonbox
- magenta
- magenta-realtime
- music-generation
- live-music
- streaming
- 48khz
- stereo
---
# Magenta RealTime 2 (small) TensorRT
TensorRT engines of [Magenta RealTime 2 (small)](https://huggingface.co/google/magenta-realtime-2), 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/codec.engine`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/codec.engine) | 215.5 MB | `c8fabeba0823` | fp32 math (as the ONNX fp16-storage build): KL 1.8e-6 (p95 3.3e-6), top-1 99.9 % (level 0: 100 %), codec 100.8 dB, style tokens equal on 3 of 3 prompts; 40.4 frames/s (the ONNX fp16 build 33.3 the same day) |
| fp16 | [`fp16/config.json`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/config.json) | 1.0 kB | `36fa9d8d4def` | (the same build: numbers in its first row) |
| fp16 | [`fp16/depth.engine`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/depth.engine) | 194.6 MB | `3a2f42ff7777` | (the same build: numbers in its first row) |
| fp16 | [`fp16/device_chain.py`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/device_chain.py) | 9.4 kB | `f34bec2d7d50` | (the same build: numbers in its first row) |
| fp16 | [`fp16/mapper.onnx`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/mapper.onnx) | 86.2 MB | `4886045a5748` | (the same build: numbers in its first row) |
| fp16 | [`fp16/music_encoder.onnx`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/music_encoder.onnx) | 371.0 MB | `56a066efaffc` | (the same build: numbers in its first row) |
| fp16 | [`fp16/musiccoca_audio.npz`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/musiccoca_audio.npz) | 0.5 MB | `1893693359f8` | (the same build: numbers in its first row) |
| fp16 | [`fp16/pipeline.py`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/pipeline.py) | 20.5 kB | `bde31b193e61` | (the same build: numbers in its first row) |
| fp16 | [`fp16/pipeline_trt.py`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/pipeline_trt.py) | 4.9 kB | `c5c45618f00c` | (the same build: numbers in its first row) |
| fp16 | [`fp16/pretrained_vector_quantizer.engine`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/pretrained_vector_quantizer.engine) | 118.4 MB | `62fa2f3575fc` | (the same build: numbers in its first row) |
| fp16 | [`fp16/spm.model`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/spm.model) | 0.5 MB | `ff325a99b61b` | (the same build: numbers in its first row) |
| fp16 | [`fp16/states.npz`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/states.npz) | 12.9 MB | `a5d612a010d5` | (the same build: numbers in its first row) |
| fp16 | [`fp16/temporal.engine`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/temporal.engine) | 870.5 MB | `3b2c13588cb5` | (the same build: numbers in its first row) |
| fp16 | [`fp16/text_encoder.engine`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/text_encoder.engine) | 466.9 MB | `96ec6b4e7d5d` | (the same build: numbers in its first row) |
| fp16 | [`fp16/trt_runner.py`](https://huggingface.co/moonbox-dev/magenta-realtime-2-small-TensorRT/blob/main/fp16/trt_runner.py) | 4.4 kB | `3075c6bb264c` | (the same build: numbers in its first row) |
## How to run
Magenta RealTime 2, the small model, as TensorRT engines plus `pipeline_trt.py`. It is Google DeepMind's live music
model: it generates 48 kHz stereo music 40 ms at a time, steered by a text or audio prompt that can change while it
plays.
The pipeline is this model's ONNX `pipeline.py` with the generation's graphs run as engines. The conditioning, the
original's sampling and the streaming loop stay in numpy. Every step's state stays on the GPU: two buffer sets per
graph, read from one and written to the other each step.
- `temporal.engine`: one step of the temporal transformer (12 layers). It takes the frame's 144 conditioning tokens
and the previous frame's 12 codes, plus its attention state (a 41-frame window plus attention sinks), and returns a
hidden state. The conditioning tokens are 12 MusicCoCa style tokens, 128 piano-roll notes, drums and CFG scales.
- `depth.engine`: one step of the depth transformer, run 12 times a frame (once per residual codebook level), giving
the logits of that level's next code.
- `codec.engine`: one step of the SpectroStream decoder, the frame's 12 codes -> 1920 stereo samples.
- `text_encoder.engine`, `pretrained_vector_quantizer.engine`: MusicCoCa's text encoder and its RVQ tokenizer.
- `mapper.onnx`, `music_encoder.onnx`: MusicCoCa's text-to-audio mapper and its audio encoder, run once per prompt on
ONNX Runtime's CPU provider, as in the ONNX build. They are TensorFlow while loops, which TensorRT 10.13 does not
build (an internal assertion).
- `states.npz`, `config.json`, `spm.model`, `musiccoca_audio.npz`: the initial states, the original's constants and
defaults, and MusicCoCa's text and audio front ends.
```python
import sys; sys.path.insert(0, "fp16")
import soundfile as sf
from pipeline_trt import MagentaRT2Trt
mrt = MagentaRT2Trt("fp16")
sf.write("funk.wav", mrt.generate("disco funk", seconds=10), 48000) # float32 [samples, 2]
stream = mrt.stream("ambient pads with sub bass") # live: one 40 ms frame per call
for _ in range(250):
chunk = stream.step() # [1920, 2]
stream.set_style("heavy metal guitar solo") # a new prompt (or CFG scales, notes, drums) between frames
```
It needs numpy, sentencepiece, onnxruntime (for the two MusicCoCa graphs), TensorRT 10.13 (`tensorrt-cu12` or
`tensorrt-lean-cu12`) and Polygraphy. The engines are version-compatible and built for Ampere or newer GPUs (RTX
30-series and up).
**Precisions.** `fp16/` is built from the ONNX `fp16/` build, whose transformers store their weights in fp16 and
compute in fp32 (with fp16 arithmetic the error grows over the stream). The casts are folded into fp32 weights, so
the engines' math is fp32 like the ONNX build's, without TF32. The codec and MusicCoCa are fp32 graphs there too.
There is no int8: TensorRT's int8 needs calibrated activations.
**Benchmark.**
- **Setup:** the ONNX build's. 3 prompts ("disco funk", "ambient pads with sub bass", "heavy metal guitar solo") of
10 s each, against the original (magenta_rt's JAX system in fp32 on the CPU). The original generates, then the
engines are teacher-forced on its codes.
- **Scores:**
- KL is the mean KL divergence of each level's code distribution from the original's, in nats, with p95 in
brackets.
- top-1 is the share of steps whose most likely code is the original's.
- Codec SNR is the decoded audio against the original's decode of the same codes, for the worst prompt.
- Style tokens counts the prompts whose MusicCoCa tokens equal the original's.
- Speed is frames generated per second for 20 s of music, whole pipeline. Real time is 25.
- **Pass mark** (the music language model's, set before the first run): KL at most 0.01, top-1 at least 90 %, codec at
least 30 dB, and the style tokens equal.
| | KL | top-1 | codec SNR (dB) | style tokens | frames / s |
|---|---|---|---|---|---|
| ONNX `fp16/` (CUDA graphs) | 1.8e-6 (3.3e-6) | 99.9 % | 99.5 | 3 / 3 | 33.3 |
| TensorRT `fp16/` | 1.8e-6 (3.3e-6) | 99.9 % | 100.8 | 3 / 3 | 40.4 |
Both speeds were measured the same day on an RTX 3080 Laptop GPU.
## How these were made
From [Magenta RealTime 2 (small)](https://huggingface.co/google/magenta-realtime-2) at revision `010aa0dcb0`: 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-4.0 (weights) / Apache-2.0 (code). 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
# Model Card for Magenta RealTime 2
**Authors**: Google DeepMind
**Resources**:
- [Get Started](https://magenta.withgoogle.com/mrt2)
- [Blog Post](https://magenta.withgoogle.com/magenta-realtime-2)
- [Repository](https://github.com/magenta/magenta-realtime)
- [HuggingFace](https://huggingface.co/google/magenta-realtime-2)
## Terms of Use
Magenta RealTime 2 is offered under a combination of licenses: the codebase is
licensed under
[Apache 2.0](https://github.com/magenta/magenta-realtime/blob/main/LICENSE), and
the model weights under
[Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode).
In addition, we specify the following usage terms:
Copyright 2026 Google LLC
Use these materials responsibly and do not generate content, including outputs,
that infringe or violate the rights of others, including rights in copyrighted
content.
Google claims no rights in outputs you generate using Magenta RealTime 2. You
and your users are solely responsible for outputs and their subsequent uses.
Unless required by applicable law or agreed to in writing, all software and
materials distributed here under the Apache 2.0 or CC-BY licenses are
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the licenses for the specific language governing
permissions and limitations under those licenses. You are solely responsible for
determining the appropriateness of using, reproducing, modifying, performing,
displaying or distributing the software and materials, and any outputs, and
assume any and all risks associated with your use or distribution of any of the
software and materials, and any outputs, and your exercise of rights and
permissions under the licenses.
## Model Details
Magenta RealTime 2 is an open music generation model from Google built for on
device streaming generation with low-latency control. It is a
[live music model](https://arxiv.org/abs/2508.04651) and a follow up to the
prior [Magenta RealTime model](https://huggingface.co/google/magenta-realtime)
and [Lyria RealTime API](http://goo.gle/lyria-realtime), offering on-device
generation with richer control and lower latency. Magenta RealTime 2 enables the
continuous generation of musical audio steered by text prompts, audio examples,
and MIDI.
### System Components
Magenta RealTime 2 is composed of three components: SpectroStream, MusicCoCa,
and an LLM. The structure is similar to that of the original Magenta RealTime,
detailed [here](https://arxiv.org/abs/2508.04651). The primary difference is
the LLM, which is now a Decoder-only model supporting frame-wise autoregression
(rather than chunk-wise) and tuned for on-device streaming with frame-level
control.
1. **SpectroStream** ([Li+ 25](https://arxiv.org/abs/2508.05207)) is a
discrete audio codec that converts stereo 48kHz audio into tokens.
1. **MusicCoCa** is a contrastive-trained model capable of embedding audio and
text into a common embedding space, building on
[Yu+ 22](https://arxiv.org/abs/2205.01917) and
[Huang+ 22](https://arxiv.org/abs/2208.12415).
1. A **decoder-only Transformer LLM** generates audio tokens given context
audio tokens, a tokenized MusicCoCa embedding, and MIDI tokens. There are
two configurations:
1. A `base` configuration with 2.4B parameters
1. A `small` configuration with 230M parameters
### Inputs and outputs
- **SpectroStream RVQ codec**: Tokenizes high-fidelity music audio
- **Encoder input / Decoder output**: Music audio waveforms, 48kHz stereo
- **Encoder output / Decoder input**: Discrete audio tokens, 25Hz frame
rate, 64 RVQ depth, 10 bit codes, 16kbps
- **MusicCoCa**: Joint embeddings of text and music audio
- **Input**: Music audio waveforms, 16kHz mono, or text representation of
music style e.g. "heavy metal"
- **Output**: 768 dimensional embedding, quantized to 12 RVQ depth, 10 bit
codes
- **Decoder Transformer LLM**: Generates audio tokens given context, MIDI,
and style. At each timestep (codec frame), the model receives:
- **Input**:
- (Context) SpectroStream tokens
- `base`: 25 frame (1s) windowed attention per layer, 20 layers
- `small`: 41 frame (~1.6s) windowed attention per layer, 12 layers
- Yields 20s effective receiptive field for both models
- (Style) 12 MusicCoCa tokens
- (MIDI) 128-dim multihot vector representing the state of each MIDI
pitch during this frame (0 = Off, 1 = Sustain, 2 = Onset, 3 = Sustain
or onset, model decides)
- **Output**: 1 generated frame, 12 RVQ tokens
## Uses
Music generation models, in particular ones targeted for continuous real-time
generation and control, have a wide range of applications across various
industries and domains. The following list of potential uses is not
comprehensive. The purpose of this list is to provide contextual information
about the possible use-cases that the model creators considered as part of model
training and development.
- **Interactive Music Creation**
- Live Performance / Improvisation: These models can be used to generate
music in a live performance setting, controlled by performers
manipulating style embeddings or the audio context
- Accessible Music-Making & Music Therapy: People with impediments to
using traditional instruments (skill gaps, disabilities, etc.) can
participate in communal jam sessions or solo music creation.
- Video Games: Developers can create a custom soundtrack for users in
real-time based on their actions and environment.
- **Research**
- Transfer learning: Researchers can leverage representations from
MusicCoCa and Magenta RT 2 to recognize musical information.
- **Personalization**
- Musicians can finetune models with their own catalog to customize the
model to their style (fine tuning support coming soon).
- **Education**
- Exploring Genres, Instruments, and History: Natural language prompting
enables users to quickly learn about and experiment with musical
concepts.
### Out-of-Scope Use
See our [Terms of Use](#terms-of-use) above for usage we consider out of scope.
## Bias, Risks, and Limitations
Magenta RT 2 supports the real-time generation and steering of instrumental
music. The purpose and intention of this capability is to foster the
development of new real-time, interactive co-creation workflows that seamlessly
integrate with human-centered forms of musical creativity.
Every AI music generation model, including Magenta RT 2, carries a risk of
impacting the economic and cultural landscape of music. We aim to mitigate these
risks through the following avenues:
- Prioritizing human-AI interaction as fundamental in the design of Magenta
RT 2.
- Distributing the model under a terms of service that prohibit developers
from generating outputs that infringe or violate the rights of others,
including rights in copyrighted content.
- Training on primarily instrumental data. With specific prompting, this model
has been observed to generate some vocal sounds and effects, though those
vocal sounds and effects tend to be non-lexical.
### Known limitations
Magenta RealTime 2 has similar limitations to Magenta RealTime in terms of
genre coverage and non lexical vocalizations,
[refer here for details](https://huggingface.co/google/magenta-realtime#known-limitations).
### Benefits
At the time of release, Magenta RealTime 2 represents the only open weights
model supporting real-time, continuous musical audio generation with low
latency control (~200ms). It is designed specifically to enable live,
interactive musical creation, bringing new capabilities to musical
performances, art installations, video games, and many other applications.
## How to Get Started with the Model
See our [Get Started Page](https://magenta.withgoogle.com/magenta-realtime-2)
and [GitHub repository](https://github.com/magenta/magenta-realtime) for usage
examples.
## Training Details
### Training Data
Magenta RealTime 2 was trained on ~71k hours of stock music from multiple
sources, mostly instrumental.
### Hardware
Magenta RealTime 2 was trained using
[Tensor Processing Unit (TPU)](https://cloud.google.com/tpu/docs/intro-to-tpu)
hardware.
### Software
Training was done using [JAX](https://github.com/jax-ml/jax) and
[Sequence Layers](https://github.com/google/sequence-layers). JAX allows
researchers to take advantage of the latest generation of hardware, including
TPUs, for faster and more efficient training of large models.
## Evaluation
Model evaluation metrics and results will be shared in our forthcoming technical
report.
## Citation
A paper about Magenta RealTime 2 is forthcoming. For now, please cite our
previous technical report:
**BibTeX:**
```
@inproceedings{gdmlyria2025live,
title={Live Music Models},
author={Caillon, Antoine and McWilliams, Brian and Tarakajian, Cassie and Simon, Ian and Manco, Ilaria and Engel, Jesse and Constant, Noah and Li, Pen and Denk, Timo I. and Lalama, Alberto and Agostinelli, Andrea and Huang, Anna and Manilow, Ethan and Brower, George and Erdogan, Hakan and Lei, Heidi and Rolnick, Itai and Grishchenko, Ivan and Orsini, Manu and Kastelic, Matej and Zuluaga, Mauricio and Verzetti, Mauro and Dooley, Michael and Skopek, Ondrej and Ferrer, Rafael and Borsos, Zal{\'a}n and van den Oord, {\"A}aron and Eck, Douglas and Collins, Eli and Baldridge, Jason and Hume, Tom and Donahue, Chris and Han, Kehang and Roberts, Adam},
booktitle={NeurIPS Creative AI},
year={2025}
}
```
|