Repository navigation
Handle unknown batch size in sharded dataloader metadata - #4491
Draft
Aurantium-47 wants to merge 1 commit into
Draft
Aurantium-47 wants to merge 1 commit into
Aurantium-47 wants to merge 1 commit into
Conversation
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.
What does this PR do?
Return
NoneforDataLoaderShard.total_batch_sizewhen a variable batch sampler hasbatch_size=None, instead of raisingTypeErrorwhile multiplying it by the process count. This applies after existingSkipBatchSamplerunwrapping.Keep the remainder explicitly unknown (
-1) when no constant batch size is available, document that contract, and correct thegather_for_metricsinformational message: an unknown remainder does not necessarily mean that the dataset has no length. Gathering/trimming logic is unchanged; callers remain responsible for duplicate removal when the remainder is unknown.Known-size behavior is unchanged. This does not add variable split-batch support, change sharding/padding, or make uneven distributed collectives safe.
Validation
Reapplied the independently reviewed patch to upstream main
f47439c1fb24721ea71ab98f9b512726b5a97828and reran:PYTHONPATH=src ACCELERATE_USE_CPU=true python -m pytest tests/test_variable_batch_metadata.py tests/test_data_loader.py -q -rs: 41 passed, 12 skipped (optionaltorchdata.stateful_dataloaderabsent).make qualitywith the project's pinned Ruff 0.13.1: all checks passed, 184 files formatted.Linux CPU, Python 3.12.14, PyTorch 2.15.0+cpu. No distributed process group was launched for this validation; DDP, GPU, XLA and full repository-suite validation are not claimed.
Related but distinct: #4416 repairs sized iterable metadata; #4489 chooses sampler length for the remainder. Neither fixes
batch_size=None. A local compatibility probe with their fetched changes passed (45 passed, 12 optional skips), preserving #4489's unsized-sampler fallback. Those changes are not included here; its overlapping modulo line will need care if it lands first.Developed with AI assistance, including separate automated code review. No human review or prior maintainer approval is claimed.
Before submitting
Who can review?
Submitted as a draft; no reviewer is assigned by this description.