Skip to content

test(checkpoint): guard empty buffers against save-time dedup - #5539

Merged
Qubitium merged 1 commit into
mainfrom
test/checkpoint-empty-buffer-dedup
Nov 19, 2026
Merged

Qubitium merged 1 commit into
mainfrom
test/checkpoint-empty-buffer-dedup

Conversation

@ZX-ModelCloud

Copy link
Copy Markdown
Collaborator

Summary

Every zero-element tensor reports storage pointer 0, so the save-time dedup in
get_state_dict_for_save collapsed all empty buffers into one key and dropped
the rest. A kernel may require such a key to be present (QQQ keeps an empty
s_group when group_size == in_features), which then fails on reload with
Missing required quantized weights.

The name-keyed branch that fixes this is in main, but nothing pins it.

What Changed

  • Add test_empty_buffers_are_not_collapsed_as_shared_storage beside the
    existing shared-storage dedup tests: two empty buffers must both survive
    get_state_dict_for_save.
  • No production code changes.

Refs #5126.

Tests

cd tests
python -m pytest test_save_state_dict_buffer_collection.py -o addopts= -rA --timeout=300
# 7 passed

# Red evidence: temporarily delete the `elif tensor.numel() == 0:` branch from
# gptqmodel/utils/model.py, then re-run the same command:
# 1 failed  (test_empty_buffers_are_not_collapsed_as_shared_storage)
  • Unit tests have been executed and passed, or the reason they are not applicable is documented.
  • I added a new simple/fast unit test for this change, or documented why that is not applicable.

#5126 keys zero-element buffers by name because every empty tensor reports
storage pointer 0, but nothing pinned that behaviour: removing the branch
collapses `empty_left`/`empty_right` into a single entry and drops a key a
kernel may require (QQQ `s_group` when `group_size == in_features`).

Add the regression beside the existing shared-storage dedup tests.

Red (with the `numel() == 0` branch removed): 1 failed.
Green: 7 passed.
@Qubitium
Qubitium marked this pull request as ready for review November 19, 2026 10:38
@Qubitium
Qubitium merged commit 348d213 into main Nov 19, 2026
6 checks passed
@Qubitium
Qubitium deleted the test/checkpoint-empty-buffer-dedup branch November 19, 2026 10:38
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.

2 participants