fix: Respect PipelineTrainer max_batch_size#622
Merged
vivekkalyan merged 2 commits intomainfrom Mar 21, 2026
Merged
Conversation
e748071 to
d7a9a06
Compare
angkywilliam
approved these changes
Mar 21, 2026
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.
Goal
Make
PipelineTrainer.max_batch_sizeactually do what it says.Today ART exposes
max_batch_size, but_collect_batch()keeps draining the queue after it has already reached the configured cap. That makes the knob misleading and causes the trainer to train on oversized batches.Direction
Keep this PR very small:
_collect_batch()What Changed
max_batch_size=2and proves collection should happen across two batches, not one oversized batch_collect_batch()so the opportunisticget_nowait()drain loop stops oncelen(batch) == self.max_batch_size_collect_batch()call returns the remaining group and then sees the sentinel normallyWhy This Shape
The bug is not in the initial blocking wait for
min_batch_size. It is in the follow-up drain loop, which ignoredmax_batch_sizeentirely.So the fix stays exactly there. No queue rewrite, no new scheduler knobs, no policy changes.
Testing
Sky CPU unit run
ssh art-pipeline-batching-tests 'cd ~/sky_workdir && ~/.local/bin/uv run pytest tests/unit/test_pipeline_trainer_batching.py tests/unit/test_pipeline_trainer_metrics.py -q'2 passed, 8 warnings in 6.33sNotes