Repository navigation
[RunInference] Validate model handler batching arguments - #40718
jrmccluskey merged 6 commits into
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR adds constructor-time validation in ModelHandler.__init__ to fail fast when max_batch_weight is provided without element_size_fn, or when max_batch_weight is combined with length-bucketing arguments (batch_length_fn or batch_bucket_boundaries). The implementation and unit tests in base.py and base_test.py are clean and align with the validation rules in BatchElements.__init__.
🔍 General Feedback
- Consider verifying or standardizing
RemoteModelHandlersubclasses (VertexAIModelHandlerJSONinvertex_ai_inference.pyandGeminiModelHandleringemini_inference.py), which inherit fromRemoteModelHandlerand constructself._batching_kwargsdirectly without callingModelHandler.__init__, so they currently defer this validation untilBatchElementsconstruction. - In
base_test.py,test_batch_elements_kwargs_all_argswas repurposed to test only length-aware arguments while dropping assertions formax_batch_weightandelement_size_fn; keeping a separate test for weight-based batching kwargs would preserve full unit test coverage forbatch_elements_kwargs().
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
💬 Inline Findings
sdks/python/apache_beam/ml/inference/base_test.py(line 2588): 🟢 Nit: Replacingmax_batch_weightandelement_size_fnhere removes the test coverage inModelHandlerBatchingArgsTestverifying thatmax_batch_weightandelement_size_fnare populated intobatch_elements_kwargs()when valid. Consider keeping a separate test method (e.g.,test_batch_elements_kwargs_weight_args) that assertsmax_batch_weightandelement_size_fnare present inbatch_elements_kwargs().
|
Assigning reviewers: R: @jrmccluskey for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #40718 +/- ##
==========================================
- Coverage 80.04% 79.93% -0.12%
==========================================
Files 490 493 +3
Lines 82916 83419 +503
==========================================
+ Hits 66373 66682 +309
- Misses 16543 16737 +194
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
R: @Eliaaazzz |
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
There was a problem hiding this comment.
Thanks for following up on #40644! The validation matches the combinations we agreed on, and the explicit calls in the remote handlers cover the constructors that bypass ModelHandler.init. I didn't find a blocking correctness issue. One small documentation suggestion inline.
jrmccluskey
left a comment
There was a problem hiding this comment.
LGTM; the recurring validation tests per model handler are a little overkill (testing in base_test.py should be sufficient) but harmless.
Summary
max_batch_weightrequireselement_size_fn.max_batch_weightwithbatch_length_fnorbatch_bucket_boundaries.batch_bucket_boundariesrequiresbatch_length_fn.Testing
ModelHandlerBatchingArgsTest: 17 passed.git diff --check: passed.