Repository navigation
perf(bench): long-prompt prefill ladder + serving telemetry - #641
Merged
Merged
Conversation
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.
15 tasks
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 Nflag 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 existingprompt_tokensfield. The short-prompt--promptpath is untouched.scripts/bench_decode.sh: threads--prompt-tokensthrough and appends one new CSV columnprompt_target_len(column 15). Columns 1-14 are byte-identical to the historical schema; the column is empty for short-prompt runs and anySKIP:*/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, reusingbench_decode.shper cell so warmup and OOM classification are identical.src/server/batch/observability.rs: adds aRequestHistogram(fixed-bucket, atomic) and two instances,request_ttft_msandrequest_decode_tok_s, plusrecord_request_completion(skips zero-token completions) and snapshot accessors, with unit tests.src/server/batch/scheduler.rs: records per-request TTFT/decode-rate once infinalize_completedwhere the finished sequence's timings are available (never on the per-token path).src/server/routes/metrics.rs: exportsmlxcel_request_ttft_msandmlxcel_request_decode_tok_son/metricswith the standard_bucket/_sum/_countseries.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.csvanddocs/benchmark_results/longprompt-prefill-gb10.md: committed GB10 baseline and a note describing the ladder and reproduction.Baseline numbers (GB10, prefill tok/s)
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.
failmarks an exit-134 allocation/capacity abort at that length;oomis a classified out-of-memory.Test plan
cargo build --release --features cudasucceeds.mlxcel-bench-decode --model ./models/llama-3.1-8b-4bit --prompt-tokens 8192emits a CSV row withprompt_target_len; a short-prompt run keeps the old 14 columns and appends an emptyprompt_target_len.cargo test --release --features cuda -p mlxcel --lib batch::observabilitypasses (9 tests) andcargo clippy --release --features cuda -p mlxcelis clean on touched code.mlxcel-server -m models/qwen2.5-0.5b-bf16 --metricsplus real requests populatemlxcel_request_ttft_msandmlxcel_request_decode_tok_son/metrics(verified count/sum/buckets).python3 scripts/bench_serving_concurrency.py --concurrency 1,2,4,8prints a summary table against the running server.Closes #624