Skip to content

perf(bench): long-prompt prefill ladder + serving telemetry - #641

Merged
inureyes merged 1 commit into
mainfrom
feature/issue-624-longprompt-bench-telemetry
Jul 2, 2026
Merged

inureyes merged 1 commit into
mainfrom
feature/issue-624-longprompt-bench-telemetry

Conversation

@inureyes

@inureyes inureyes commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

Measurement foundation for epic #623: long-prompt prefill benchmarking plus serving-level TTFT and decode-rate telemetry. Existing benchmark CSVs use 8-66 token prompts whose prefill is launch-overhead-bound, and the server exposed only aggregate counters, so neither prefill optimizations nor batching/pipelining changes could be measured. The short-prompt path, the historical CSV schema (first 14 columns), and Metal behavior are all unchanged.

What changed

  • src/bin/bench_decode.rs: new --prompt-tokens N flag that synthesizes a deterministic prompt (repeated fixed corpus, tokenized with the model's own tokenizer, truncated to exactly N) capped at the model context window (read_model_context_window), reporting the actual length used in the existing prompt_tokens field. The short-prompt --prompt path is untouched.
  • scripts/bench_decode.sh: threads --prompt-tokens through and appends one new CSV column prompt_target_len (column 15). Columns 1-14 are byte-identical to the historical schema; the column is empty for short-prompt runs and any SKIP:*/FAIL:* classification token still trails it.
  • scripts/bench_longprompt.sh (new): runs the representative subset (llama-3.1-8b-4bit, qwen2.5-7b-4bit, qwen3-30b-a3b-4bit, mixtral-8x7b-4bit, gemma-4-31b-it-4bit) across the 512/2048/8192/32768 ladder into one CSV, reusing bench_decode.sh per cell so warmup and OOM classification are identical.
  • src/server/batch/observability.rs: adds a RequestHistogram (fixed-bucket, atomic) and two instances, request_ttft_ms and request_decode_tok_s, plus record_request_completion (skips zero-token completions) and snapshot accessors, with unit tests.
  • src/server/batch/scheduler.rs: records per-request TTFT/decode-rate once in finalize_completed where the finished sequence's timings are available (never on the per-token path).
  • src/server/routes/metrics.rs: exports mlxcel_request_ttft_ms and mlxcel_request_decode_tok_s on /metrics with the standard _bucket/_sum/_count series.
  • scripts/bench_serving_concurrency.py (new): stdlib asyncio client over the OpenAI-compatible streaming API that fires N concurrent requests and reports per-request TTFT, decode tok/s, and aggregate tok/s for N in {1,2,4,8}.
  • benchmarks/cuda_gb10_longprompt_2026-07-03.csv and docs/benchmark_results/longprompt-prefill-gb10.md: committed GB10 baseline and a note describing the ladder and reproduction.

Baseline numbers (GB10, prefill tok/s)

Model 512 2048 8192 32768
llama-3.1-8b-4bit 3286.7 2946.0 1666.3 fail
qwen2.5-7b-4bit 3487.7 3125.7 1805.0 1176.0 (cap 32736)
qwen3-30b-a3b-4bit (MoE) 162.6 162.2 fail fail
mixtral-8x7b-4bit (MoE) 15.3 13.8 25.3 fail
gemma-4-31b-it-4bit 390.3 489.2 fail oom

MoE prefill (mixtral 13-25 tok/s, qwen3-30b-a3b ~162 tok/s) is far below dense at the same length, which is exactly the epic #623 target. fail marks an exit-134 allocation/capacity abort at that length; oom is a classified out-of-memory.

Test plan

  • cargo build --release --features cuda succeeds.
  • mlxcel-bench-decode --model ./models/llama-3.1-8b-4bit --prompt-tokens 8192 emits a CSV row with prompt_target_len; a short-prompt run keeps the old 14 columns and appends an empty prompt_target_len.
  • cargo test --release --features cuda -p mlxcel --lib batch::observability passes (9 tests) and cargo clippy --release --features cuda -p mlxcel is clean on touched code.
  • mlxcel-server -m models/qwen2.5-0.5b-bf16 --metrics plus real requests populate mlxcel_request_ttft_ms and mlxcel_request_decode_tok_s on /metrics (verified count/sum/buckets).
  • python3 scripts/bench_serving_concurrency.py --concurrency 1,2,4,8 prints a summary table against the running server.

Closes #624

Add long-prompt prefill benchmarking and serving-level TTFT/decode-rate telemetry so epic #623 prefill and batching work can actually be measured. Existing benchmark CSVs use 8-66 token prompts whose prefill numbers are launch-overhead-bound, and the server only exposed aggregate counters.

Benchmark harness:

- mlxcel-bench-decode gains --prompt-tokens N, which synthesizes a deterministic prompt (repeated fixed corpus, tokenized with the model's tokenizer, truncated to exactly N) capped at the model context window; the short-prompt --prompt path is unchanged.
- scripts/bench_decode.sh threads --prompt-tokens through and appends one new CSV column, prompt_target_len (column 15). The first 14 columns stay byte-identical to the historical schema; the column is empty for short-prompt runs and any SKIP/FAIL classification token still trails it.
- scripts/bench_longprompt.sh runs a representative subset (llama-3.1-8b-4bit, qwen2.5-7b-4bit, qwen3-30b-a3b-4bit, mixtral-8x7b-4bit, gemma-4-31b-it-4bit) across the 512/2048/8192/32768 ladder, reusing bench_decode.sh per cell so warmup and OOM classification match.

Server telemetry:

- BatchObservability gains two fixed-bucket Prometheus histograms, request_ttft_ms and request_decode_tok_s, recorded once per completed request in the scheduler's finalize_completed path (never per token). Zero-token completions are skipped so TTFT stays meaningful.
- /metrics (behind --metrics) exports mlxcel_request_ttft_ms and mlxcel_request_decode_tok_s with the standard _bucket/_sum/_count series.

Concurrency load:

- scripts/bench_serving_concurrency.py is a stdlib asyncio client over the OpenAI-compatible streaming API that fires N concurrent requests and reports per-request TTFT, decode tok/s, and aggregate tok/s for N in {1,2,4,8}.

Baseline benchmarks/cuda_gb10_longprompt_2026-07-03.csv and docs/benchmark_results/longprompt-prefill-gb10.md capture the GB10 numbers: dense 7-8B prefill 1600-3500 tok/s falling with length, MoE mixtral-8x7b only 13-25 tok/s, qwen3-30b-a3b ~162 tok/s and aborting at 8192+. Everything backend-conditional keys off runtime detection or the existing flags, so Metal and the short-prompt path are unchanged.
@inureyes inureyes added type:performance Performance improvements priority:medium Medium priority area:benchmark Benchmark harness and performance measurement (bench_*.sh, /update-benchmarks) status:done Completed labels Jul 2, 2026
@inureyes
inureyes merged commit 8287041 into main Jul 2, 2026
4 checks passed
@inureyes
inureyes deleted the feature/issue-624-longprompt-bench-telemetry branch August 4, 2026 12:07
@inureyes inureyes self-assigned this Aug 31, 2026
be-free-snowboy pushed a commit to freestylejs/snowbrain-mlxcel that referenced this pull request Oct 27, 2026
Add long-prompt prefill benchmarking and serving-level TTFT/decode-rate telemetry so epic lablup#623 prefill and batching work can actually be measured. Existing benchmark CSVs use 8-66 token prompts whose prefill numbers are launch-overhead-bound, and the server only exposed aggregate counters.

Benchmark harness:

- mlxcel-bench-decode gains --prompt-tokens N, which synthesizes a deterministic prompt (repeated fixed corpus, tokenized with the model's tokenizer, truncated to exactly N) capped at the model context window; the short-prompt --prompt path is unchanged.
- scripts/bench_decode.sh threads --prompt-tokens through and appends one new CSV column, prompt_target_len (column 15). The first 14 columns stay byte-identical to the historical schema; the column is empty for short-prompt runs and any SKIP/FAIL classification token still trails it.
- scripts/bench_longprompt.sh runs a representative subset (llama-3.1-8b-4bit, qwen2.5-7b-4bit, qwen3-30b-a3b-4bit, mixtral-8x7b-4bit, gemma-4-31b-it-4bit) across the 512/2048/8192/32768 ladder, reusing bench_decode.sh per cell so warmup and OOM classification match.

Server telemetry:

- BatchObservability gains two fixed-bucket Prometheus histograms, request_ttft_ms and request_decode_tok_s, recorded once per completed request in the scheduler's finalize_completed path (never per token). Zero-token completions are skipped so TTFT stays meaningful.
- /metrics (behind --metrics) exports mlxcel_request_ttft_ms and mlxcel_request_decode_tok_s with the standard _bucket/_sum/_count series.

Concurrency load:

- scripts/bench_serving_concurrency.py is a stdlib asyncio client over the OpenAI-compatible streaming API that fires N concurrent requests and reports per-request TTFT, decode tok/s, and aggregate tok/s for N in {1,2,4,8}.

Baseline benchmarks/cuda_gb10_longprompt_2026-07-03.csv and docs/benchmark_results/longprompt-prefill-gb10.md capture the GB10 numbers: dense 7-8B prefill 1600-3500 tok/s falling with length, MoE mixtral-8x7b only 13-25 tok/s, qwen3-30b-a3b ~162 tok/s and aborting at 8192+. Everything backend-conditional keys off runtime detection or the existing flags, so Metal and the short-prompt path are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:benchmark Benchmark harness and performance measurement (bench_*.sh, /update-benchmarks) priority:medium Medium priority status:done Completed type:performance Performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(bench): long-prompt prefill benchmark coverage and serving TTFT/decode-rate telemetry

1 participant