Repository navigation
fix(looper): accept calibration inputs without len() (#4192) - #4291
Merged
Merged
Conversation
datasets.IterableDataset and plain generators are documented calibration inputs, but LoopProcessor.__init__ called len() on the raw dataset before prepare_dataset could materialise it, so quantize() crashed with TypeError. Run the pre-prepare empty/size checks only when the input exposes a length, and verify emptiness on the prepared result instead. Materialise an unsized prepared result so the per-layer replay and batch accounting still get a reusable, sized dataset.
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
LoopProcessor.__init__calledlen()on the raw calibration dataset beforeCalibrationConfig.prepare_datasetran.prepare_calibration_datasetacceptsdatasets.IterableDatasetand generic iterables, which do not implement__len__, soquantize()crashed with:Model-specific
prepare_datasetoverrides (for example Qwen3-VL) also keepimage iterators lazy, so the raw input must not be materialised before
preparation.
Fix
and token statistics receive a reusable, sized dataset.
batch count after preparation.
Tests
Added to
tests/test_looper_concurrency.py:prepare_datasetuntouched.datasets.IterableDatasetcalibration input is accepted.prepare_datasetresult is materialised.Existing coverage still passes: empty sized input is rejected before
preparation, and an input emptied by preparation reports the post-prepare
error.
Fixes #4192