[GH-ISSUE #4821] [TUI] strata tune auto measures only the solo path: judge and tune settings under the --parallel load (opt-in) #2214

Open
opened 2026-11-04 01:57:33 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @gdevenyi on GitHub (Oct 31, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4821

Area

[TUI] (the Terminal: strata tune auto, and strata launch --tune)

What do you want to do?

I want to serve several users with --parallel N and have the tuner pick the settings that are fastest for N requests at once.

Today the tuner starts the server with the N slots, but it sends one request at a time. Each request stays on the solo path, so batch windows never run. A setting can be much better or worse with slots busy, and the tuner cannot see it.

The repo's own numbers show the gap (docs/BATCHING.md, 2x RTX A6000 48 GB, IQ3_S, --batch 4, total tok/s; not my measurements):

Change 1 stream 4 streams
Serial group -> pipelined groups 101.7 -> 101.7 141.0 -> 171.4
Pipelined groups -> STRATA_PIPED_MTP=1 with --batch-mtp 101.7 -> 101.4 171.4 -> 188.8

A solo measurement shows no gain for either change, and the tuner needs at least +3% to accept one.

The best setting also depends on the machine, so it cannot be one fixed default. #3849 reports that --batch lost expert-cache hits on 2x RTX 3060 12 GB (99% -> 86%), and docs/BATCHING.md measures a lone request 22% slower with 4 slots on one RTX 5070.

What do you do today instead?

Tune for solo speed, then compare the batch settings by hand: restart with --set flags, run strata bench run --suite parallel-mixed-v1 --concurrency N or tools/serve_load.py, and use strata bench compare. Noise control and stacking winners are left to the user.

What I found in the code

Reproduction status: unconfirmed static analysis. I read the code at c62d5e3a (0.2.9). I ran no tuner or engine for this report.

  • One request at a time: WorkerEngine.measure calls decode_once and prompt_once in sequence (strata_control/tune_session.py:378-409).
  • Judged on solo speed: metric() uses decode_tok_s, combined with prompt speed for coding (strata_control/autotune.py:139-154). It has no total throughput or first-token measure under load.
  • No batch settings to try: ARMS has no --batch-groups, --batch-mtp, STRATA_PIPED_MTP, parallel stack switch or STRATA_BATCH_DECODE_SHARE (strata_control/tune_knobs.py:80-121).
  • Slot count is not part of a tuning result's key: slot_key hashes model, context, KV format, pictures and goal (strata_control/presets.py:128-131). A result tuned at parallel 1 looks reusable at parallel 8 without --retune.
  • Slot count is not recorded: _FACTS does not read INFO batch_slots=N (strata_control/tune_session.py:97-106), so a candidate that ends up with fewer slots is not noticed.
  • Two batch settings exclude each other, and only a load test can choose: on Linux NVIDIA, the 0.2.9 stack sets STRATA_BATCH_SELF_COMMIT=1 (serve/server.py:3670-3679). The engine then turns STRATA_PIPED_MTP off (src/program/generate.cpp:6228-6229). The server comment reports +16% for the stack at 8 requests on two A6000, and docs/BATCHING.md:513 names STRATA_PIPED_MTP=1 the best drafts setting. I found no published run comparing them.
  • A solo win could cost batch speed: the kv_resident_64k arm is judged alone, but docs/BATCHING.md:692 says a slot with KV streaming keeps per-row launches instead of STRATA_BATCH_ATTN_ROWS. Whether this matters in practice is unmeasured.

Suggested implementation

Opt-in, with the current code path unchanged when it is not asked for. For example strata tune auto TARGET --concurrency N, with a matching option on strata launch. It keeps the existing seams: interleaved rounds, A/A noise, memory guards and cancel stay as they are.

  1. Measure under load. Add clients to RequestSet (default 1, today's behaviour). With more than 1, measure adds a phase of N streamed requests at once and fills new RunResult fields such as batch_tok_s and ttft_p95_s. Use the tools/serve_load.py shape, with a unique nonce per prompt. parallel-mixed-v1 is less suited: its N requests repeat two fixed prompts and stop at 32 or 96 tokens (strata_cli/bench.py:45-46, :599-601).

  2. Record the slots. Add batch_slots to _FACTS. Use it as the default for clients, and reject a candidate that runs fewer slots than the base.

  3. Judge on the load. Add a metric() use based on batch_tok_s, with the same accept_threshold and win rule. Add guards for p95 first-token time and for solo decode, so a batch gain cannot hide a solo loss. The limits need agreeing and measuring.

  4. Add batch arms, used only in this mode:

    • --batch-groups 1 against auto on a layer split
    • the tied group --batch-mtp + STRATA_PIPED_MTP=1 + STRATA_BATCH_SELF_COMMIT=0
    • the parallel stack on and off
    • STRATA_BATCH_DECODE_SHARE, for a mix with long prompts

    Each needs an answer class. The stack's comment and tools/batch_test.py runs may already support exact for some of them.

  5. Store it. Save the concurrency and load numbers in the preset. Add the slot count to slot_key only for these results, so existing presets keep their hash, and have the re-check repeat the same load.

Out of scope for a first version: searching the slot count itself (--parallel auto), and any change to a default.

Limits and open questions

  • More time per candidate: the load phase has to fit the quick mode's 20 minutes, probably by trying fewer arms.
  • Noise is unknown. The A/A gap under load may be wider than solo, and a p95 from few requests is noisy.
  • The first version could cover Flash-Next on CUDA and HIP. DeepSeek V4.1 has no slots and Mac has no batch path, so the option should say that and do nothing.
  • Would you accept this scope, and should it live in strata tune auto, or should the Terminal only report a load check after tuning?

I searched open and closed issues and pull requests and found no request for concurrency-aware tuning.

  • #2275: the multi-user direction
  • #3849: slots cost speed on small cards
  • #3560 and #4687: batch behaviour that changes by machine and version
  • PR #2738: earlier hand tuning of --batch-mtp for several streams (closed)

Written with AI assistance (Claude Code). I checked the code references above against the commit named. Nothing here has been built or run.

Originally created by @gdevenyi on GitHub (Oct 31, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4821 ### Area [TUI] (the Terminal: `strata tune auto`, and `strata launch --tune`) ### What do you want to do? I want to serve several users with `--parallel N` and have the tuner pick the settings that are fastest for N requests at once. Today the tuner starts the server with the N slots, but it sends one request at a time. Each request stays on the solo path, so batch windows never run. A setting can be much better or worse with slots busy, and the tuner cannot see it. The repo's own numbers show the gap (`docs/BATCHING.md`, 2x RTX A6000 48 GB, IQ3_S, `--batch 4`, total tok/s; not my measurements): | Change | 1 stream | 4 streams | |---|---:|---:| | Serial group -> pipelined groups | 101.7 -> 101.7 | 141.0 -> 171.4 | | Pipelined groups -> `STRATA_PIPED_MTP=1` with `--batch-mtp` | 101.7 -> 101.4 | 171.4 -> 188.8 | A solo measurement shows no gain for either change, and the tuner needs at least +3% to accept one. The best setting also depends on the machine, so it cannot be one fixed default. #3849 reports that `--batch` lost expert-cache hits on 2x RTX 3060 12 GB (99% -> 86%), and `docs/BATCHING.md` measures a lone request 22% slower with 4 slots on one RTX 5070. ### What do you do today instead? Tune for solo speed, then compare the batch settings by hand: restart with `--set` flags, run `strata bench run --suite parallel-mixed-v1 --concurrency N` or `tools/serve_load.py`, and use `strata bench compare`. Noise control and stacking winners are left to the user. ### What I found in the code **Reproduction status: unconfirmed static analysis.** I read the code at c62d5e3a (0.2.9). I ran no tuner or engine for this report. - **One request at a time:** `WorkerEngine.measure` calls `decode_once` and `prompt_once` in sequence (`strata_control/tune_session.py:378-409`). - **Judged on solo speed:** `metric()` uses `decode_tok_s`, combined with prompt speed for coding (`strata_control/autotune.py:139-154`). It has no total throughput or first-token measure under load. - **No batch settings to try:** `ARMS` has no `--batch-groups`, `--batch-mtp`, `STRATA_PIPED_MTP`, parallel stack switch or `STRATA_BATCH_DECODE_SHARE` (`strata_control/tune_knobs.py:80-121`). - **Slot count is not part of a tuning result's key:** `slot_key` hashes model, context, KV format, pictures and goal (`strata_control/presets.py:128-131`). A result tuned at `parallel` 1 looks reusable at `parallel` 8 without `--retune`. - **Slot count is not recorded:** `_FACTS` does not read `INFO batch_slots=N` (`strata_control/tune_session.py:97-106`), so a candidate that ends up with fewer slots is not noticed. - **Two batch settings exclude each other, and only a load test can choose:** on Linux NVIDIA, the 0.2.9 stack sets `STRATA_BATCH_SELF_COMMIT=1` (`serve/server.py:3670-3679`). The engine then turns `STRATA_PIPED_MTP` off (`src/program/generate.cpp:6228-6229`). The server comment reports +16% for the stack at 8 requests on two A6000, and `docs/BATCHING.md:513` names `STRATA_PIPED_MTP=1` the best drafts setting. I found no published run comparing them. - **A solo win could cost batch speed:** the `kv_resident_64k` arm is judged alone, but `docs/BATCHING.md:692` says a slot with KV streaming keeps per-row launches instead of `STRATA_BATCH_ATTN_ROWS`. Whether this matters in practice is unmeasured. ### Suggested implementation Opt-in, with the current code path unchanged when it is not asked for. For example `strata tune auto TARGET --concurrency N`, with a matching option on `strata launch`. It keeps the existing seams: interleaved rounds, A/A noise, memory guards and cancel stay as they are. 1. **Measure under load.** Add `clients` to `RequestSet` (default 1, today's behaviour). With more than 1, `measure` adds a phase of N streamed requests at once and fills new `RunResult` fields such as `batch_tok_s` and `ttft_p95_s`. Use the `tools/serve_load.py` shape, with a unique nonce per prompt. `parallel-mixed-v1` is less suited: its N requests repeat two fixed prompts and stop at 32 or 96 tokens (`strata_cli/bench.py:45-46`, `:599-601`). 2. **Record the slots.** Add `batch_slots` to `_FACTS`. Use it as the default for `clients`, and reject a candidate that runs fewer slots than the base. 3. **Judge on the load.** Add a `metric()` use based on `batch_tok_s`, with the same `accept_threshold` and win rule. Add guards for p95 first-token time and for solo decode, so a batch gain cannot hide a solo loss. The limits need agreeing and measuring. 4. **Add batch arms, used only in this mode:** - `--batch-groups 1` against auto on a layer split - the tied group `--batch-mtp` + `STRATA_PIPED_MTP=1` + `STRATA_BATCH_SELF_COMMIT=0` - the parallel stack on and off - `STRATA_BATCH_DECODE_SHARE`, for a mix with long prompts Each needs an answer class. The stack's comment and `tools/batch_test.py` runs may already support `exact` for some of them. 5. **Store it.** Save the concurrency and load numbers in the preset. Add the slot count to `slot_key` only for these results, so existing presets keep their hash, and have the re-check repeat the same load. Out of scope for a first version: searching the slot count itself (`--parallel auto`), and any change to a default. ### Limits and open questions - More time per candidate: the load phase has to fit the quick mode's 20 minutes, probably by trying fewer arms. - Noise is unknown. The A/A gap under load may be wider than solo, and a p95 from few requests is noisy. - The first version could cover Flash-Next on CUDA and HIP. DeepSeek V4.1 has no slots and Mac has no batch path, so the option should say that and do nothing. - Would you accept this scope, and should it live in `strata tune auto`, or should the Terminal only report a load check after tuning? ### Related I searched open and closed issues and pull requests and found no request for concurrency-aware tuning. - #2275: the multi-user direction - #3849: slots cost speed on small cards - #3560 and #4687: batch behaviour that changes by machine and version - PR #2738: earlier hand tuning of `--batch-mtp` for several streams (closed) Written with AI assistance (Claude Code). I checked the code references above against the commit named. Nothing here has been built or run.
Author
Owner

@Barmallini commented on GitHub (Oct 31, 2026):

Supportive data point from the #4687 rig (6x Tesla V100-SXM2-16GB, sm_70, split 9/9/9/8/8/5, Qwen3.8 IQ3_S, --parallel 4 --batch 4, KV int8 resident 262K, engine 0.1.55 built from source).
Your central premise — that a switch's real cost only shows up under concurrent load — we confirmed by accident yesterday, with clean A/B runs of the same 4x ~25,955-token prompt test through the OpenAI API (wall time per slot, no other load on the box):

Configuration (engine 0.1.55) Wall time
shipped 0.2.9 defaults 195.6 s
defaults + STRATA_PREFILL_LAYER_MAJOR=0 124.4 s
defaults + STRATA_BATCH_GROUPS_NV_SERIAL=1 190.3 s
both 123.3 s
STRATA_DEFAULTS=026 122.4 s
One prefill-path flag moves it 60%, and none of that would show on a solo measurement — layer-major is even designed as a prompt-time win. Isolation details are in #4687.
Two additions to the proposal, from running this box for real multi-agent traffic:
  1. The load profile matters more than the arm list. Our production pain is not batch tok/s but the conversation-cache park/restore cycle between turns of two alternating ~130K/~190K-token conversations: 4.4–10 s of snapshot copy per turn, and 0.2.9's checkpoint reuse (reused_kv_bytes) catches only about 1 in 5 parks (details in #4450). A tuner judged on batch_tok_s from fixed short prompts would not see any of this. If the first version can afford one more load shape, "two long conversations alternating turns" (growing contexts, park/restore between turns) would rank candidates much closer to how they behave for us.
  2. Prefill-path arms belong in the batch mode, at least for multi-card splits: STRATA_PREFILL_LAYER_MAJOR on/off dominates everything else on our 6-card sm_70 split, and it is exactly the kind of setting the solo tuner cannot rank (see #4687).
    Noise note: on this box, back-to-back clean runs of the same configuration land within ~1 s (~1%), so a +3% accept threshold has usable headroom even without a long A/A phase — but that is one machine, one test shape.

<!-- gh-comment-id:6550622519 --> @Barmallini commented on GitHub (Oct 31, 2026): Supportive data point from the #4687 rig (6x Tesla V100-SXM2-16GB, sm_70, split 9/9/9/8/8/5, Qwen3.8 IQ3_S, `--parallel 4 --batch 4`, KV int8 resident 262K, engine 0.1.55 built from source). Your central premise — that a switch's real cost only shows up under concurrent load — we confirmed by accident yesterday, with clean A/B runs of the same 4x ~25,955-token prompt test through the OpenAI API (wall time per slot, no other load on the box): | Configuration (engine 0.1.55) | Wall time | |---|---| | shipped 0.2.9 defaults | 195.6 s | | defaults + `STRATA_PREFILL_LAYER_MAJOR=0` | 124.4 s | | defaults + `STRATA_BATCH_GROUPS_NV_SERIAL=1` | 190.3 s | | both | 123.3 s | | `STRATA_DEFAULTS=026` | 122.4 s | One prefill-path flag moves it 60%, and none of that would show on a solo measurement — layer-major is even designed as a prompt-time win. Isolation details are in #4687. Two additions to the proposal, from running this box for real multi-agent traffic: 1. **The load profile matters more than the arm list.** Our production pain is not batch tok/s but the conversation-cache park/restore cycle between turns of two alternating ~130K/~190K-token conversations: 4.4–10 s of snapshot copy per turn, and 0.2.9's checkpoint reuse (`reused_kv_bytes`) catches only about 1 in 5 parks (details in #4450). A tuner judged on `batch_tok_s` from fixed short prompts would not see any of this. If the first version can afford one more load shape, "two long conversations alternating turns" (growing contexts, park/restore between turns) would rank candidates much closer to how they behave for us. 2. **Prefill-path arms belong in the batch mode**, at least for multi-card splits: `STRATA_PREFILL_LAYER_MAJOR` on/off dominates everything else on our 6-card sm_70 split, and it is exactly the kind of setting the solo tuner cannot rank (see #4687). Noise note: on this box, back-to-back clean runs of the same configuration land within ~1 s (~1%), so a +3% accept threshold has usable headroom even without a long A/A phase — but that is one machine, one test shape. ---
Sign in to join this conversation.
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
Niko1221/Strata#2214
No description provided.