Added batch_size support to sliced inference with deterministic outputs and full test coverage#1318
Open
Added batch_size support to sliced inference with deterministic outputs and full test coverage#1318
batch_size support to sliced inference with deterministic outputs and full test coverage#1318Conversation
Author
|
Hi @onuralpszr, thanks for the update! I’d appreciate it if you could help assign a reviewer for this PR. |
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
This PR introduces
batch_sizesupport forget_sliced_prediction, enabling batched slice inference while keeping the API simple and backward compatible.This work is based on earlier community efforts and addresses the reliability concerns reported there. In particular, this implementation is a stable fork of the ideas discussed in:
Because this is a high-impact feature for production environment, we implemented and validated our own version end-to-end.
What Changed
Quoted from the commits in this branch:
38c45d4— “add batch_size support for sliced inference with backward-compatible fallback and tests”c517427— “Fix sliced progress callback and add robust batch-size equivalence test”Concretely:
batch_size: int = 1toget_sliced_prediction(...)batch_size >= 1)Nslices per batch)batch_sizeis not providedWhy This Matters
Previous attempts introduced important ideas but had runtime/test failures reported by users (shape mismatches, conversion issues, empty outputs, and
NotImplementedErrorpaths in some model tests).This PR focuses on correctness first: same outputs, safer fallback behavior, and minimal API change for users.
Usage
Only one additional argument is needed:
If
batch_sizeis omitted, behavior remains equivalent to current single-slice processing (batch_size=1).New Test Added
A new regression/equivalence test was added in
tests/test_predict.py:test_get_sliced_prediction_batch_size_exact_outputWhat it verifies:
batch_size=1,batch_size=4, andbatch_size=8This guarantees batching changes performance characteristics without changing detection results.
Validation
All tests were run successfully for this branch, including the new batch-size equivalence coverage.
Backward Compatibility
batch_size=1)