Skip to content

Commit 9fd0bac

Browse files
committed
fix: Changed try block for gptqmodel to optional dependency guard
Signed-off-by: Brandon Groth <[email protected]>
1 parent 968168b commit 9fd0bac

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

fms_mo/modules/linear.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,13 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:
15831583
return x.to(in_dtype)
15841584

15851585

1586-
try:
1586+
gptq_available = (
1587+
available_packages["gptqmodel"]
1588+
and available_packages["gptqmodel_exllama_kernels"]
1589+
and available_packages["gptqmodel_exllamav2_kernels"]
1590+
)
1591+
1592+
if gptq_available:
15871593
# Third Party
15881594
from gptqmodel.nn_modules.qlinear.exllama import (
15891595
ExllamaQuantLinear as QLinearExllamaV1,
@@ -1882,12 +1888,6 @@ def forward(self, x, force_cuda=False):
18821888
x.add_(self.bias)
18831889
return x
18841890

1885-
except ModuleNotFoundError:
1886-
logger.warning(
1887-
"GPTQModel is not properly installed. "
1888-
"QLinearExv1WI4AF16 and QLinearExv2WI4AF16 wrappers will not be available."
1889-
)
1890-
18911891

18921892
class LinearFuncFPxFwdBwd(torch.autograd.Function):
18931893
"""Linear function using FP24 accumulation, experimental only.
@@ -2355,6 +2355,14 @@ def extra_repr(self) -> str:
23552355
if available_packages["mx"]:
23562356
QLinear_modules += (QLinearMX,)
23572357

2358+
if gptq_available:
2359+
QLinear_modules += (
2360+
QLinearExllamaV1,
2361+
QLinearExllamaV2,
2362+
QLinearExv1WI4AF16,
2363+
QLinearExv2WI4AF16,
2364+
)
2365+
23582366

23592367
def isinstance_qlinear(module):
23602368
"""

0 commit comments

Comments
 (0)