-
Notifications
You must be signed in to change notification settings - Fork 0
fix: non-streaming event-channel overflow + baseline benchmark doc #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
willamhou
wants to merge
1
commit into
master
Choose a base branch
from
fix/nonstream-channel-cap
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # Benchmark Baseline — TinyLlama-1.1B on GB10 (pre-CUDA-Graphs) | ||
|
|
||
| **Date:** 2026-05-25 | ||
| **Hardware:** NVIDIA GB10 (DGX Spark, Blackwell, sm_121) | ||
| **Model:** TinyLlama-1.1B-Chat-v1.0, F16 weights (BF16→F16 at load) | ||
| **Config:** `--backend cuda --kv-cache paged --num-blocks 1024 --block-size 16 --max-batch-size 64` | ||
| **Build:** `cargo build --release` (CUDA on) | ||
| **Path under test:** paged attention decode, **no CUDA Graphs** (engine calls | ||
| the allocating `model.forward()`; `forward_into` + graph capture not yet wired). | ||
|
|
||
| This is the reference point for the CUDA Graphs end-to-end work. Re-run the | ||
| same harness after graph capture lands to quantify the win. | ||
|
|
||
| ## Numbers | ||
|
|
||
| | Metric | Value | | ||
| |---|---| | ||
| | **Single-stream decode** | **38.2 ms/token (26.2 tok/s)** | | ||
| | Concurrent throughput, C=4 | 179 tok/s | | ||
| | Concurrent throughput, C=16 | 531 tok/s | | ||
| | Concurrent throughput, C=32 | **730 tok/s** | | ||
| | TTFT (C=4, short prompt) | ~148 ms | | ||
|
|
||
| Single-stream decode measured by the differential method: stream the same | ||
| prompt at `max_tokens` 32 and 256 (greedy), take min-of-3 each, subtract to | ||
| cancel prefill — `(256-32) tok / (t256 - t32)`. This avoids the urllib | ||
| line-buffering artifact that corrupts naive per-chunk TTFT/ITL timing on a | ||
| single fast stream (see "Measurement notes"). | ||
|
|
||
| Concurrent throughput = total decoded tokens / wall-clock, firing C streams | ||
| simultaneously (Python threads), max_tokens=128 each. | ||
|
|
||
| ## Interpretation | ||
|
|
||
| 1. **38 ms/token single-stream is slow for a 1.1B model on Blackwell** | ||
| (should be sub-10 ms). The decode hot path issues ~220 kernel launches | ||
| per step (22 layers × ~10 kernels/layer: matmul ×4, rms_norm ×2, | ||
| silu_mul, paged_attention, rope, add, …) plus per-op output allocations. | ||
| Launch latency + allocation churn dominate at batch=1. **This is exactly | ||
| what CUDA Graphs targets** — collapse the ~220 launches into one graph | ||
| replay. | ||
|
|
||
| 2. **Concurrent throughput scales near-linearly** (179 → 531 → 730 tok/s for | ||
| C = 4 → 16 → 32). Continuous batching + paged attention are working; | ||
| C=32 throughput is ~28× single-stream, so the GPU is well-utilized under | ||
| batching and the single-step bottleneck is launch overhead, not FLOPs. | ||
|
|
||
| 3. **Expected CUDA Graphs win**: single-stream TPOT should drop substantially | ||
| (launch overhead amortized into one replay). Concurrent throughput may | ||
| improve less (already GPU-bound) but should still benefit from removing | ||
| per-step CPU launch work. | ||
|
|
||
| ## Measurement notes / caveats | ||
|
|
||
| - **urllib SSE buffering artifact**: a naive `for line in resp` over a single | ||
| fast SSE stream buffers the whole body, so per-chunk TTFT/ITL timing is | ||
| bogus (TTFT≈total, ITL≈0). Only wall-clock-total metrics are trustworthy | ||
| for single streams. The differential method sidesteps this. | ||
| - **Non-streaming long generations 500**: `stream:false` + `max_tokens=256` | ||
| returns HTTP 500 (`event channel full, cancelling slow consumer`). The | ||
| non-streaming handler does not drain the bounded engine event channel | ||
| concurrently, so long generations overflow it. Streaming works fine. This | ||
| is a separate forge bug (fixed in a follow-up); the benchmark uses | ||
| streaming throughout. | ||
| - Numbers are single-run (min-of-3 for the differential); not averaged over | ||
| many trials. Treat as order-of-magnitude baseline, not a precise figure. | ||
|
|
||
| ## Repro | ||
|
|
||
| ```bash | ||
| # Start server | ||
| ./target/release/forge-server \ | ||
| --model-path /path/to/tinyllama-1.1b-chat \ | ||
| --backend cuda --kv-cache paged --num-blocks 1024 --block-size 16 \ | ||
| --max-batch-size 64 --port 8110 | ||
|
|
||
| # Differential single-stream decode + concurrent throughput | ||
| python bench.py http://127.0.0.1:8110 128 | ||
| ``` |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_tokensis user-controlled (ChatCompletionRequest.max_tokens) and is used directly in(params.max_tokens + 16).max(256)to sizempsc::channel. For sufficiently large values, this can overflowusizeor exceed Tokio’s maximum bounded-channel capacity, which makesmpsc::channel(...)panic instead of returning a normal API error. In practice, a single non-streaming request with an extrememax_tokenscan force a handler panic/connection abort; please boundmax_tokens(orchannel_cap) and use checked arithmetic before constructing the channel.Useful? React with 👍 / 👎.