Skip to content

fix ipex cpu backend import error and fix too much logs #793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions gptqmodel/nn_modules/qlinear/dynamic_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@

logger = setup_logger()

import gptqmodel_cuda_64 # noqa: E402
import gptqmodel_cuda_256 # noqa: E402

gptqmodel_cuda_import_exception = None
try:
import gptqmodel_cuda_64 # noqa: E402
import gptqmodel_cuda_256 # noqa: E402
except ImportError as e:
gptqmodel_cuda_import_exception = e


class DynamicCudaQuantLinear(TorchQuantLinear):
Expand Down Expand Up @@ -40,6 +45,10 @@ def __init__(
kernel_switch_threshold=128,
**kwargs,
):
if gptqmodel_cuda_import_exception is not None:
raise ValueError(
f"Trying to use the cuda backend, but could not import the C++/CUDA dependencies with the following error: {gptqmodel_cuda_import_exception}"
)
super().__init__(bits=bits, group_size=group_size, sym=sym, desc_act=desc_act, infeatures=infeatures,
outfeatures=outfeatures, bias=bias, weight_dtype=weight_dtype, **kwargs)

Expand Down
10 changes: 8 additions & 2 deletions gptqmodel/utils/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,23 @@ def select_quant_linear(
allow_backends = format_dict[format]
allow_quant_linears = backend_dict
err = None
# Suppose all quant linears in the model should have the same backend.
has_logged = False
for k, v in allow_quant_linears.items():
in_allow_backends = k in allow_backends
validate, err = v.validate(bits, group_size, desc_act, sym, dynamic=dynamic, device=device, trainable=trainable)
if in_allow_backends and validate:
if pack:
check_pack_func = hasattr(v, "pack")
if check_pack_func:
logger.info(f"Auto choose the fastest one based on quant model compatibility: {v}")
if not has_logged:
logger.info(f"Auto choose the fastest one based on quant model compatibility: {v}")
has_logged = True
return v
else:
logger.info(f"Auto choose the fastest one based on quant model compatibility: {v}")
if not has_logged:
logger.info(f"Auto choose the fastest one based on quant model compatibility: {v}")
has_logged = True
return v

if err:
Expand Down