Skip to content

fix(hf): materialize 3-bit symmetric qzeros + fix INT3 legacy fixture (#6375) - #6392

Merged
Qubitium merged 3 commits into
mainfrom
fix/6375-int3-tests
Nov 29, 2026
Merged

Qubitium merged 3 commits into
mainfrom
fix/6375-int3-tests

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Follow-up to #6388

#6388 fixed the pre-7.0 INT3 v1 qzero corruption and added tests/test_int3_legacy_qzeros_6375.py. It merged onto a main that already contained #6386, and two #6386 interactions leave the new test red on main:

  1. Fixture tokenizer. The fixture's tiny WordLevel tokenizer has only special tokens, so the new tokenizer-usability guard rejects it (cannot encode ordinary text). Add ordinary word tokens to the vocabulary.
  2. 3-bit symmetric HF loads. fix(loader): reject tokenizer-less checkpoints and repair pad token (#6361) #6386 defers symmetric qzeros and regenerates them in _materialize_hf_sym_qzeros(), but qzeros_symmetric_word() only defines a single constant word for 2/4/8-bit continuous packing. Every 3-bit symmetric HF load raises legacy GPTQ qzeros padding is only defined for 2/4/8-bit continuous packing, got bits=3. Pack the constant 3-bit zero point with the 10-1-10-1-10 layout instead.

The PR also adds coverage for the plain-HF re-save retag path introduced by #6388.

Fixes #6375

Verification

  • tests/test_int3_legacy_qzeros_6375.py (11 tests) passes on merged main 1615accf9 with this PR: 11 passed.
  • The same test file fails 2 tests on unpatched main (the 3-bit HF materialization error above).
  • Ruff is clean on both changed files.

agent added 3 commits November 29, 2026 13:15
The HF bridge defers symmetric qzeros and regenerates them from the
constant zero point. qzeros_symmetric_word() only defines a single
constant word for 2/4/8-bit continuous packing, so every 3-bit symmetric
HF load raised after #6386. Pack the constant 3-bit zero point with the
10-1-10-1-10 layout instead.
@Qubitium
Qubitium marked this pull request as ready for review November 29, 2026 13:31
@Qubitium
Qubitium merged commit fb46e9a into main Nov 29, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/6375-int3-tests branch November 29, 2026 13:32
Qubitium added a commit that referenced this pull request Nov 29, 2026
* test(qzeros): pin the symmetric-qzeros state machine invariants

Six changes landed on the symmetric ``qzeros`` path in one day (#6388,
#6392, #6391, #6395, #6409 and the pending #6157 normalization). Each was
verified on its own; nothing pinned the combination, and a later edit can
satisfy one fix while breaking another.

The state machine has three markers (``_HF_LEGACY_QZEROS``,
``_HF_CHECKPOINT_SYM``, ``_HF_DEFER_SYM_QZEROS``) and two word encodings,
selected by ``_load_target_qzeros_format()``. The tests assert:

- a 32-aligned legacy projection never defers, and a real floor-width
  mismatch always does (#6409 / #6396);
- an asymmetric floor-width checkpoint is refused, never silently wrong;
- a deferred module materializes to the standard shape with a resolved
  layout that agrees with the one the kernel decodes;
- materialization is idempotent across 2/3/4/8-bit;
- the deferral marker and a materialized buffer are mutually exclusive;
- a float ``qzeros`` buffer (int4pack affine offsets) is never filled with
  a packed word -- skipped until the #6157 normalizer exists;
- a clean checkpoint's word survives the load, and every pre- and
  post-#2983 producer lands on the same decoded zero point.

``qzero_format()`` is deliberately not read as a decode answer before
``_qzeros_format_established``: every kernel is ``REQUIRES_FORMAT_V2``, so
the constructor placeholder ``1`` disagrees with the decoded ``2`` until a
load resolves it (#4377). That distinction is the whole reason the first
#6157 draft corrupted clean checkpoints.

Test-only. Verified 49 passed / 13 skipped on main (a4471c5) and
50 / 12 with #6419 applied; 68 passed / 17 skipped together with the four
existing qzeros test files, so there is no global-state pollution. Every
skip is a kernel-geometry or environment gate with a precise reason.

* test(qzeros): spell out the unreachable return after a pytest.skip

``_legacy_module_or_skip`` ended with a bare ``pytest.skip(...)`` call, which
reads as an implicit ``return None`` to static analysis and made CodeQL flag
the function for mixing explicit and implicit returns. ``pytest.skip``
raises, so the added return is unreachable; it exists only to make every
non-exceptional path explicit, and the comment says so.

Behaviour unchanged: 49 passed, 13 skipped, identical to before.

---------

Co-authored-by: agent <agent@local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant