[Bug/Perf] Lightning MTP batch thrashing (activate/park loop) & severe throughput drop with concurrent requests on MoE models
Hi Goushen and the oMLX team,
First of all, I want to express my deepest respect and gratitude for your incredible work. I am an absolute die-hard fan of oMLX! What you've achieved with version 0.7.0 is nothing short of a masterpiece. Reaching 80100 tok/s locally on Mac with a 125B-level model (Qwen 3.8 Flash) is absolute black magic. It feels like a physical ascension for local AI, and it has completely changed my daily workflow!
However, while heavily testing the new version, I noticed a severe performance cliff when running concurrent requests (e.g., batch=2) on the MoE model with MTP enabled. I digged into the logs and it seems I might have caught a scheduling bug regarding the new Lightning MTP batch state machine.
I would love to share my findings here to help make this masterpiece even more flawless!
The Symptom
When running a single stream, the generation flies at 6080+ tok/s. But the moment a second concurrent request kicks in (e.g., doing ASR or running an Agent tool in the background), the total throughput completely collapses to around 8~9 tok/s per sequence. The expected concurrency scaling (Continuous Batching) is not happening; instead, 1+1 becomes < 0.5.
Log Analysis & Root Cause
Looking at the logs, there are two fatal issues happening under the hood:
- Lightning MTP State Machine Thrashing (Infinite Activate/Park Loop) The scheduler realizes the MTP efficiency is low and decides to "park" it with a cooldown. However, the lack of an exponential backoff (or hysteresis) mechanism causes it to immediately re-activate the batch once the cooldown ends, only to park it again right after. This results in massive late-join-handoff overheads and synchronization bubbles.
- standard_ms Spiking to ~90ms due to MoE Expert Divergence In the logs, the standard_ms balloons to ~90ms (rows=2 standard_ms=89.877). Because Qwen 3.8 Flash is an MoE model, concurrent requests route to completely different experts, causing massive memory bandwidth contention on the Apple Silicon Unified Memory. With a 90ms base latency, forcing multi-sequence MTP simply starves the pipeline. Log Snippet (14:41:51 - 14:44:20):
14:41:51 - Lightning MTP batch activated for 2 sequences 14:42:06 - Lightning MTP batch parked: rows=2 standard_ms=89.877 cooldown=128 14:42:18 - Lightning MTP batch activated for 2 sequences 14:42:29 - Lightning MTP batch parked: rows=2 standard_ms=89.816 cooldown=256 ... 14:43:37 - Lightning MTP batch activated for 2 sequences 14:43:47 - Lightning MTP batch parked: rows=2 standard_ms=90.275 cooldown=256 ... 14:44:11 - Lightning MTP batch activated for 2 sequences 14:44:20 - Lightning MTP batch parked: rows=2 standard_ms=89.777 cooldown=128
(Side note: At 14:31:05, I also observed a massive prefix cache miss causing a 190k token re-prefill that locked the GPU for 3.5 minutes, starving my background ASR model to take 26 seconds for a simple task, though this might be related to KV cache eviction.) Suggested Improvements Dynamic MTP Disabling based on Latency/MoE: If standard_ms exceeds a certain threshold (e.g., > 40ms) during concurrency, completely disable the multi-sequence MTP path and fall back to standard Continuous Batching (or even pure sequential queuing), as the penalty of loading extra MTP draft weights is too high when memory bandwidth is already saturated by MoE expert fetching. Exponential Backoff for MTP Parking: Implement a stricter exponential backoff for the cooldown timer to prevent the state machine from thrashing between activated and parked. Thank you again for creating this god-tier software! I'll happily test any experimental fixes or branches if needed. Keep up the phenomenal work! ❤️ Best regards, A faithful oMLX fan
Mac Ultra 3 256
Source: jundot/omlx