Skip to content
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

remove nested list in dict #774

Merged
merged 2 commits into from
Dec 5, 2024
Merged
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
37 changes: 18 additions & 19 deletions gptqmodel/utils/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
logger = setup_logger()

backend_dict = OrderedDict({
BACKEND.MARLIN: [MarlinQuantLinear],
BACKEND.EXLLAMA_V2: [ExllamaV2QuantLinear],
BACKEND.EXLLAMA_V1: [ExllamaQuantLinear],
BACKEND.TRITON: [TritonV2QuantLinear],
BACKEND.CUDA: [DynamicCudaQuantLinear],
BACKEND.BITBLAS: [BitBLASQuantLinear],
BACKEND.IPEX: [IPEXQuantLinear],
BACKEND.TORCH: [TorchQuantLinear],
BACKEND.MARLIN: MarlinQuantLinear,
BACKEND.EXLLAMA_V2: ExllamaV2QuantLinear,
BACKEND.EXLLAMA_V1: ExllamaQuantLinear,
BACKEND.TRITON: TritonV2QuantLinear,
BACKEND.CUDA: DynamicCudaQuantLinear,
BACKEND.BITBLAS: BitBLASQuantLinear,
BACKEND.IPEX: IPEXQuantLinear,
BACKEND.TORCH: TorchQuantLinear,
})

backend_dict_cpu = OrderedDict({
Expand Down Expand Up @@ -114,19 +114,18 @@ def select_quant_linear(
allow_backends = format_dict[format]
allow_quant_linears = backend_dict
err = None
for k, values in allow_quant_linears.items():
for v in values:
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}")
return v
else:
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}")
return v
else:
logger.info(f"Auto choose the fastest one based on quant model compatibility: {v}")
return v

if err:
raise err
Expand Down