Skip to content

serve: --lanes N flag (default 1) and tools/bench_concurrency.py, with M3 Ultra measurements - #37

Closed
chadhurley25075-png wants to merge 1 commit into
ashhart:mainfrom
chadhurley25075-png:hurley-lanes-flag
Closed

chadhurley25075-png wants to merge 1 commit into
ashhart:mainfrom
chadhurley25075-png:hurley-lanes-flag

Conversation

@chadhurley25075-png

Copy link
Copy Markdown
Contributor

Small one, on top of 0.3.4.1 (bb4b4a3), independent of the GLM work.

What

  • serve --lanes N (default 1): serve hardcoded lanes=1 for ChatApp; this plumbs the constructor argument through. Nothing else changes, so a server started as before behaves as before.
  • tools/bench_concurrency.py: fires N simultaneous streaming chat/completions (temperature 0, distinct prompts, 160 new tokens) and reports wall time, aggregate tok/s, per-stream decode tok/s, TTFT, and whether every concurrent answer is byte-identical to the same prompt answered alone. Standard library only; --tokenizer DIR counts tokens exactly with tokenizers when the server streams several tokens per event (the CUDA server does).
  • A short Concurrency section in the README with the table below, and a row in the serve options table.

Measured — M3 Ultra (Mac Studio, 256 GB, MLX 0.32.2), Vontra/Qwen3.8-Flash-Next-MLX-4bit-MTP, 0.3.4 (2f8e514), context 32768, one client on the LAN

lanes callers wall s aggregate tok/s per-stream tok/s (med / min) TTFT s (med / max) identical
1 (as shipped) 1 1.6 102.5 113.7 0.16 1/1
1 4 6.3 101.9 106.8 / 99.5 2.53 / 4.94 4/4
1 8 13.0 98.6 105.6 / 94.8 5.48 / 11.44 8/8
4 4 6.5 99.2 26.7 / 26.2 0.29 / 0.49 4/4
4 8 13.0 98.7 25.9 / 22.2 3.25 / 7.58 8/8
8 4 6.2 102.6 26.9 / 26.2 0.12 / 0.25 4/4
8 8 12.5 102.2 13.7 / 13.3 0.32 / 0.94 8/8

Server-side, rows a round stayed at a median of 2.4–2.8 at every lane count (max ~4), ~18 ms a round at 2–3 rows.

What we see on the M3 Ultra: lanes > 1 works and stays exact (24 of 24 answers identical, zero errors), and it buys latency fairness — eight callers get a first token in 0.3 s instead of 5.5 s, and the last one waits 0.9 s instead of 11.4 s — but not throughput: aggregate is pinned near 100 tok/s whatever the lane count, because the wide pass never got wider on this GPU. That is the difference from your M5 Max table (Nemotron 265 → 377 tok/s aggregate at 1 → 8 callers — your numbers, not ours), where the lane kernels' wide pass does the work. So on M1–M4 the flag is about fairness; on tensor-unit GPUs it should be about both. The default stays 1.

For what it is worth, our GLM-5.3-Flash family (PR #9) shows the same shape on the same Mac with lanes=4: aggregate pinned at ~55 tok/s, TTFT at 8 callers 5.3 s median instead of 10.1 s, 15 of 15 identical. And the CUDA server on two DGX Sparks is a byte-exact FIFO under load (30/30 identical across two passes), as cuda/server.py says.

Tests: pytest tests on the Mac, 303 passed / 69 skipped (the CUDA and real-weights ones). Full bench output and the Spark tables are in the bench's --out JSON if you want them.

Thanks for making concurrency a one-line change to expose — the engine already did all of this; the flag just lets a serve user reach it.

— Chad

`serve` hardcoded lanes=1 for ChatApp. `--lanes N` plumbs the constructor's lanes through (default 1: as before).
tools/bench_concurrency.py fires N simultaneous streaming requests at temperature 0 and reports aggregate and
per-stream tok/s, time to first token, and whether every concurrent answer is byte-identical to the same prompt
answered alone (standard library only).

Measured on an M3 Ultra (256 GB, MLX 0.32.2, Flash Next 4-bit MTP, 0.3.4) with lanes 1 / 4 / 8 and 1 to 8 callers:
aggregate stays ~100 tok/s at every lane count, but with 8 lanes eight callers get a first token in 0.3 s instead of
5.5 s and the last waits 0.9 s instead of 11.4 s; 24 of 24 answers identical to the serial ones. The README's
Concurrency section carries the table and cites the author's M5 Max Nemotron numbers (265 -> 377 aggregate) as his.
@ashhart

ashhart commented Sep 27, 2026

Copy link
Copy Markdown
Owner

Thanks @chadhurley25075-png for the proposal and the measurements. In 0.3.5, which ships tonight, --parallel auto is on by default and shares each verification round across streams, so aggregate throughput rises with concurrency instead of only latency becoming fairer. That supersedes --lanes on 0.3.4.1, so we're closing this unmerged. A rerun of your bench_concurrency.py workload on 0.3.5 with --parallel would be very welcome, and your GLM work in #9 is credited when it lands in 0.3.5.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants