Streaming-video VLMs in MLX are LM-prefill-bound — what does M5's Neural Accelerator do to the frontier? #3829
katlun-lgtm
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've been building a bounded-memory streaming-video path for VLMs in mlx-vlm (ties into #492): ingest frames one at a time into a persistent KV cache, keep an attention-sink + the most-recent frames, evict the oldest vision spans, and re-anchor survivors to contiguous RoPE positions — instead of
load_video()'s pre-sample-all-frames + O(T) KV growth. It runs on 1-D-RoPE models (SmolVLM / Idefics3) with no model changes, and the re-anchor is numerically exact vs a fresh prefill (max|Δ| = 0).Building it, I measured where the per-frame time actually goes on an M3 Max — and I think it points at a nice M5 question, so sharing here.
Where the time goes (per frame, M3 Max)
Two things fall out:
So the streaming frontier is gated by per-frame LM-prefill GEMM on a large model.
The M5 question
M5's GPU adds a Neural Accelerator (matrix unit) per core — aimed exactly at that matmul inner loop, which streaming prefill is nothing but, run once per frame. So the falsifiable hypothesis is that M5 shifts the streaming Pareto frontier: at a fixed per-frame latency budget you could run a more capable model (higher accuracy) or a higher frame rate than M3 Max allows.
The thing I'd genuinely like to know from folks closer to the Metal backend:
What I'd measure (harness already exists)
Same code, cross-generation (M3 Max → M4 → M5), reusing the streaming benchmark I've already written: per-frame encode/prefill split, prefill tok/s on the qmv/GEMM microbench, answer TTFT, and the money curve — accuracy at equal latency budget (the largest model whose per-frame prefill fits budget B, M3 Max vs M5). KV memory stays bounded/flat regardless of chip (algorithmic, a good null control).
I can run the M3 Max numbers now. If anyone has M5 access or wants specific configs in the comparison, I'm glad to fold them in.
Code + harness (fork): the streaming path and the full benchmark harness + raw JSON live on
feat/streaming-video-kv—examples/phase2b_scaled.py,fastvlm_size_sweep.py,phase2c_equal_memory.py,streaming_video_demo.py(+ the committed*_results.json).Curious whether this matches what others are seeing on M5, and whether the "does MLX already use the Neural Accelerators" question has a known answer. 🙏
Beta Was this translation helpful? Give feedback.
All reactions