Downloads · 30 days
51
24% of all-time downloads
mattmireles/magenta-realtime-2-iphone
magenta-realtime-2-iphone is a text-to-audio model from mattmireles. Use it for the text-to-audio task on the model card, and read the license before you ship it in a product. It is set up for coreml. The card lists the license as cc-by-4.0.
Ten minutes of live 48 kHz stereo music generation on an iPhone 15 Pro Max, at 1.03× real time, with zero underruns and no app GPU work.
Downloads · 30 days
51
24% of all-time downloads
All-time downloads
213
Public
Repo size
1.3 GB
Likes
4
Public
Click a slice to open those files.
.bin814 MB · 100%
From the Hugging Face model README
Ten minutes of live 48 kHz stereo music generation on an iPhone 15 Pro Max, at 1.03× real time, with zero underruns and no app GPU work.
This is Google DeepMind's
Magenta RealTime 2
(mrt2_small, 230M parameters), cut into three Core ML graphs and placed on
the engine each one suits. On the iPhone 15 Pro Max (A17 Pro), the temporal
transformer and the codec decoder run on the Neural Engine and the depth
transformer runs on the CPU: 11.2 + 9.8 + 2.3 ms per 40 ms frame
(iteration-normalized p50 over a 610 s run).
What that claim does and does not cover:
Exporters, validation harness, method docs: github.com/mattmireles/magenta-realtime-2-iphone Papers: Surgical Inference (conversion and admission findings, Section 5) and Throughput Is Not Liveness (end-to-end runtime study), both linked from the GitHub repo.
| File | Size | Precision | Runs on | Role |
|---|---|---|---|---|
MRT2TemporalBodyStreamingCarry.mlpackage | 366 MB | fp16 | ANE (10/10 cold launches on both phones, ANE cost share 1.000) | One-frame temporal step. 48 K/V caches in, 48 one-token updates out; the host owns a 41-frame ring. The shipped temporal graph. |
MRT2DepthBodyRollout.f16.mlpackage | 74 MB | fp16 | CPU | In-graph depth rollout: all 12 RVQ levels sampled in one prediction from host Gumbel noise. The shipped depth graph. |
MRT2DepthBodyRollout.f32.mlpackage | 148 MB | fp32 | — (reference) | Token-exact reference (0/900 mismatches against the reference sampler). |
SpectroStreamDecoder.f16.mlpackage | 68 MB | fp16, exact mid-network rescale | ANE on the A17 Pro | Shipped A17 Pro decoder. Do not use on the A14's ANE (see below). |
SpectroStreamDecoder.mlpackage | 136 MB | fp32 | CPU (its compute plan under .cpuAndNeuralEngine is all CPU) | Shipped A14 decoder and reference (118.85 dB SNR against MLX). |
SpectroStreamRVQCodebooks.f32.bin (+ .json) | 12.6 MB | f32 | CPU | 12×1024×256 codebook table for the host gather |
examples/test_vector_smooth_electronic.bin (+ .json) | 1 KB | f32 | — | One certified conditioning vector |
metadata/ | — | — | — | Per-model export receipts (coremltools config, I/O schemas) |
validation/ | — | — | — | Parity receipts for the numbers on this card |
fixtures/ | 1.3 MB | — | — | MLX reference tensors |
All models are mlprogram with a minimum deployment target of iOS 18 /
macOS 15. Every package here was regenerated from the public exporters, and its
weight.bin matches the certified package byte for byte (checksums below).
prompt text ──(compiled once, on a Mac)──▶ prompt vector
│
▼
┌──────────────────────────────────┐
│ TEMPORAL (stateless step) │ ◀── ANE, fp16
│ Next 40 ms frame, host K/V ring │
└──────────────┬───────────────────┘
▼
┌──────────────────────────────────┐
│ DEPTH (in-graph rollout) │ ◀── CPU, fp16
│ Samples 12 RVQ levels │ host Gumbel noise
└──────────────┬───────────────────┘
▼
┌──────────────────────────────────┐
│ RVQ GATHER (host) │ ◀── CPU
└──────────────┬───────────────────┘
▼
┌──────────────────────────────────┐
│ DECODER (SpectroStream) │ ◀── ANE fp16 + rescale (A17 Pro)
│ Every 12 frames, 25-frame window│ CPU fp32 (A14)
└──────────────┬───────────────────┘
▼
┌──────────────────────────────────┐
│ iSTFT + OVERLAP-ADD (host) │ ◀── CPU
└──────────────┬───────────────────┘
▼
48 kHz stereo audio
Three findings decided the cuts (details in Surgical Inference, Section 5):
ct.StateType graphs fail ANECCompile() with error −14. The
same math as a stateless one-frame step, with caches as ordinary inputs and
updates as ordinary outputs, compiles fully to the ANE.Sampling entropy (RNG, Gumbel noise) and the codebook gather stay on the host, so seeds reproduce and token-level parity is testable. CFG is baked in at conditioning time.
| Model | Inputs | Outputs |
|---|---|---|
| MRT2TemporalBodyStreamingCarry | temporal_inputs [1,1,1024] f32 · source_encoded [1,1,256] f32 · cache_valid_bias [1,1,1,43] fp16 · 48 × temporal_layer_XX_{self,cross}_{key,value}_cache_in [1,41,8,128] fp16 | temporal_outputs [1,1,1024] fp16 · 48 × ..._cache_updates [1,1,8,128] fp16 |
| MRT2DepthBodyRollout (both precisions) | temporal_frame [1,1,1024] · gumbel_noise [12,1024] · inverse_temperature [1] | sampled_codes [12] int32 · temporal_feedback [1,1024] |
| SpectroStreamDecoder (both precisions) | decoder_embeddings [1,25,256] f32 (host RVQ lookup sum) | decoder_stft [1,96,480,4] f32 (→ host iSTFT and overlap-add) |
Everything is static-shaped. sampled_codes are codebook-local (0–1023); the
unique id is 6 + level*1024 + code. temporal_feedback is the next frame's
temporal_inputs row. The decoder runs once every 12 frames over a 25-frame
window that keeps 12 frames of causal history; without that history its output
is wrong. Full I/O schemas are in metadata/.
import CoreML
let temporal = try MLModel(contentsOf: temporalURL, configuration: aneConfig) // .cpuAndNeuralEngine
let depth = try MLModel(contentsOf: depthF16URL, configuration: cpuConfig) // .cpuOnly
let decoder = try MLModel(contentsOf: decoderURL, configuration: decConfig) // A17 Pro: f16 on .cpuAndNeuralEngine; A14: fp32
var ring = HostKVRing(layers: 12, window: 41) // 48 fp16 buffers, host-owned
while generating { // must average >= 25 frames/s
let t = try temporal.prediction(from: ring.inputs(
temporalInputs: prevFeedback, source: conditioning))
ring.append(updates: t) // host-owned ring write
let d = try depth.prediction(from: ["temporal_frame": t.frame,
"gumbel_noise": gumbel(seed),
"inverse_temperature": invTemp])
prevFeedback = d.temporalFeedback
// gather 12 codebook rows on the host; every 12 frames run the decoder over
// a 25-frame window (12 frames of history), then iSTFT + overlap-add.
}
Check placement with MLComputePlan at session start; a successful prediction
on .cpuAndNeuralEngine does not prove the ANE ran it.
Every number on this card has a receipt in validation/ or in the GitHub
repo's validation/results/. The device results (placement, sustain runs,
decoder accuracy) are in the GitHub repo's
docs/validation-receipts.md
and the Surgical Inference paper. Quick local check:
pip install coremltools numpy torch
git clone https://github.com/mattmireles/magenta-realtime-2-iphone && cd magenta-realtime-2-iphone
hf download mattmireles/magenta-realtime-2-iphone --local-dir hf
# Depth rollout, FP32: zero token mismatches required
PYTHONPATH=exporters python validation/validate_depth_body_rollout.py \
--model-path hf/MRT2DepthBodyRollout.f32.mlpackage --float32
Data/com.apple.CoreML/weights/weight.bin)| Package | sha256 |
|---|---|
MRT2TemporalBodyStreamingCarry.mlpackage | 02657e24a19402fed8210e431e1a67baa0c8196d4d23f0c78dd931668a9c5a64 |
MRT2DepthBodyRollout.f16.mlpackage | 6c69ebae8cd7401fcb9927e3ff558d5b240cebdae2e29972d731ee08bd81c4f8 |
MRT2DepthBodyRollout.f32.mlpackage | af3ec4f9fadb84991b5dabbac58acd44294df7514226af2db63aa79659e304a9 |
SpectroStreamDecoder.f16.mlpackage | ceb3ed7d5b0286e69a937a17db253ce5a95e6bfa5560a187eb4c17de9e080f5d |
SpectroStreamDecoder.mlpackage | 38cbdf5ca97fe1744fa4d5a5caee23d50170a7eeb18daed1c40fe3a73aed9852 |
The temporal weights are shared with the 2-frame carry export; the package here
is the one-frame streaming graph (--frames 1 --streaming), which is the one
that runs on the ANE.
superseded/)Export metadata (and, for the temporal graphs, validation receipts) for earlier artifacts, kept as negative-result evidence. The packages themselves are not hosted; the superseded exporters reproduce them.
| Artifact | Why superseded |
|---|---|
MRT2TemporalBody (stateful, 48 ct.StateType) | One-frame fixed-slot graph compiles only as a partial ANE island, and its baked bias masks all 41 history slots. |
MRT2TemporalBodyCarry (2-frame bucket) | Under .cpuAndNeuralEngine it prints ANECCompile() FAILED and runs an all-CPU plan. |
MRT2DepthBody (fp32 logits + host sampling) | Twelve predictions per frame each re-read the weights. |
The temporal body cross-attends to a 256-dim compiled prompt
(source_encoded). The exporter
(export_conditioning.py)
compiles a text prompt through MusicCoCa and the MRT2 conditioning encoder on a
Mac, deterministically, with CFG baked in at reference strength (3.0, 1.0,
1.0).
We ship one conditioning vector, "smooth electronic", as a test vector, not a preset. Treat conditioning quality as experimental.
.cpuAndNeuralEngine. On the
CPU or GPU it is usable on typical content but returns non-finite values on
the hottest windows; on the A14's Neural Engine it is wrong. Use the FP32
decoder elsewhere.The model weights here are content-preserving derivatives (precision and memory-layout transforms only; no fine-tuning, pruning or distillation) of google/magenta-realtime-2 by Google DeepMind, redistributed under the same CC-BY-4.0 license. Use of the model remains subject to the upstream model's terms; you are responsible for what you generate.
Conversion code, validation harnesses and docs are Apache-2.0 in the GitHub repo.