Realtime Talking Avatar on an M5 MacBook
by John Robinson @johnrobinsnEvery frame of that face is being generated live, by a diffusion model, on my MacBook.
It's a base M5 MacBook Pro with 32 GB. The model draws a 512×512 talking face at 25 fps, lip-synced to the avatar's own voice, and it does it about twice as fast as realtime. On the same laptop, at the same time, run the speech recognition that hears me, the LLM that decides what to say, and the voice that says it. There's no cloud, no NVIDIA GPU, and nothing leaves the machine.
You can run it yourself with one command:
curl -LsSf https://raw.githubusercontent.com/johnrobinsn/AvatarVoice/main/install.sh | bash
avatarvoice run
You need an Apple Silicon Mac with 32 GB of memory. I've tested it on an M5, and I'd love to hear how it runs on yours. (Details in Try it below.)
From a GPU workstation to a laptop #
Last week I built the first version on Linux with two NVIDIA RTX PRO 6000 cards. The model is AvatarForcing (Ki et al., CVPR 2026). I assumed a diffusion video model running alongside speech recognition, an LLM and text-to-speech would need all the compute I could throw at it, and even then the first version took 437 ms on average to generate each 400 ms block of video, just short of realtime.
But the voice half of the project started life on a Mac, as macvoice, and I wanted the face there too. So I tried porting it to my MacBook Pro, a base M5, not even the M5 Pro I had planned around. I expected something that sort of worked, slowly. That isn't what happened.
The numbers #
AvatarForcing generates video in blocks of 10 frames, 400 ms of video at 25 fps. To stay realtime, each block has to be generated in under 400 ms.
| MacBook Pro, M5 (base), 32 GB | RTX PRO 6000 Blackwell, single GPU | |
|---|---|---|
| Time per 400 ms block (steady state) | ~210 ms | ~210 ms |
| Realtime factor | ~0.5× (about 2× faster than realtime) | ~0.5× |
| Avatar memory | ~5.5 GB unified | ~5 GB VRAM resident |
| Whole stack (avatar + STT + 4B LLM + TTS) | ~11.5 GB | ~18 GB VRAM |
The laptop matches the tuned single-GPU Blackwell number block for block. It's about twice as fast as the first CUDA version from my earlier post, and it leaves enough headroom for the rest of the voice pipeline on the same chip. The whole thing runs comfortably in 32 GB of unified memory.
I honestly didn't think the M5 with MLX would get me here. But it turns out that for small batch inference the unified memory and MLX the M5 is very capable.
What actually got ported #
AvatarForcing has three neural pieces per block: a flow transformer that denoises motion latents (run about 9 times per block), a motion decoder that turns those latents into 512×512 frames, and wav2vec2, which encodes the avatar's speech audio.
The flow transformer moved to MLX. It couldn't run on PyTorch's Metal backend at all, because the sampler computes its coefficients in float64 and Apple GPUs don't do float64. Those coefficients are precomputed once on the CPU now, and the transformer itself is a line-for-line MLX port that loads the original checkpoint. It uses mx.fast.scaled_dot_product_attention and mx.fast.rope, which matches the model's RoPE with no position table, so there's no length limit. It takes about 58 ms per block.
I verified it against the PyTorch code with 89 equivalence checks, from individual modules up to a full multi-block sampling loop, all within 2e-5 relative error in float32. Rendered frames come out at a per-frame SSIM of 0.9975 against the float32 PyTorch reference.
The motion decoder stayed on PyTorch (MPS), and turned out to be the real bottleneck. As shipped it took 613 ms per block on the Mac: by itself, it was too slow for realtime. The actual convolution math is only 60–70 ms. The rest was overhead:
- modulated convolutions run as grouped per-sample convs;
- the upsampling filter run as a single-channel conv over every feature map;
- autocast silently promoting every activation back to float32;
- a sampling grid rebuilt in numpy and copied from the CPU on every call;
- long chains of unfused elementwise ops over 170 MB tensors.
I rewrote those pieces to be mathematically exact (identical to 2.4e-5 in float32), switched to pure float16 and let torch.compile fuse the rest. That brought it to 150 ms, a 4× speedup without changing the model. I tried porting the decoder to MLX as well, but MLX convolutions were slower than Metal's at 512×512, so it stays on PyTorch.
wav2vec2 also stays on PyTorch MPS. It runs once per spoken phrase, not per block, so it costs only a few milliseconds.
The result is a hybrid pipeline (MLX for the transformer, PyTorch MPS for the rest) sharing the Mac's unified memory, so nothing gets copied between "CPU" and "GPU".
Precision #
I ran the flow transformer in float32 by default. bfloat16 is about 25 ms per block faster, but the diffusion sampler amplifies its rounding errors over a stream. PyTorch's own bfloat16 drifts by the same amount, so this isn't an MLX problem. In float32 the Mac's output is actually closer to the reference than the CUDA app's bfloat16, and it still fits in the realtime budget.
A few things I found along the way #
- The checkpoint's attention masks are stored inverted. The app never loads them (it regenerates the masks), so it doesn't matter in practice. But loading the checkpoint with
strict=Truewould silently invert attention. - One denoising step per block is a no-op. Its output equals its input, so the MLX sampler skips it (bit-identical) and saves about 4 ms per block.
The rest of the stack on the Mac #
| Mac | |
|---|---|
| STT | Parakeet TDT 0.6B v2 on MLX, 8-bit (from macvoice): ~100 ms per utterance |
| LLM | Qwen3-4B-Instruct (4-bit) via mlx_lm.server: ~2.4 GB |
| TTS | Phonon |
| VAD / end-of-turn | Silero + Smart Turn v3.2 |
Replies start about 2.3–2.8 s after you stop talking.
Try it #
On an Apple Silicon Mac with 32 GB:
curl -LsSf https://raw.githubusercontent.com/johnrobinsn/AvatarVoice/main/install.sh | bash
avatarvoice run
The installer sets up everything in ~/.avatarvoice (nothing system-wide), downloads the models and adds an avatarvoice command. A completely fresh install took about 3 minutes on my connection, and the app is ready about 40 seconds after avatarvoice run. The same command works on Linux with an NVIDIA GPU. It uses the browser's echo cancellation, so the avatar doesn't hear its own voice coming out of the speakers.
The code is in the AvatarVoice repo. If you just want the model on a Mac without the voice chat, the MLX port is also published on its own as avatarforcing-mlx, a package with a CLI that downloads and converts the original weights.
AvatarForcing is the work of Taekyung Ki and co-authors at KAIST (project page, paper, code). They released it under CC BY-NC 4.0, and I chose the same license for both of my projects to respect that choice, so all of it is for non-commercial use only. The avatar portraits are AI-generated.
Futures #
- Re-measure and trim the end-to-end reply latency.
- Voice cloning for TTS, so each avatar can have its own voice.
- Try an M5 Pro or Max; the base chip already has headroom, so a bigger one might allow higher resolution or a larger LLM.
- Better reanchoring strategies for long sessions.
Get more content like this. Occasional, low-cadence, real-news-only.
Follow along at storminthecastle.com, or reply if you're building in this space.
Share on Twitter | Discuss on Twitter
John Robinson © 2022-2026
- Previous: Giving a Face to Your AI Assistant