Skip to content

fix: materialise one-shot calibration input for native and EoRA passes (#4307) - #4329

Merged
Qubitium merged 1 commit into
mainfrom
pr/4307
Nov 16, 2026
Merged

Qubitium merged 1 commit into
mainfrom
pr/4307

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

Fixes #4307. A one-shot iterable (generator) passed as quantize() calibration data failed with ValueError: Quantize: calibration dataset is empty. whenever the run plan had both a native and an EoRA step (GPTAQ or a LoRA/EoRA adapter). list(texts) worked because the list can be iterated again.

Root cause

BaseQModel._quantize_with_calibration() builds a separate CalibrationConfig for the NATIVE step and for the EORA step, and each LoopProcessor.__init__ re-runs prepare_dataset on its raw input. #4192 (b7a352f) only normalised the prepared result; the raw generator is exhausted by the first processor, so the second one receives nothing.

What Changed

  • gptqmodel/looper/loop_processor.py: add _reusable_calibration_dataset(). It materialises only plain one-shot iterators (iter(obj) is obj, e.g. generators), returns sized containers untouched (no unnecessary copy), and leaves datasets.IterableDataset lazy because it yields a fresh iterator.
  • gptqmodel/models/base.py: in _quantize_with_calibration(), normalise calibration and adapter_calibration_dataset once, before the native and EoRA CalibrationConfigs are built and shared with their processors.

Tests

New tests/test_generator_calibration_4307.py (tiny locally-built Llama, CPU, no downloads):

  • generator calibration + GPTAQConfig quantizes successfully (NATIVE + EORA).
  • generator calibration + Lora(rank=4) produces EoRA adapters.
  • generator adapter_calibration_dataset with a LoRA adapter works.
  • _reusable_calibration_dataset returns a sized list by identity, materialises a generator, passes None through, and keeps an HF IterableDataset lazy.

Both end-to-end cases fail on unpatched base.py with ValueError: Quantize: calibration dataset is empty. and pass with the fix.

$ CUDA_VISIBLE_DEVICES= GPTQ_BYPASS_SAFETY_CHECKS=1 PYTHONPATH=$PWD python3 -m pytest tests/test_generator_calibration_4307.py tests/test_looper_concurrency.py tests/test_prepare_dataset.py -q
55 passed in 20.49s

$ ruff check gptqmodel/looper/loop_processor.py gptqmodel/models/base.py tests/test_generator_calibration_4307.py
All checks passed!

Fixes #4307

@Qubitium
Qubitium merged commit 9edc183 into main Nov 16, 2026
6 of 9 checks passed
@Qubitium
Qubitium deleted the pr/4307 branch November 16, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] A one-shot iterable (generator) as calibration data fails with GPTAQ or LoRA/EoRA: "calibration dataset is empty" (incomplete fix of #4192)

1 participant