Skip to content

[BUG] Calibration rejects an HF Dataset left in with_format("pandas") or with_format("arrow") (and arrow [:] slices): only the format differs (#4652 incomplete) #4882

Closed

Description

@Qubitium

Found on main @ 4f287eb, CPU (x86_64), datasets with pyarrow/pandas installed.

What is wrong

prepare_calibration_dataset (gptqmodel/utils/calibration.py:436-437) turns an HF Dataset into rows with list(calibration_dataset). What iteration yields depends on the dataset's format, which is a property the user set earlier (often for another pipeline step):

  • ds.with_format("pandas"): iteration yields one-row pandas.DataFrames.
  • ds.with_format("arrow"): iteration yields one-row pyarrow.Tables, and ds.with_format("arrow")[:] is a pyarrow.Table (not a Mapping, and it has no to_dict, so _frame_columns does not pick it up).

None of these reach a supported row type, so quantize() rejects a plain HF Dataset (the documented input type) based only on its output format. #4652 fixed with_format("numpy")[:] and top-level DataFrames, but not these formats. torch, numpy, python and their [:] slices all work and give the expected tokens.

Repro (prep level; same result through quantize(CalibrationConfig(dataset=...)))

from datasets import Dataset
from gptqmodel.utils.calibration import prepare_calibration_dataset
ds = Dataset.from_dict({"text": texts})               # 3 English sentences
ids = ds.map(lambda x: tok(x["text"])).remove_columns(["text"])
for d in (ds, ids):
    for fmt in ("torch", "numpy", "python", "pandas", "arrow"):
        prepare_calibration_dataset(q, d.with_format(fmt))
        prepare_calibration_dataset(q, d.with_format(fmt)[:])
Dataset[text].with_format(torch)          OK   (and numpy/python, and their [:])
Dataset[text].with_format(pandas)         EXC ValueError: Quantize: unsupported calibration example type <class 'pandas.DataFrame'> at index 0.
Dataset[ids].with_format(pandas)          EXC ValueError: Quantize: unsupported calibration example type <class 'pandas.DataFrame'> at index 0.
Dataset[text].with_format(arrow)          EXC ValueError: Quantize: unsupported calibration example type <class 'pyarrow.lib.Table'> at index 0.
Dataset[text].with_format(arrow)[:]       EXC ValueError: Quantize: unsupported calibration example type <class 'pyarrow.lib.ChunkedArray'> at index 0.
Dataset[ids].with_format(arrow)           EXC ValueError: Quantize: unsupported calibration example type <class 'pyarrow.lib.Table'> at index 0.
Dataset[ids].with_format(arrow)[:]        EXC ValueError: Quantize: unsupported calibration example type <class 'pyarrow.lib.ChunkedArray'> at index 0.

(Same with the Qwen2.5 and Llama-3.2 tokenizers; with_format("pandas")[:] works because it is a top-level DataFrame.)

Suggested fix

For an HF Dataset/IterableDataset, iterate calibration_dataset.with_format(None) (python rows), whatever format the caller left on it. For a top-level pyarrow.Table, use table.to_pydict() in _frame_columns. The VLM splitter (models/definitions/_vlm_calibration.py:219-224) goes through the same helpers, so it is fixed by the same change.

Test that should have caught it

tests/test_calibration_mapping_input.py / tests/test_calibration_input_gaps_4311.py: parametrize over Dataset.with_format(fmt) for every datasets format (None, torch, numpy, pandas, arrow), both iterated and sliced.

Severity

Low. The failure is loud and with_format(None) works around it, but an HF Dataset is the primary documented calibration input and the rejection depends only on its display format.

🤖 Generated with Claude Code

Activity

  1. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Agent claim released: agent-11788dff99fd finished this issue.

    Pull request: #4902

    calibration: iterate HF datasets through with_format(None) and accept a top-level pyarrow Table via to_pydict, so only the caller's display format differs; parametrized test over every datasets format

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions