Skip to content
Open
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
6 changes: 3 additions & 3 deletions auto_round/calib_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def apply_chat_template_to_samples(samples, tokenizer, seqlen, system_prompt=Non
tokenize=False,
add_generation_prompt=True,
)
except:
except Exception:
logger.warning("Failed to apply chat template. removing the system role in chat history.")
message_modified = [msg for msg in message if msg["role"] != "system"]
chat_templated = tokenizer.apply_chat_template(
Expand Down Expand Up @@ -706,7 +706,7 @@ def get_dataset_len(dataset):
try:
dataset_len = len(dataset)
return dataset_len
except:
except Exception:
cnt = 0
for _ in dataset:
cnt += 1
Expand Down Expand Up @@ -748,7 +748,7 @@ def select_dataset(dataset, indices):
"""
try:
return dataset.select(indices)
except:
except Exception:
list_data = list(select(dataset, indices))
import pandas as pd

Expand Down
2 changes: 1 addition & 1 deletion auto_round/inference/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ def build_pip_commands(gptq_req, other_reqs):
for req in requirements:
try:
require_version(req)
except:
except Exception:
missing_requirements.append(req)

gptq_req = next((f'"{req}"' for req in missing_requirements if "gptqmodel" in req), None)
Expand Down
6 changes: 3 additions & 3 deletions auto_round/inference/convert_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def skip_not_convert_modules(model, quantization_config, layer_names, layer_conf
modules_to_not_convert = getattr(quantization_config, "modules_to_not_convert", [])
try: # transformers new api
modules_to_not_convert = get_modules_to_not_convert(model, modules_to_not_convert, add_default_skips=True)
except:
except Exception:
modules_to_not_convert = _get_modules_to_not_convert(model, modules_to_not_convert)
if modules_to_not_convert:
for layer_name in layer_names:
Expand Down Expand Up @@ -155,7 +155,7 @@ def _get_modules_to_not_convert(
from transformers.quantizers.base import HfQuantizer

get_modules_to_not_convert = HfQuantizer.get_modules_to_not_convert
except:
except Exception:
get_modules_to_not_convert = _get_modules_to_not_convert


Expand Down Expand Up @@ -492,7 +492,7 @@ def _import_exllamav2_kernels():
"""Attempts to import ExLlamaV2 kernels for performance optimization."""
try:
from exllamav2_kernels import gemm_half_q_half, make_q_matrix # pylint: disable=E0611, E0401
except:
except Exception:
logger.warning_once(
"AutoGPTQ ExLlamaV2 has not been installed, Please install it using the following command: "
"`pip install git+https://github.com/AutoGPTQ/AutoGPTQ.git@b8b4127`"
Expand Down
2 changes: 1 addition & 1 deletion auto_round/modeling/unfused_moe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def pre_check_config(model_name: str | torch.nn.Module, trust_remote_code: bool
for key in model_keys:
if "gate_up_proj" in key:
return False
except:
except Exception:
return True
return True

Expand Down
2 changes: 1 addition & 1 deletion auto_round/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __getattr__(self, name):
try:
self.module = importlib.import_module(self.module_name)
mod = getattr(self.module, name)
except:
except Exception:
spec = importlib.util.find_spec(str(self.module_name + "." + name))
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
Expand Down
2 changes: 1 addition & 1 deletion auto_round/utils/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def set_cuda_visible_devices(device: str):
indices = [int(device) for device in devices]
try:
pick_device = [current_visible_devices[i] for i in indices]
except:
except Exception:
raise ValueError(
"Invalid '--device' value: It must be smaller than the number of available devices."
" For example, with CUDA_VISIBLE_DEVICES=4,5, "
Expand Down
2 changes: 1 addition & 1 deletion auto_round/utils/device_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def empty_cache(self) -> None:
if callable(fn):
try:
fn() # pylint: disable=E1102 # mps has issues
except:
except Exception:
pass

def device_index(self, index: int):
Expand Down
8 changes: 4 additions & 4 deletions auto_round/utils/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def _is_mxfp4_model(model_path, trust_remote_code=True):

try: # in case of config loading failure for new models
config = AutoConfig.from_pretrained(model_path, trust_remote_code=trust_remote_code)
except:
except Exception:
return False

model_type = getattr(config, "model_type", "")
Expand Down Expand Up @@ -844,7 +844,7 @@ def diffusion_load_model(
from transformers import AutoConfig

config = AutoConfig.from_pretrained(pretrained_model_name_or_path, trust_remote_code=trust_remote_code)
except:
except Exception:
config = None

model_type = getattr(config, "model_type", "")
Expand Down Expand Up @@ -1043,7 +1043,7 @@ def is_diffusion_model(model_or_path: Union[str, object], trust_remote_code: boo
# A special case for NextStep
if model_type == "nextstep":
return True
except:
except Exception:
logger.warning(
f"Failed to load config for {model_or_path}, trying to check model_index.json for diffusion pipeline."
)
Expand Down Expand Up @@ -1436,7 +1436,7 @@ def _to_model_dtype(model, model_dtype):
model = model.to(torch.bfloat16)
elif model_dtype == "float32" or model_dtype == "fp32" and model.dtype != torch.bfloat32:
model = model.to(torch.float32)
except:
except Exception:
logger.error("please use more device to fit the device or just use one device")
exit()
return model
Expand Down
Loading