Skip to content

test(hf): pin the import-order-independent Optimum GPTQ bridge (#4749) - #4779

Merged
Qubitium merged 1 commit into
mainfrom
root/optimum-bridge-4749
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
root/optimum-bridge-4749

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

test(hf): pin the import-order-independent Optimum GPTQ bridge (#4749)

#4771 fixed #4749 - the Optimum GPTQ bridge is now retried from Transformers'
GptqHfQuantizer hooks instead of being latched off when optimum.gptq is
observed mid-initialization - but it shipped without a test. Nothing in the
suite distinguishes "Optimum is not installed" from "optimum.gptq is importing
gptqmodel right now", which is exactly the state that silently decoded every
dynamic override with the global bits (NLL 3.45 -> 16.49, no error, no
warning).

Three tests pin the contract of _ensure_optimum_gptqmodel_load_bridge:

  • a stand-in optimum.gptq that has no GPTQQuantizer yet (the real import
    window) must return False and must not set
    _OPTIMUM_GPTQ_BRIDGE_UNAVAILABLE, so the retry stays possible;
  • once the class appears, the same call must install the bridge, set
    _OPTIMUM_GPTQ_BRIDGE_INSTALLED, wrap convert_model/post_init_model, and
    stay idempotent on a second call;
  • a genuinely missing Optimum (find_spec -> None) must set the sticky
    _OPTIMUM_GPTQ_BRIDGE_UNAVAILABLE latch so a load does not retry the failed
    import.

Verified: all three fail on the pre-#4771 tree (9a63019a8, where the retry
path and its state flags do not exist yet) and tests/test_hf_gptqmodel_load_bridge.py
passes 30/30 on current main. Test-only, no production change.

#4771 fixed #4749 - the Optimum GPTQ bridge is now retried from Transformers'
`GptqHfQuantizer` hooks instead of being latched off when `optimum.gptq` is
observed mid-initialization - but it shipped without a test. Nothing in the
suite distinguishes "Optimum is not installed" from "optimum.gptq is importing
gptqmodel right now", which is exactly the state that silently decoded every
`dynamic` override with the global bits (NLL 3.45 -> 16.49, no error, no
warning).

Three tests pin the contract of `_ensure_optimum_gptqmodel_load_bridge`:

* a stand-in `optimum.gptq` that has no `GPTQQuantizer` yet (the real import
  window) must return `False` and must **not** set
  `_OPTIMUM_GPTQ_BRIDGE_UNAVAILABLE`, so the retry stays possible;
* once the class appears, the same call must install the bridge, set
  `_OPTIMUM_GPTQ_BRIDGE_INSTALLED`, wrap `convert_model`/`post_init_model`, and
  stay idempotent on a second call;
* a genuinely missing Optimum (find_spec -> None) must set the sticky
  `_OPTIMUM_GPTQ_BRIDGE_UNAVAILABLE` latch so a load does not retry the failed
  import.

Verified: all three fail on the pre-#4771 tree (`9a63019a8`, where the retry
path and its state flags do not exist yet) and `tests/test_hf_gptqmodel_load_bridge.py`
passes 30/30 on current main. Test-only, no production change.
@Qubitium
Qubitium force-pushed the root/optimum-bridge-4749 branch from 59c9a92 to eec605b Compare November 17, 2026 14:49
@Qubitium Qubitium changed the title fix(hf): re-arm the Optimum GPTQ bridge for the Transformers-first import order (#4749) test(hf): pin the import-order-independent Optimum GPTQ bridge (#4749) Nov 17, 2026
@Qubitium
Qubitium merged commit 186a38d into main Nov 17, 2026
6 checks passed
@Qubitium
Qubitium deleted the root/optimum-bridge-4749 branch November 17, 2026 14:50
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