Skip to content

Commit 85896e2

Browse files
fix(global_ptq): make MDBF detection tolerate a missing MDBF quantizer
detect_quantization_method() imported MultipathMDBFLinear unconditionally, so on an installation without onecomp.quantizer.mdbf *every* call raised ModuleNotFoundError -- including for plain GPTQ and DBF models. On this PR's base branch that broke the existing TestDetectQuantizationMethod tests (3 failures). Guard the import and treat MDBF as absent when it cannot be imported, so GPTQ/DBF detection keeps working without the MDBF quantizer. Verified both ways: without MDBF the global_ptq unit tests pass (69 passed, integration tests deselected), and with MDBF present (merged with feature/mdbf) detection still resolves MultipathMDBFLinear.
1 parent b9940cc commit 85896e2

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

  • global_ptq/onecomp_globalptq/global_ptq/_core

global_ptq/onecomp_globalptq/global_ptq/_core/helpers.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,20 @@ def detect_quantization_method(
8585
"""
8686
from onecomp.quantizer.gptq.gptq_layer import GPTQLinear
8787
from onecomp.quantizer.dbf.dbf_layer import DoubleBinaryLinear
88-
from onecomp.quantizer.mdbf.mdbf_layer import MultipathMDBFLinear
88+
89+
try:
90+
from onecomp.quantizer.mdbf.mdbf_layer import MultipathMDBFLinear
91+
except ImportError:
92+
# MDBF quantizer is optional; without it only GPTQ/DBF are detectable.
93+
MultipathMDBFLinear = None
8994

9095
gptq_modules = find_target_modules(model, GPTQLinear)
9196
dbf_modules = find_target_modules(model, DoubleBinaryLinear)
92-
mdbf_modules = find_target_modules(model, MultipathMDBFLinear)
97+
mdbf_modules = (
98+
find_target_modules(model, MultipathMDBFLinear)
99+
if MultipathMDBFLinear is not None
100+
else []
101+
)
93102

94103
if gptq_modules and (dbf_modules or mdbf_modules):
95104
logger.warning(

0 commit comments

Comments
 (0)