You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] concat_size packing runs after the per-row min_length filter and position-budget trim: short documents dropped (397/400 rows), long documents truncated before windowing #4892
prepare_calibration_dataset applies two per-row policies beforeconcat_size packing (gptqmodel/utils/calibration.py:796-898, then packing at :949-1051). Both are meant to protect unpacked rows, and both throw away data that packing would have used:
min_length drops short documents before they are packed (:859-862). Packing exists to combine short samples into full windows, but every document of <= min_length (default 10) tokens is discarded first. On a dataset of short utterances, almost the whole corpus disappears. The warning blames the rows (Use CalibrationConfig(min_length=...)), not the combination with concat_size.
The position-budget trim cuts a long document before it is split into windows (:827-846). A document longer than max_position_embeddings is truncated to that length, then packed into concat_size windows, which are all far below the budget. Everything past max_position_embeddings is lost with only an INFO line (trimmed 1 calibration rows above max_position_embeddings). A window can never exceed the budget as long as concat_size <= max_position_embeddings, so the trim is unnecessary on this path.
Meanwhile the packed windows themselves are never checked: the padded tail window is kept even with only a few real tokens, and concat_size > max_position_embeddings is not validated.
rows 400 tokens 2807 max row 11
WARN Quantize: 397 calibration rows with <= 10 non-padding tokens were removed. Use CalibrationConfig(min_length=...) ...
concat_size=256 min_length=10: windows=1 real tokens=33 <- 99% of the corpus dropped
concat_size=256 min_length=0: windows=11 real tokens=2807
INFO Quantize: trimmed 1 calibration rows above max_position_embeddings=32768 (longest original length=40000, truncation_side=right)
one 40000-token doc, concat_size=2048: windows=16 real tokens=32768 lost=7232
Suggested fix
When concat_size is set, skip the per-row min_length filter and the position-budget trim. Pack every real token first, then apply min_length to the packed windows (it then drops only a near-empty tail window). Validate concat_size <= max_position_embeddings up front instead. The non-concat path keeps its current per-row behaviour.
Test that should have caught it
tests/test_prepare_dataset.py concat cases use documents longer than min_length. Add a case with many sub-min_length documents and concat_size, asserting that every token is packed, and one with a document longer than max_position_embeddings.
Severity
Low-medium. Silent (or misattributed) loss of calibration data with concat_size. Short-utterance corpora are hit hardest (99% dropped in the repro); long-document corpora lose every token past max_position_embeddings.
concat_size: pack every real token before the per-row min_length/position-budget policies, apply min_length to the packed windows, validate concat_size <= max_position_embeddings up front
Activity
Qubitium commentedon Nov 17, 2026
Agent claim released:
agent-11788dff99fdfinished this issue.Pull request: #4916
concat_size: pack every real token before the per-row min_length/position-budget policies, apply min_length to the packed windows, validate concat_size <= max_position_embeddings up front
fix(calibration): pack before the per-row policies when concat_size i…