Skip to content

[BUG] quantize() crashes on datasets.IterableDataset / any iterable without len(), although the calibration helper accepts them #4192

Closed

Description

@Qubitium

Severity: medium (documented input type crashes)
Version: 7.11.0 @ 9dad249

Summary

  • looper/loop_processor.py:432-439 calls len(calibration_dataset) on the raw input before prepare_dataset runs.
  • CalibrationInputType / prepare_calibration_dataset (utils/calibration.py:61-67, :161-168) explicitly accept HFIterableDataset and generic iterables, via list(...).
  • The Qwen3-VL prepare_dataset (base_qwen3_vl.py:547-557) is written to keep image iterators lazy, so that path can't be reached either.
  • datasets 5.2 IterableDataset has no __len__.

Reproduce

from gptqmodel import GPTQModel, QuantizeConfig
model = GPTQModel.load("facebook/opt-125m", QuantizeConfig(bits=4, group_size=32))
texts = ["Once upon a time there was a little girl who loved to play in the park. " * 3] * 8
class Stream:   # same contract as datasets.IterableDataset
    def __iter__(self): return iter({"text": t} for t in texts)
model.quantize(Stream())
# TypeError: object of type 'Stream' has no len()   (loop_processor.py:434)

Expected

Materialise or prepare the dataset first, then run the size and average-length checks on the prepared batches.


Found during an AI-assisted review (Claude Code) of 9dad249; repros were run on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions