perf: scale throughput by effective batch size, not requested --batch-size#930
Open
xieofxie wants to merge 3 commits into
Open
perf: scale throughput by effective batch size, not requested --batch-size#930xieofxie wants to merge 3 commits into
xieofxie wants to merge 3 commits into
Conversation
Contributor
Author
|
For the issue 155, only the remaining |
DingmaomaoBJTU
left a comment
Collaborator
There was a problem hiding this comment.
Overall this is a clean, well-motivated fix. The core bug (samples_per_sec inflated by requested batch on static-batch models) is correctly diagnosed and fixed. The effective_batch_size helper is clear and its fallback behavior is well-documented. Tests cover the important scenarios including the regression guard. A few minor observations below.
- Simplify static-batch warning guard to fire consistently with the console Note (drop redundant batch_size != 1 check) - Document single-input assumption in effective_batch_size docstring
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
Fixes incorrect
samples_per_secinwmk perfwhen the requested--batch-sizecannot be applied to the model.The requested
--batch-sizeonly lands on inputs whose leading dimension is dynamic (see_resolve_shape). For a model with a statically-fixed batch dim (e.g.[1, 3, 224, 224]), input generation silently keeps the static value, so the session runs batch=1 — but throughput was still computed asconfig.batch_size / latency, inflatingsamples_per_secby the requested batch factor (e.g. reporting 800 sps when the model actually processed 100). Latency stats were always correct; only the derived per-sample throughput was wrong.Changes
effective_batch_size()— reads the actual batch back from the first batched (rank ≥ 1) generated input, matching the module's existing "first dim is batch" convention. Falls back to the requested value when all inputs are scalar._collect_results()now scalessamples_per_secby the effective batch the session ran, not the requestedconfig.batch_size. (batches_per_secwas already correct — it is per-call.)_generate_inputs()logs a warning when the requested--batch-sizecould not be applied (static batch dim).BenchmarkResultgains aneffective_batch_sizefield, surfaced in the JSONbenchmark_infoalongside the requestedbatch_size, and shown in the console throughput line with aNote:when the two differ.Tests
New
TestEffectiveBatchSizeintests/unit/commands/test_perf_cli.pycovers the helper (dynamic / static / scalar / fallback), throughput scaling for both static-batch (regression guard: 100 not 800 sps) and dynamic-batch cases, the warning on mismatch, and the JSON field. Fulltest_perf_cli.py,test_perf_module.py, andtest_perf_composite.pysuites pass.Scope note
This addresses the batch-size correctness aspect of the epic. The broader items (batch-size sweep
--batch-sizes 1,4,8,16and--ep allcross-EP comparison) are not part of this PR.Closes #155