Repository navigation
fix(models): measure benchmark throughput from the request itself - #4885
Merged
gabsprogrammer merged 1 commit intoSep 13, 2026
Conversation
5 of 6 tasks
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.
Why this matters
Benchmarking a loaded model while another client generates tokens currently records the server-wide counter delta as if it belonged to the benchmark. A request that generated 64 tokens in two seconds can be reported and persisted as 400 tokens / two seconds (200 tok/s) because unrelated requests incremented the counters.
The root cause is treating aggregate Prometheus counters as a per-request measurement and mixing counters, response timings, usage, and even whitespace word counts. The invariant is that the token numerator and duration describe the same request and measurement basis.
Use a complete
timings.predicted_n/timings.predicted_mspair when supplied; otherwise use the request's integerusage.completion_tokensover its measured wall duration. Return the basis inmethod. Incomplete timings never mix with a different token count. A completion without an actual valid request token count returns 502 and writes no performance samples. Remove the now-unused counter scraper and word-count estimator.Overlap check
Searched all open/closed upstream PR titles, bodies, and changes to
routers/models.py, plus benchmark, comparison, latency, counters and request measurements. #1194 introduced the performance oracle. #2471 validates model introspection before benchmarking; it does not change measurement. #3843 compares catalog models before download. #4064 overlaps independent usage scrapes. This PR fixes benchmark attribution and preserves discovery, activation, authentication and the existing performance storage boundary.Validation
pytest -q tests/test_benchmark_measurement.py tests/test_models.py tests/test_performance_oracle.py— 169 passed, Python 3.11.16; one dependency deprecation warning.git diff --checkpassed.The shipped NVIDIA default is llama.cpp b9014. Its server contract documents request timing fields;
/metricsdocuments aggregate generation counters. Tests use those response contracts and a controlled clock; they do not claim a measured GPU throughput improvement or live Lemonade validation.Wall-time measurements include prompt processing, queueing and transport and are explicitly labelled; decode timings describe generation. Concurrent load can still slow the request itself. Previously saved samples are not rewritten, and this does not solve model replacement during an in-flight request. Revert restores the previous measurement behavior without a schema migration. Shared Python covers the API on Linux/macOS/Windows; executed evidence is Linux/WSL. Batch baseline gate limitations remain root/WSL fixtures and unchanged dummy private-key fixtures.