Stormin' The Castle

tinygradspeech-recognitionvoiceapple-siliconnvidia

Parakeet on tinygrad: NVIDIA's speech recognizer in ~700 lines, faster than MLX on a Mac, and the same code on an RTX 5090

by John Robinson @johnrobinsn

Parakeet on tinygrad

Numbers measured 2026-11-21/22 on a base MacBook Pro M5 (32 GB) and an RTX 5090 in a Thunderbolt dock on the same Mac. Code: parakeet-tinygrad.

TL;DR

I ported NVIDIA's Parakeet TDT 0.6B v2, one of the best open English speech-to-text (STT) models, to tinygrad. (It topped Hugging Face's Open ASR Leaderboard when NVIDIA released it in May 2025, and it's still near the top for accuracy while being one of the fastest models on the board.) It reads NVIDIA's original .nemo checkpoint directly (no PyTorch, no NeMo at runtime), and:

Utterance parakeet-mlx (M5) tinygrad, M5 GPU tinygrad, RTX 5090 eGPU
1.5 s 39.6 ms 24.6 ms 28.8 ms
6 s 76.2 ms 49.7 ms 39.8 ms
16 s 178.0 ms 127.2 ms 63.1 ms
30 s 283.5 ms 248.6 ms 78.1 ms

Warm latency for one utterance, JITBEAM=2. parakeet-mlx runs in bf16, the precision of its Hugging Face checkpoint; tinygrad runs in fp16, its default here (in bf16 it's within a few percent: 24.2, 49.8, 129.5 and 259.3 ms, still ahead of MLX at every length). The 5090 column uses 2 s length buckets (see below).

Time to transcribe one utterance vs its length: parakeet-mlx and tinygrad on the M5, and tinygrad on the RTX 5090

It wasn't all smooth: there's a cold-start cost (with a fix), a few tinygrad bugs (with workarounds and upstream repros), and a regression that means the eGPU currently needs an older tinygrad. All of that is below.

Why tinygrad, when MLX already works?

This port is the first step in moving AvatarVoice, my real-time voice chat with a lip-synced diffusion avatar, onto tinygrad. AvatarVoice already runs on a MacBook: the avatar's flow transformer in MLX, everything else on PyTorch's Metal backend or other runtimes. Speech recognition uses Parakeet through parakeet-mlx. So why rewrite working code?

A sovereign stack. AvatarVoice today stands on PyTorch, MLX, ONNX Runtime, CTranslate2, vLLM and a Rust TTS runtime, each with its own kernels, memory allocator and opinions. tinygrad is one framework from the tensor API down to the GPU command queues. On macOS it even drives an NVIDIA card through its own userspace driver, with no CUDA runtime and no NVIDIA kernel driver. (Honest caveat: it still needs NVIDIA's nvcc to produce machine code, which on a Mac runs in a Docker container.) The goal is one stack I understand end to end, for every model in the app.

The allure of tiny. tinygrad master is about 35,000 lines of Python, excluding auto-generated hardware bindings. Leave out its 16 hardware backends too and it's about 25,700. That's small enough to actually read. When something broke during this port (and things did), the fix was always "open the file and look": the shape simplifier, the strided-conv bookkeeping, the JIT, the device scan. I never had to treat the framework as a black box. The port itself is 724 lines, model and weight loader, docstrings included (plus a 60-line shim that backports one tinygrad fix for the eGPU's older tinygrad).

BEAM search and fusion. tinygrad builds a lazy graph, fuses operations into kernels, and with JITBEAM=2 it searches over each kernel's tiling, unrolling and vectorisation by timing real candidates on your GPU. On this port that took the encoder from 123 ms (default kernels) to 42 ms on the first try, with no hand-written kernels. The search costs about a minute per graph, once; the results are cached on disk.

Same model, many GPUs. The model file has no Metal- or CUDA-specific code. The M5 numbers and the RTX 5090 numbers above come from the same model.py; switching is DEV=NV. And BEAM tunes the kernels separately for each GPU.

MLX is excellent. parakeet-mlx is a clean port, and it's the speed baseline here. But MLX is Apple-only by design, and for AvatarVoice I want one stack that can be tuned across the M5's integrated GPU, a 5090 in a dock, and a Linux box.

The model in one paragraph

Parakeet TDT is NVIDIA's FastConformer encoder plus a Token-and-Duration Transducer decoder (papers: Rekesh et al., arXiv:2305.05084; Xu et al., arXiv:2304.06795). Audio becomes a 128-bin log-mel spectrogram at 100 frames/s. An 8× convolutional subsampler feeds 24 Conformer layers (d = 1024, 8 heads; macaron feed-forwards, Transformer-XL relative-position attention, a depthwise convolution with BatchNorm). The decoder is RNN-T-style, but the joint network predicts both a token and how many encoder frames to skip (0–4). A 2-layer LSTM tracks the emitted text. 600M parameters, CC-BY-4.0.

Porting: match the reference, not another port

Weights without torch. A .nemo file is a plain tar holding a YAML config, a torch zip checkpoint and the tokenizer files. tinygrad.nn.state.tar_extract + torch_load read it straight from disk. I named every module after NeMo's, so load_state_dict(strict=True) takes all 725 tensors with zero renaming. The checkpoint even carries the STFT window and mel filterbank, so no librosa either.

The audio front-end. parakeet-mlx's log-mel differs from NeMo's in four small ways:

NeMo parakeet-mlx
Window symmetric Hann periodic Hann
STFT padding zeros reflect
Power spectrum re² + im² (|re| + |im|)²
Log guard log(x + 2⁻²⁴) log(x + 1e-5)

The model shrugs these off, but parity is the point, so I followed NeMo. tinygrad has no FFT, so the STFT is framing (unfold) plus a matmul against a 512 × 514 cos/sin basis, which costs almost nothing at 257 bins.

Parity. A small script in a separate environment (with NeMo installed) dumps reference tensors. The tests then compare against them without torch: log-mel within 6e-5 relative error, encoder output within 8e-7 (fp32), tokens identical. The first end-to-end run got NeMo's transcript on the first try, including NeMo's own mistake of hearing "tinygrad" as "Tenogrid" in my synthetic test clip.

Making it fast

The first correct version took 604 ms for a 5.4 s clip. The path to 45 ms:

Step Features + encoder Decode End-to-end
eager everything 354 ms 250 ms 604 ms
TinyJit + length buckets + on-device decoding 240 25 266
+ BEAM search 51 23 77
+ bf16, 8 decode steps per sync, fused decoder tables 38 8 47
final defaults (fp16, one graph for all lengths) ~32 ~10 45

TinyJit captures the ~750 kernels of the encoder once and replays them, instead of rescheduling them in Python on every call.

Decoding on the GPU. Greedy TDT is a data-dependent loop: emit a token or a blank, then skip 0–4 frames, with a cap of 10 symbols per frame. The naïve version round-tripped to Python twice per step. I moved the whole rule onto the GPU: the frame pointer, the symbol counter, the LSTM state and the last token are tensors, updated with where. A JIT'd chunk runs 8 steps per sync. Interestingly, smaller chunks were faster: the sync is cheap, and the real cost is reading the decoder's weights every step. So I fused them: layer 0's input gates depend only on the token and become a precomputed lookup table, and layer 1 does one matmul instead of two. With those tables in 16-bit floats, decoding fell from 250 ms to 8 ms, 4× faster than parakeet-mlx's decoder.

fp16, and an overflow. fp16 first produced an empty transcript. Tracing per-layer magnitudes showed the residual stream peaking around 1,900, comfortably inside fp16's 65,504. But LayerNorm squares it (3.6 million). Running only the LayerNorms in fp32 fixed it. On LibriSpeech, fp16 then matched NeMo as closely as fp32 (both 0.02% WER against NeMo's own output, vs 0.10% for bf16), and it's the fastest on the M5.

One graph for every length

TinyJit wants fixed shapes, but every utterance has a different length. The first answer was length buckets: pad to the next multiple of 2 s and mask the padding exactly as NeMo masks a batch, so the results are identical. That works, but each bucket is its own graph, with its own ~3 s capture per process and ~1 minute of BEAM search per machine.

tinygrad supports symbolic shapes: pass x[:, :Variable("n", 1, max).bind(n)] and one captured graph serves every n. Getting Parakeet through that hit three walls in tinygrad's shape simplifier, and each needed an exact rewrite:

  1. Strided convolutions. The pooling helper computes smax(1, ceildiv(o·s − d, i)), and after one stride-2 conv the simplifier can't prove that equals 1. Fix: 1×1 convs as matmuls (which is what they are), and stride-2 convs as stride 1 in time followed by keeping every other frame.
  2. Transformer-XL's rel_shift. Its reshape fails an element-count check: k·(16k−8) == k·(2k−1)·8 can't be proven, though both sides are 8k(2k−1). Fix: the same shift as one flat slice.
  3. A performance cliff. Once it ran, the symbolic encoder was 2.5× slower in attention. The relative-position axis has length 2T − 1, an odd number with no known factors, and the optimiser can't tile it. One matmul ran 12.7× slower than with concrete shapes.

The fix for the third turned out to be my favorite part of the project. For head hh, the position term is (qi+vh) Wh pe(i−j)(q_i + v_h)\,W_h\,\mathrm{pe}(i-j), where vhv_h is the head's learned position bias, WhW_h its slice of the position projection, and pe\mathrm{pe} holds sinusoids (at frequencies ωk\omega_k) of the distance between positions ii and jj. Expanding sin and cos of a difference,

ui⋅pe(i−j)=∑kcos⁡(j ωk)(aksin⁡(i ωk)+bkcos⁡(i ωk))+sin⁡(j ωk)(bksin⁡(i ωk)−akcos⁡(i ωk))u_i \cdot \mathrm{pe}(i-j) = \sum_k \cos(j\,\omega_k)\big(a_k \sin(i\,\omega_k) + b_k \cos(i\,\omega_k)\big) + \sin(j\,\omega_k)\big(b_k \sin(i\,\omega_k) - a_k \cos(i\,\omega_k)\big)

with ui=(qi+vh) Whu_i = (q_i + v_h)\,W_h, and aka_k, bkb_k its even and odd entries. So the whole term is one ordinary T × T matmul per head: no 2T − 1 table, no shift trick. It's exact up to rounding (encoder within 3e-6 of NeMo in fp32, identical LibriSpeech accuracy). It's the same identity that makes RoPE work, applied after the fact to Transformer-XL-style positions. With it, and with lengths padded to multiples of 8 encoder frames (0.64 s), the single symbolic graph runs within ~10% of fixed-shape kernels. On short clips it's even faster, because it pads less.

Startup: from ~38 s to 1.5 s

With every BEAM result cached on disk, a fresh process still spent about 30 s before its first fast transcription. Profiling showed tinygrad's code generation for the symbolic graph's host-side program (the C program that issues all ~800 kernel launches), which isn't cached between processes. Three fixes:

Result: load in 1.2–2.0 s, first transcription 0.4 s, then 45 ms.

Accuracy

LibriSpeech test-clean, all 2,620 utterances (5.4 h), WER with the Whisper English normaliser (as the Open ASR Leaderboard does):

System WER Identical to NeMo (normalised)
NVIDIA model card 1.69% —
NeMo, fp32, CPU (reference run) 1.64% —
tinygrad M5, fp16, symbolic (default) 1.63% 2,611 / 2,620
tinygrad M5, fp32 1.62% 2,611
tinygrad M5, bf16 1.62% 2,579–2,580
tinygrad RTX 5090 eGPU, fp16, buckets 1.63% 2,611

The RTX 5090 over Thunderbolt

tinygrad's TinyGPU app plus its driver extension let it drive NVIDIA (Ampere+) and AMD GPUs over USB4/Thunderbolt on macOS. I put an RTX 5090 in an ADT-Link UT4G dock on the same MacBook (40 Gb/s). The snags, in order:

Once running, it matched NeMo on the parity tests, and on all of LibriSpeech test-clean (1.63% WER, 2,611/2,620 identical to NeMo). Its transcripts are raw-identical to the M5's on 2,591 of 2,620 utterances (both fp16, length buckets). Of the other 29, 25 differ only in punctuation or casing, and 4 in one word, mostly rare names ("Lyucadia" vs "Leucadia"): different GPU, compiler and tinygrad version, and essentially the same answers. The latency table at the top tells the story. Below ~3 s the M5's integrated GPU wins, because launching each of ~800 kernels over Thunderbolt costs ~26 µs and dominates tiny workloads: the encoder runs at ~4 TFLOP/s on a card capable of far more. From 4 s the 5090 is ahead, and at 30 s it does 78 ms (3.2× the M5). On a 10-minute file it takes 10.4 s against 35 s on the M5, with the same words (two punctuation marks differ).

One graph on the 5090 too. Ten bucket graphs meant ~90 s of capture every time a process started. Two fixes got the single symbolic graph working on the old commit. Its compiler compared a loop bound with .val, which fails when the bound is symbolic; master had already fixed that, so a 60-line shim (compat.py) swaps master's version in when it detects the old code, including in tinygrad's compile worker processes. Then the graph ran, but took 4.9 s to encode 11 s of audio, growing quadratically. One kernel was nearly all of it: a samples × samples reduction from NeMo's length mask arange(L) < n_samples. tinygrad builds arange as a cumulative sum; with a concrete length it's rewritten to an index, but with a symbolic length on the old commit it stays a literal O(L²) reduction. Doing the pre-emphasis on the host (the padding is already zero) removed the mask. Now a 5090 process gives its first transcript 6.2 s after it starts, from the pickled graph, and runs at 45 / 53 / 70 ms for 1.5 / 4.6 / 11 s, against ~30 / 45 / 80 ms with buckets.

Why MLX is the baseline

The comparison that matters for a Mac is MLX, which is Apple's own framework, on the same GPU, and that's what every number above is measured against. For NVIDIA I've reported tinygrad on its own; CUDA doesn't run on macOS anyway (the 5090 here has no NVIDIA driver, only tinygrad's). For anyone with a Linux box who's curious, scripts/linux_cuda_baselines.sh runs the same tests for NeMo on CUDA, onnxruntime-gpu and tinygrad DEV=CUDA.

Long audio: a caveat about the model

I also ran a 10-minute file (two LibriSpeech chapters, two speakers) in a single pass. Both NeMo and the port drop the second chapter: the first 8.4 minutes come out at 2.1% WER, then almost nothing. That's Parakeet's behaviour in one long full-attention pass, not the port's. The port's transcript is within 0.75% WER of NeMo's. fp32, fp16 and both position-term forms give identical output; the 5090's differs only in two punctuation marks. For long recordings NeMo recommends local attention or chunked inference; overlapping ~30 s chunks through the fast graph is the obvious next step.

What I'd tell the tinygrad folks

All reproduced on master as of 2026-11-22, with minimal repros in the repo's upstream/ folder:

Honest limits

Try it

The code is in the parakeet-tinygrad repo. On an Apple Silicon Mac (or anywhere tinygrad runs):

git clone https://github.com/johnrobinsn/parakeet-tinygrad && cd parakeet-tinygrad
uv sync
JITBEAM=2 uv run python scripts/warmup.py # once per machine, ~45 s on an M5
JITBEAM=2 uv run python scripts/transcribe.py samples/hello.wav

The checkpoint downloads from Hugging Face on first use. The README covers the Python API, the settings and the eGPU setup.

Parakeet TDT 0.6B v2 is NVIDIA's (CC-BY-4.0). The port follows NVIDIA NeMo (Apache-2.0) and is tested against it. parakeet-mlx by senstella informed the module layout and is the speed baseline. LibriSpeech (Panayotov et al., CC BY 4.0) for evaluation. tinygrad by tiny corp. My code is Apache-2.0, the same as NeMo.

What's next

Parakeet was the first of AvatarVoice's models to move to tinygrad, and the rest followed: turn-taking, the TTS, the LLM, the portrait crop and the avatar's diffusion model. Next week I'll share the whole AvatarVoice project ported to tinygrad: the complete voice-chat avatar on one framework, running on the M5's GPU or on the 5090. After that, deep dives on the talking head and the voice.


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