[GH-ISSUE #602] maya-mm3: the single-conversation server ignores the calibrated chunk from prefill-tune.txt (v1.1.34/v1.1.35: prompts read at ~155 tok/s instead of ~340 on one 48 GB GPU) #248

Closed
opened 2026-10-29 21:23:13 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @talisp on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/602

In short: on v1.1.34, ./maya.sh --calibrate picks chunk 4096 for MiniMax-M3.1 here and writes it to prefill-tune.txt. The engine sizes its buffers for 4096 (so fewer experts fit in VRAM: 878 instead of 961), but the server of one conversation still reads prompts in chunks of 1024. We pay for the bigger chunk and get none of its speed: prompts read at 155-161 tok/s, the same as before the calibration.

The cause is one argument. serve() gets o.chunk from main, and main's options never see prefill-tune.txt. Model::load applies the calibrated chunk to its own copy of the options. serve_multi (--parallel) already asks the model (m.chunk()), so only the one-conversation server is affected. With a one-line change (below), the same calibration reads prompts at 340-365 tok/s, exactly what --chunk 4096 given by hand gives.

A follow-up from #552, where the larger chunk was found. Thanks for the quick turnaround there!


Where it happens (v1.1.34, and still in v1.1.35)

  • src/mm3/mm3_model.cu:3058: Options o = o_in; - Model::load works on a copy.
  • src/mm3/mm3_model.cu:3099: if (k == "chunk" && !o.chunk_given && v >= 64 && v <= 16384) o.chunk = v; - the calibrated chunk lands in that copy (the buffers are sized from it).
  • src/mm3/mm3_main.cpp:1767 (v1.1.35; 1764 in v1.1.34): return serve(m, eos, o.chunk, ...) - main's own o.chunk, still the default 1024.
  • src/mm3/mm3_main.cpp:416: serve() reads the prompt in calls of chunk tokens.
  • src/mm3/mm3_main.cpp:993: serve_multi uses m.chunk() > 0 ? m.chunk() : chunk - correct.
  • With --chunk N on the command line, main sees N too, which is why --chunk 8192 always worked for us.

The change we tested (local only)

// src/mm3/mm3_main.cpp:1767 (v1.1.35)
return serve(m, eos, m.chunk() > 0 ? m.chunk() : o.chunk, o.dspark, dspark_conf, dspark_cost, kvf, profile_out);

The same expression serve_multi uses. m.chunk() returns 0 on the tensor-parallel path, which keeps o.chunk there. (Line 1766, the serve_multi call, could take the same for consistency; it doesn't need it.)

Numbers

Same model, pack, context and flags in every row; only the chunk changes (and the threads, in the one row that says so). One start each, the model files' page cache dropped before each start. Prompt reading in tok/s at three lengths (9.6K, 39K and 159K tokens), decode is the mean of six code prompts (600 tokens each).

Run Chunk the server reads with Experts in VRAM Decode tok/s Prompt 9.6K Prompt 39K Prompt 159K
Setup's config (prefill-tune.txt from v1.1.32: chunk=1024) 1024 961 18.35 156.7 163.3 136.5
After ./maya.sh --calibrate (chunk=4096) 1024 (the bug) 878 17.90 155.2 161.0 135.8
Calibrated + --chunk 4096 by hand 4096 878 17.98 337.4 365.1 241.9
Calibrated + the one-line change, no --chunk 4096 878 17.95 340.1 364.3 240.9
--chunk 8192 --cpu-threads 28 (earlier, #552) 8192 767 17.18 403.1 465.5 271.5
The one-line change + --chunk 8192 (30 threads) 8192 767 18.03 404.6 464.5 270.0
The one-line change + --chunk 16384 (30 threads) 16384 541 17.35 511.7 518.1 276.3

The calibration's own line:

mm3-prefill-1|NVIDIA L40S-48Q sm_89 48GB|rt12090|drv12040	chunk=4096 gemm=0 tok_s=371.6 default_tok_s=136.3 tokens=4096

Its 371.6 tok/s matches what the server reaches once it really uses 4096 (337-365).

Why the old calibration wrote 1024

Before v1.1.34 the rule only raised the chunk above the default where every routed expert fits in VRAM. Here they don't (961 resident), so it kept the default and wrote chunk=1024. That is why the bug never showed until v1.1.34 started picking larger chunks where experts are staged. Anyone who recalibrates on v1.1.34 with experts outside VRAM and serves one conversation (no --parallel) is affected. That may include #580 (4x RTX 3090, Maya-S, calibration wrote chunk 1024, asks about prefill chunking), if a recalibration there picks a larger chunk.

A second, smaller point: the calibration can't see chunks above 4096

tools/calibrate_mm3_prefill.py measures on a ~4K-token prompt (TOKENS = 4096), so a chunk of 8192 or more reads that prompt in one call, the same as 4096, and can never win. On real prompts here it does:

  • 8192 against 4096: prompts 19% / 28% / 12% faster (9.6K / 39K / 159K), decode the same (18.03 vs 17.95), with 767 experts in VRAM instead of 878.
  • 16384 against 4096: prompts 50% / 42% / 15% faster, decode 3.3% slower (541 experts in VRAM). Just past the script's DECODE_LOSS = 0.03.
  • (The --cpu-threads 28 row is from #552: in that single start, the 2 threads fewer cost ~5% of decode; the chunk did not.)

Measuring on a longer prompt (16K, say, or the chunk's own size times two) would let the calibration weigh that trade itself. The Strata engine saw the same per-chunk cost of copying the experts VRAM doesn't hold, in its hybrid mode (Niko1221/Strata#4332: its chunk rule had no 4096 arm; adding one read prompts 51-76% faster on a 16 GB card).

Setup

  • GPU: 1× NVIDIA L40S-48Q (vGPU, 48 GB, sm_89), CUDA driver API 12.4 (vGPU guest), CUDA 12.9 toolkit.
  • CPU and RAM: Xeon Platinum 8580 VM, 32 vCPUs (no SMT), ~504 GB RAM, Linux 6.8. Model on a local NVMe.
  • Model: MiniMax-M3.1-Flash EXL3 3.55 bpw, Maya v1.1.34 (maya-mm3 built with -DCMAKE_CUDA_ARCHITECTURES=89).
  • Config: --max-context 262144 --kv-streaming on --vision on --dspark on --profile data/expert-profile-mm3.bin, no --cpu-threads (30 threads), no --parallel.
  • Server: maya.py --plain, one request at a time.
Originally created by @talisp on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/602 **In short:** on v1.1.34, `./maya.sh --calibrate` picks chunk 4096 for MiniMax-M3.1 here and writes it to `prefill-tune.txt`. The engine sizes its buffers for 4096 (so fewer experts fit in VRAM: 878 instead of 961), **but the server of one conversation still reads prompts in chunks of 1024.** We pay for the bigger chunk and get none of its speed: prompts read at 155-161 tok/s, the same as before the calibration. The cause is one argument. `serve()` gets `o.chunk` from `main`, and `main`'s options never see `prefill-tune.txt`. `Model::load` applies the calibrated chunk to its own copy of the options. `serve_multi` (`--parallel`) already asks the model (`m.chunk()`), so only the one-conversation server is affected. With a one-line change (below), the same calibration reads prompts at **340-365 tok/s**, exactly what `--chunk 4096` given by hand gives. A follow-up from #552, where the larger chunk was found. Thanks for the quick turnaround there! --- ### Where it happens (v1.1.34, and still in v1.1.35) - `src/mm3/mm3_model.cu:3058`: `Options o = o_in;` - `Model::load` works on a copy. - `src/mm3/mm3_model.cu:3099`: `if (k == "chunk" && !o.chunk_given && v >= 64 && v <= 16384) o.chunk = v;` - the calibrated chunk lands in that copy (the buffers are sized from it). - `src/mm3/mm3_main.cpp:1767` (v1.1.35; 1764 in v1.1.34): `return serve(m, eos, o.chunk, ...)` - `main`'s own `o.chunk`, still the default 1024. - `src/mm3/mm3_main.cpp:416`: `serve()` reads the prompt in calls of `chunk` tokens. - `src/mm3/mm3_main.cpp:993`: `serve_multi` uses `m.chunk() > 0 ? m.chunk() : chunk` - correct. - With `--chunk N` on the command line, `main` sees N too, which is why `--chunk 8192` always worked for us. ### The change we tested (local only) ```cpp // src/mm3/mm3_main.cpp:1767 (v1.1.35) return serve(m, eos, m.chunk() > 0 ? m.chunk() : o.chunk, o.dspark, dspark_conf, dspark_cost, kvf, profile_out); ``` The same expression `serve_multi` uses. `m.chunk()` returns 0 on the tensor-parallel path, which keeps `o.chunk` there. (Line 1766, the `serve_multi` call, could take the same for consistency; it doesn't need it.) ### Numbers Same model, pack, context and flags in every row; only the chunk changes (and the threads, in the one row that says so). One start each, the model files' page cache dropped before each start. Prompt reading in tok/s at three lengths (9.6K, 39K and 159K tokens), decode is the mean of six code prompts (600 tokens each). | Run | Chunk the server reads with | Experts in VRAM | Decode tok/s | Prompt 9.6K | Prompt 39K | Prompt 159K | |---|---|---|---|---|---|---| | Setup's config (`prefill-tune.txt` from v1.1.32: chunk=1024) | 1024 | 961 | 18.35 | 156.7 | 163.3 | 136.5 | | After `./maya.sh --calibrate` (chunk=4096) | **1024** (the bug) | 878 | 17.90 | 155.2 | 161.0 | 135.8 | | Calibrated + `--chunk 4096` by hand | 4096 | 878 | 17.98 | 337.4 | 365.1 | 241.9 | | Calibrated + the one-line change, no `--chunk` | 4096 | 878 | 17.95 | **340.1** | **364.3** | **240.9** | | `--chunk 8192 --cpu-threads 28` (earlier, #552) | 8192 | 767 | 17.18 | 403.1 | 465.5 | 271.5 | | The one-line change + `--chunk 8192` (30 threads) | 8192 | 767 | **18.03** | 404.6 | 464.5 | 270.0 | | The one-line change + `--chunk 16384` (30 threads) | 16384 | 541 | 17.35 | **511.7** | **518.1** | **276.3** | The calibration's own line: ``` mm3-prefill-1|NVIDIA L40S-48Q sm_89 48GB|rt12090|drv12040 chunk=4096 gemm=0 tok_s=371.6 default_tok_s=136.3 tokens=4096 ``` Its 371.6 tok/s matches what the server reaches once it really uses 4096 (337-365). ### Why the old calibration wrote 1024 Before v1.1.34 the rule only raised the chunk above the default where every routed expert fits in VRAM. Here they don't (961 resident), so it kept the default and wrote `chunk=1024`. That is why the bug never showed until v1.1.34 started picking larger chunks where experts are staged. Anyone who recalibrates on v1.1.34 with experts outside VRAM and serves one conversation (no `--parallel`) is affected. That may include #580 (4x RTX 3090, Maya-S, calibration wrote chunk 1024, asks about prefill chunking), if a recalibration there picks a larger chunk. ### A second, smaller point: the calibration can't see chunks above 4096 `tools/calibrate_mm3_prefill.py` measures on a ~4K-token prompt (`TOKENS = 4096`), so a chunk of 8192 or more reads that prompt in one call, the same as 4096, and can never win. On real prompts here it does: - **8192 against 4096:** prompts 19% / 28% / 12% faster (9.6K / 39K / 159K), decode the same (18.03 vs 17.95), with 767 experts in VRAM instead of 878. - **16384 against 4096:** prompts 50% / 42% / 15% faster, decode 3.3% slower (541 experts in VRAM). Just past the script's `DECODE_LOSS = 0.03`. - (The `--cpu-threads 28` row is from #552: in that single start, the 2 threads fewer cost ~5% of decode; the chunk did not.) Measuring on a longer prompt (16K, say, or the chunk's own size times two) would let the calibration weigh that trade itself. The Strata engine saw the same per-chunk cost of copying the experts VRAM doesn't hold, in its hybrid mode (Niko1221/Strata#4332: its chunk rule had no 4096 arm; adding one read prompts 51-76% faster on a 16 GB card). ### Setup - **GPU:** 1× NVIDIA L40S-48Q (vGPU, 48 GB, sm_89), CUDA driver API 12.4 (vGPU guest), CUDA 12.9 toolkit. - **CPU and RAM:** Xeon Platinum 8580 VM, 32 vCPUs (no SMT), ~504 GB RAM, Linux 6.8. Model on a local NVMe. - **Model:** MiniMax-M3.1-Flash EXL3 3.55 bpw, Maya v1.1.34 (`maya-mm3` built with `-DCMAKE_CUDA_ARCHITECTURES=89`). - **Config:** `--max-context 262144 --kv-streaming on --vision on --dspark on --profile data/expert-profile-mm3.bin`, no `--cpu-threads` (30 threads), no `--parallel`. - **Server:** `maya.py --plain`, one request at a time.
Author
Owner

@mw00 commented on GitHub (Oct 28, 2026):

Fixed in v1.1.36: the single-conversation MiniMax server now reads the prompt in the chunk from prefill-tune.txt, the same one the model was sized for. Thank you @talisp for the exact line in serve(); it was a one-line fix because of that. Please tell us if your 48 GB card now gets the speed you measured with the calibrated chunk.

Released in v1.1.36: https://github.com/mw00/project-maya/releases/tag/v1.1.36

<!-- gh-comment-id:6480773886 --> @mw00 commented on GitHub (Oct 28, 2026): Fixed in v1.1.36: the single-conversation MiniMax server now reads the prompt in the chunk from `prefill-tune.txt`, the same one the model was sized for. Thank you @talisp for the exact line in `serve()`; it was a one-line fix because of that. Please tell us if your 48 GB card now gets the speed you measured with the calibrated chunk. Released in **v1.1.36**: https://github.com/mw00/project-maya/releases/tag/v1.1.36
Author
Owner

@talisp commented on GitHub (Oct 29, 2026):

Confirmed on v1.1.36, thanks! Same box as the report (1× L40S 48 GB, 32-vCPU Xeon VM, ~504 GB RAM), same pack and calibration (prefill-tune.txt: chunk=4096), and no --chunk on the command line:

Prompt 9.6K 38.8K 158K Decode
v1.1.34 (the bug) 155.2 161.0 135.8 17.90
our local one-line patch 340.1 364.3 240.9 17.95
v1.1.36 337.0 363.7 241.3 17.28

The start line reads the calibration (prefill: this PC's calibration (<pack>/prefill-tune.txt): chunk 4096), with 878 experts resident as before. Decode is at the low end of our run-to-run spread (17.2-18.4); it's one start, with the page cache dropped before it.

<!-- gh-comment-id:6491387314 --> @talisp commented on GitHub (Oct 29, 2026): Confirmed on v1.1.36, thanks! Same box as the report (1× L40S 48 GB, 32-vCPU Xeon VM, ~504 GB RAM), same pack and calibration (`prefill-tune.txt`: chunk=4096), and no `--chunk` on the command line: | | Prompt 9.6K | 38.8K | 158K | Decode | |---|---|---|---|---| | v1.1.34 (the bug) | 155.2 | 161.0 | 135.8 | 17.90 | | our local one-line patch | 340.1 | 364.3 | 240.9 | 17.95 | | **v1.1.36** | **337.0** | **363.7** | **241.3** | 17.28 | The start line reads the calibration (`prefill: this PC's calibration (<pack>/prefill-tune.txt): chunk 4096`), with 878 experts resident as before. Decode is at the low end of our run-to-run spread (17.2-18.4); it's one start, with the page cache dropped before it.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#248
No description provided.