[PR #5260] [Benchmark] tools: a serving calibration for single and parallel requests #5369

Open
opened 2026-11-07 16:34:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5260
Author: @suzuri-lollipop
Created: 11/5/2026
Status: 🔄 Open

Base: main ← Head: suzuri/serving-cal-pr


📝 Commits (1)

  • 31ef550 tools: a serving calibration for single and parallel requests

📊 Changes

3 files changed (+531 additions, -0 deletions)

View changed files

📝 docs/BATCHING.md (+43 -0)
➕ tools/calibrate_serving.py (+436 -0)
➕ tools/test_calibrate_serving.py (+52 -0)

📄 Description

Problem and result

strata engine calibrate measures a fixed single-stream workload. What a serving user waits for is different:
with several requests in flight, a cold prompt's read is serialized with the others, so the later requests' time
is queue wait plus prompt time, not the solo decode rate. The env settings that change this
(STRATA_PREFILL_ROUTED_STREAM, STRATA_PIPE_ADAPT_EVERY, STRATA_COALESCE_PREFILL) were compared by hand.

Before: no serving-side calibration; the queue-wait and prompt-time parts are invisible to the existing suite.
After: tools/calibrate_serving.py measures one request (--mode single) or several (--mode multi, with
--shape both|loop|stagger), compares env-only arms, and writes the winner back with --apply. On the rig below
the routed arm changed four 1.1K-token prompts sent 5 s apart from 6.9-10.4 s prompt reads and 18.9 s total queue
wait to 3.3-4.8 s reads and 0.31 s queue wait; the pipelined line went from 28.5-33.0 to 52.1 rows/s. No engine
code, default path or answer changes: every arm is an existing opt-in env setting, and nothing is applied without
--apply.

None (a new opt-in tool; no engine or default change).

Approach

  • --mode single (--single): one request on the solo path; scored on throughput first (a 2% loss is refused),
    with the prompt time as the tie-break.
  • --mode multi (--multi, the default): several cold prompts; scored on queue wait, then the sum of prompt
    times, then throughput (a 3% loss is refused), then the longest decode gap.
  • Arms: baseline, routed (STRATA_PREFILL_ROUTED_STREAM=1), routed_adapt (routed +
    STRATA_PIPE_ADAPT_EVERY=32), and coalesce (STRATA_COALESCE_PREFILL=4, multi only).
  • Per request it reads prompt_ms and first_engine_token_s - prompt_ms from the JSON /metrics; no new endpoint.
  • --apply writes engine keys into the config's env with a .bak-<time> copy. Keys the server reads
    (STRATA_COALESCE_PREFILL, STRATA_ADMIT_SHORT_FIRST) go to <config>.server-env.json, because the config's
    env only reaches the engine.
  • --root starts a fork clone's serve/server.py; the arms are env-only, so the same tool measures both.

Validation

Environment: Linux, 2x NVIDIA RTX PRO 4000 Blackwell (CUDA1 on a Gen4 x4 link), CUDA 13.3, Qwen3.8-Flash-Next
NVFP4, 63 GiB arena, --parallel 4 --batch-groups auto, STRATA_PIPED_CONCURRENT=1. PR branch head
31ef550c (engine 0.1.56 = ffa80d73).

Passed:

  • python -m pytest tools/test_calibrate_serving.py at 31ef550c -> 6 passed (single/multi score,
    throughput gates, server/engine env split, prompt seed).
  • python tools/calibrate_serving.py --help -> the --mode {single,multi} | --single | --multi and
    --shape both|loop|stagger options are present.
  • Four prompts of about 1.1K tokens, sent 5 s apart, temp 0, engine 0.1.56, with the same probe and arms:
    baseline p 6.9-10.4 s and q sum 18.9 s; STRATA_PREFILL_ROUTED_STREAM=1 p 3.3-4.8 s and q sum 0.31 s.
    The pipelined batch line went from 28.5-33.0 to 52.1 rows/s. Fixed 64-token A/B (all four hit length):
    per-request decode 29-78 -> 87-96 tok/s, q sum 16.8 -> 0.08 s.
  • The routed walk is an existing opt-in: it drops experts no token of the chunk routes to and copies every routed
    entry into its existing slot, so the prompt products are the same bits (include/strata/prefill/routed_stream.hpp;
    tests/prefill/routed_stream_test.cpp).

Failed:

None observed.

Not run:

  • AMD/HIP, SYCL and Metal builds and servers.
  • Other models, prompt lengths, more than four streams.
  • The single mode's full GPU probe: its argument parse and score are unit-tested; only the multi arm was run on
    the GPU above.
  • A fork clone's serve/server.py in CI; --root is the local path for that, not exercised by the unit tests.
  • The tool's own full run on the PR's exact commit; the measured run above used the same probe/arms on engine
    0.1.56.

Limits

  • The numbers are one rig, one model and one prompt size; other hardware needs its own measurement.
  • The tool calibrates env arms only. It does not tune the fork-only server CLI flags (--batch-mtp, etc.).
  • Queue-wait matching uses the server's arrival time and prompt_tokens; equal-length requests arriving in the
    same instant can be matched to the wrong entry. The per-request rows stay in the report so this is visible.
  • It needs the GPUs to itself and pins tens of GiB; stop the server for the config first.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/5260 **Author:** [@suzuri-lollipop](https://github.com/suzuri-lollipop) **Created:** 11/5/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `suzuri/serving-cal-pr` --- ### 📝 Commits (1) - [`31ef550`](https://github.com/Niko1221/Strata/commit/31ef550c234608ba32c61de0be0b4ed0bb36c853) tools: a serving calibration for single and parallel requests ### 📊 Changes **3 files changed** (+531 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/BATCHING.md` (+43 -0) ➕ `tools/calibrate_serving.py` (+436 -0) ➕ `tools/test_calibrate_serving.py` (+52 -0) </details> ### 📄 Description ## Problem and result `strata engine calibrate` measures a fixed single-stream workload. What a serving user waits for is different: with several requests in flight, a cold prompt's read is serialized with the others, so the later requests' time is queue wait plus prompt time, not the solo decode rate. The env settings that change this (`STRATA_PREFILL_ROUTED_STREAM`, `STRATA_PIPE_ADAPT_EVERY`, `STRATA_COALESCE_PREFILL`) were compared by hand. Before: no serving-side calibration; the queue-wait and prompt-time parts are invisible to the existing suite. After: `tools/calibrate_serving.py` measures one request (`--mode single`) or several (`--mode multi`, with `--shape both|loop|stagger`), compares env-only arms, and writes the winner back with `--apply`. On the rig below the routed arm changed four 1.1K-token prompts sent 5 s apart from 6.9-10.4 s prompt reads and 18.9 s total queue wait to 3.3-4.8 s reads and 0.31 s queue wait; the pipelined line went from 28.5-33.0 to 52.1 rows/s. No engine code, default path or answer changes: every arm is an existing opt-in env setting, and nothing is applied without `--apply`. ## Related discussion None (a new opt-in tool; no engine or default change). ## Approach - `--mode single` (`--single`): one request on the solo path; scored on throughput first (a 2% loss is refused), with the prompt time as the tie-break. - `--mode multi` (`--multi`, the default): several cold prompts; scored on queue wait, then the sum of prompt times, then throughput (a 3% loss is refused), then the longest decode gap. - Arms: `baseline`, `routed` (`STRATA_PREFILL_ROUTED_STREAM=1`), `routed_adapt` (routed + `STRATA_PIPE_ADAPT_EVERY=32`), and `coalesce` (`STRATA_COALESCE_PREFILL=4`, multi only). - Per request it reads `prompt_ms` and `first_engine_token_s - prompt_ms` from the JSON `/metrics`; no new endpoint. - `--apply` writes engine keys into the config's `env` with a `.bak-<time>` copy. Keys the server reads (`STRATA_COALESCE_PREFILL`, `STRATA_ADMIT_SHORT_FIRST`) go to `<config>.server-env.json`, because the config's `env` only reaches the engine. - `--root` starts a fork clone's `serve/server.py`; the arms are env-only, so the same tool measures both. ## Validation Environment: Linux, 2x NVIDIA RTX PRO 4000 Blackwell (CUDA1 on a Gen4 x4 link), CUDA 13.3, Qwen3.8-Flash-Next NVFP4, 63 GiB arena, `--parallel 4 --batch-groups auto`, `STRATA_PIPED_CONCURRENT=1`. PR branch head `31ef550c` (engine 0.1.56 = `ffa80d73`). **Passed:** - `python -m pytest tools/test_calibrate_serving.py` at `31ef550c` -> **6 passed** (single/multi score, throughput gates, server/engine env split, prompt seed). - `python tools/calibrate_serving.py --help` -> the `--mode {single,multi} | --single | --multi` and `--shape both|loop|stagger` options are present. - Four prompts of about 1.1K tokens, sent 5 s apart, temp 0, engine 0.1.56, with the same probe and arms: baseline `p` 6.9-10.4 s and `q` sum 18.9 s; `STRATA_PREFILL_ROUTED_STREAM=1` `p` 3.3-4.8 s and `q` sum 0.31 s. The pipelined batch line went from 28.5-33.0 to 52.1 rows/s. Fixed 64-token A/B (all four hit length): per-request decode 29-78 -> 87-96 tok/s, `q` sum 16.8 -> 0.08 s. - The routed walk is an existing opt-in: it drops experts no token of the chunk routes to and copies every routed entry into its existing slot, so the prompt products are the same bits (`include/strata/prefill/routed_stream.hpp`; `tests/prefill/routed_stream_test.cpp`). **Failed:** None observed. **Not run:** - AMD/HIP, SYCL and Metal builds and servers. - Other models, prompt lengths, more than four streams. - The single mode's full GPU probe: its argument parse and score are unit-tested; only the multi arm was run on the GPU above. - A fork clone's `serve/server.py` in CI; `--root` is the local path for that, not exercised by the unit tests. - The tool's own full run on the PR's exact commit; the measured run above used the same probe/arms on engine 0.1.56. ## Limits - The numbers are one rig, one model and one prompt size; other hardware needs its own measurement. - The tool calibrates env arms only. It does not tune the fork-only server CLI flags (`--batch-mtp`, etc.). - Queue-wait matching uses the server's arrival time and `prompt_tokens`; equal-length requests arriving in the same instant can be matched to the wrong entry. The per-request rows stay in the report so this is visible. - It needs the GPUs to itself and pins tens of GiB; stop the server for the config first. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#5369
No description provided.