Skip to content

fix(calibration): unpack columnar mappings instead of calibrating on keys - #4293

Merged
Qubitium merged 1 commit into
mainfrom
fix/4193-calibration-mapping
Nov 16, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/4193-calibration-mapping

Conversation

@ZX-ModelCloud

@ZX-ModelCloud ZX-ModelCloud commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

prepare_calibration_dataset() rejected only str before falling back to list(calibration_dataset). A top-level Mapping therefore became its keys:

  • model.quantize(tokenizer(texts)) calibrated on "input_ids" / "attention_mask".
  • load_dataset(...) without split= calibrated on "train" / "validation" / "test".

With the default calibration_data_min_length=10, every row was then dropped and quantization failed with a misleading "every input_ids was shorter than ..." error.

Fixes #4193.

Changes

  • Treat a top-level Mapping as calibration input:
    • A columnar BatchEncoding / dict of columns (input_ids, text, messages) is split into one example per row.
    • A single-example mapping (1-D input_ids, one text, one messages conversation) is kept as one row.
    • A DatasetDict-style mapping raises a clear ValueError listing the splits and suggesting dataset['train'].
    • Unknown mapping keys raise a clear ValueError with the keys.
    • Mismatched column lengths raise a clear ValueError.
  • Add regression coverage in tests/test_calibration_mapping_input.py.

Tests

  • tests/test_calibration_mapping_input.py: 9 passed
  • Full calibration suite (normalisation, padding_mask, truncation, windows, data_device, mapping_input, special_tokens_4191): 80 passed
  • ruff check on changed files: clean

Behavior

Before: a top-level mapping was iterated as its keys and those strings were tokenized as calibration text.

After: columnar mappings calibrate on their rows, and split mappings fail early with an actionable error.

@ZX-ModelCloud
ZX-ModelCloud force-pushed the fix/4193-calibration-mapping branch from a97b8b1 to 99bdca4 Compare November 16, 2026 07:52
@Qubitium
Qubitium merged commit 842d666 into main Nov 16, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/4193-calibration-mapping branch November 16, 2026 07:53
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] Passing a Mapping as the calibration dataset (BatchEncoding, dict of columns, DatasetDict) calibrates on the key names

2 participants