Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
load_state_dict(..., assign=True)of a v1qzerostensor into a v2-runtime kernelskipped the v1→v2 conversion, silently corrupting every zero point (regression from
08f1b2b / #4166).
The load hook decided whether the incoming words were the module's own live buffer by
calling
_incoming_qzeros_is_live()aftersuper()._load_from_state_dict(). Withassign=True, torch rebindsself.qzerosto the incoming checkpoint tensor, so thatcheck compared the tensor against itself, reported "refill", and skipped the conversion.
torch.distributed.checkpoint'sset_model_state_dictusesassign=Trueformeta-device models, so it hit the same path.
What Changed
gptqmodel/nn_modules/qlinear/__init__.py(only file changed):_load_from_state_dictnow evaluates_incoming_qzeros_is_live()before the copyand reuses that flag for the post-copy decision. Genuine checkpoint loads convert under
both
assign=Falseandassign=True; a refill of the module's own buffer still does not(the [BUG]
GPTQModel.load(...).save(...)corruptsqzeros(every zero point shifted; sharded checkpoints become garbage) #4166 protection is unchanged, it is just measured at the correct time)._incoming_qzeros_is_livealso requires matching devices, so an incoming tensor on adifferent device can never be mistaken for an aliased live buffer by a numeric
data_ptr()collision.Tests
New
tests/test_qzeros_assign_load_4304.py:test_assign_true_converts_v1_qzeros_like_assign_false— loads raw v1 words(
0x77777777) into a v2-runtimeTorchLinearwhose checkpoint format is v1, withassign=Falseandassign=True; both must yield the logical0x88888888words andqzero_format() == 2.test_assign_true_does_not_double_convert_refilled_live_buffer— [BUG]GPTQModel.load(...).save(...)corruptsqzeros(every zero point shifted; sharded checkpoints become garbage) #4166 regressionguard: a marker-less refill of the live buffer (identity/aliased tensor) is not shifted
under either assign mode.
test_assign_true_is_idempotent_with_marker_carrying_refill— a marker-carryingaccelerate/DCP refill stays a no-op under both assign modes.
End-to-end check against the issue repro (tiny local GPTQ v1 checkpoint, CPU):
Pre-existing, unrelated failures on this CPU-only box (identical at the base commit):
tests/test_checkpoint_state_invariant.pyAVX512-BF16 kernel cases (compiled extensionnot built) and
tests/kernels/test_ret_idx_cache_invalidation.py::test_fused_refresh_preserves_wider_source_metadata[load_assign-*](
"rshift_cpu" not implemented for 'Float').Fixes #4304