Skip to content

Add Magenta RealTime 2 Small and Base with streaming generation - #1121

Merged
0xShug0 merged 2 commits into
mainfrom
feature/magenta-realtime-2
Oct 28, 2026
Merged

0xShug0 merged 2 commits into
mainfrom
feature/magenta-realtime-2

Conversation

@0xShug0

@0xShug0 0xShug0 commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Adds Magenta RealTime 2 Small (230M) and Base (2.4B) for 48 kHz stereo instrumental music generation through the gen route, with offline and streaming modes.

  • Text and audio style conditioning, optional piano/drum controls, and sampling controls.
  • Self-contained F16 and Q8_0 GGUF packages, converter, v1 spec, model guide, license entry, and routing documentation.
  • A MusicCoCa conditioner runtime built with existing framework modules. Existing framework module APIs are unchanged; Metal adds an opt-in F32-input matmul lowering.
  • Generation graphs and bounded attention/codec state are cached per session.

Packages: audio-cpp/Magenta-RealTime-2-GGUF. Inference requires no Python, JAX, or TensorFlow Lite.

CUDA performance

RTX 5090, CUDA, eight host threads, one persistent session per model. After a
two-second warmup, generate three different 30-second styles and repeat the
first style. Both implementations use temperature 1.3, top-k 40, style guidance
3, note/drum guidance 1, the text mapper enabled, and seed 0.

Warm RTF averages the four measured requests, including style conditioning and
waveform generation. RTF is wall time divided by audio duration. Peak VRAM
includes model preparation and generation. Python uses its official generate()
path; every row measures complete waveform generation.

Model Runtime Mode RTF Peak VRAM (MiB)
Small Official Python Official generation 0.1359 24,626
Small audio.cpp F16 Offline 0.0861 2,146
Small audio.cpp F16 Streaming 0.0874 2,146
Small audio.cpp Q8_0 Offline 0.0833 1,954
Small audio.cpp Q8_0 Streaming 0.0831 1,954
Base Official Python Official generation 0.3714 16,946
Base audio.cpp F16 Offline 0.2376 6,336
Base audio.cpp F16 Streaming 0.2335 6,336
Base audio.cpp Q8_0 Offline 0.1789 4,218
Base audio.cpp Q8_0 Streaming 0.1789 4,218

Streaming time to first audio

Under the same CUDA settings, TTFA includes text conditioning through the first
160 ms audio block and excludes model loading and preparation. Warm averages
cover the four requests after warmup.

Model First request TTFA Warm average TTFA
Small F16 218 ms 22.1 ms
Small Q8_0 242 ms 21.4 ms
Base F16 262 ms 46.9 ms
Base Q8_0 267 ms 38.4 ms

Validation

Debug build, eight host threads, sequential runs.

  • Official F32 greedy fixtures: Small and Base each match all 204 generated codes; final-waveform cosine is 0.99999924 and 0.99999941 respectively.
  • SpectroStream teacher-forced waveform checks pass for one-frame, four-frame, padded-final-block, and reset/reuse cases on CUDA and Vulkan; minimum cosine exceeds 0.999999.
  • MusicCoCa text, mapper, quantizer, and audio frontend/embedding reference checks pass on CUDA.
  • F16/Q8_0 offline and streaming outputs match byte-for-byte for all 20 matched request pairs. Repeated requests remain identical after different prompts, and concatenated streaming events exactly match the final waveform.
  • Standalone GGUF loading uses the embedded v1 contract without a spec override.

Vulkan and CPU end-to-end smoke tests

One Small Q8_0 streaming request per backend, no warmup: “A gentle acoustic guitar with warm piano”, eight seconds, seed 0, other options at their defaults. Vulkan uses the RTX 5090; CPU uses a Ryzen 9 7900X with eight threads.

Backend Audio duration Cold RTF Cold TTFA Result
Vulkan 8 s 0.127 191 ms Pass
CPU 8 s 1.154 652 ms Pass

Both produce finite, non-silent 48 kHz stereo audio and 50 streaming events that concatenate exactly to the final WAV. Cold RTF and TTFA include request-time graph initialization and conditioning, excluding model loading/preparation. These are functional smoke tests; cross-backend sampled-waveform parity was not required.

Metal fix and performance

SpectroStream activations exceed FP16 range, causing NaNs when Metal's default F32-buffer matmul internally narrows its operands to FP16. Add an explicit full-F32-input Metal specialization and enable it only for this codec on Metal. Default pipelines and other backend paths retain their existing behavior.

Apple M4 Pro, Release, eight host threads, Small Q8_0: the same eight-second streaming smoke request completes in 4.754 s, with RTF 0.594 and TTFA 205 ms, excluding model loading/preparation. Output is finite, non-silent 48 kHz stereo; offline and streaming WAVs are byte-identical. This is a functional measurement, not a speedup comparison against the invalid pre-fix output.

All 56 extended Metal matmul cases pass against independent scalar double-precision calculations. Default F32/F16/Q8_0 before/after outputs remain byte-identical. Tensor-enabled Metal shader compilation also passes; GPU execution was validated on M4 Pro.

@0xShug0 0xShug0 added the ggml label Oct 28, 2026
@0xShug0
0xShug0 merged commit 3d426f4 into main Oct 28, 2026
7 checks passed
@0xShug0
0xShug0 deleted the feature/magenta-realtime-2 branch October 28, 2026 16:33
0xShug0 added a commit that referenced this pull request Nov 1, 2026
…the missing WebUI catalog entry (#1158)

* fix(magenta_realtime_2): accept legacy duration_seconds request option

The server forwards the top-level duration_seconds field verbatim, and the
WebUI gen path sends that legacy field to every family except controlfoley
and midashenglm_gen. Magenta RealTime 2 validated raw option keys against
its schema-v1 contract before parsing, so GUI music requests failed with
"unknown Magenta RealTime 2 request option: duration_seconds".

Normalize legacy request names with apply_option_v1_compatibility before
the whitelist check, as stable_audio and heartmula already do, and parse
all options from the normalized map. Sending both spellings still fails
with the explicit use-duration_sec error.

* fix(webui): add the missing Magenta RealTime 2 catalog entry

PR #1121 added the family everywhere except models_catalog.json, so a
Magenta RealTime 2 model configured through the server config found no
catalog base and its GUI entry carried no request_options metadata. With
that metadata missing, supportsMaxTokens fell back to the task-based
assumption and sent max_tokens with every gen request, which magenta's
strict schema-v1 whitelist rejected with "unknown Magenta RealTime 2
request option: max_tokens".

Add the catalog entry following the other music-gen families, and
regenerate the embedded dist bundle. Config-defined magenta entries now
match the catalog by family and task, get their request options from the
family spec, and no longer send max_tokens.

* Use canonical duration option in WebUI requests

---------

Co-authored-by: 0xShug0 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant