-
Notifications
You must be signed in to change notification settings - Fork 39
Replace bare excepts with specific exception types and add explicit weights_only to torch.load #373
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| try: | ||
| from .evo_2_config import Evo2Config | ||
| from .model import Evo2 | ||
| except: | ||
| except ImportError: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Broaden to |
||
| LOGGER = logging.getLogger(__name__) | ||
| LOGGER.info( | ||
| "Evo 2 not available: If you want to use this model, please follow the installation instructions in the evo_2/README." | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ | |
| from vortex.model.generation import generate as vortex_generate | ||
| from vortex.model.model import StripedHyena | ||
| from vortex.model.utils import dotdict, load_checkpoint | ||
| except: | ||
| except ImportError: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Broaden to |
||
| message = "Vortex is required for Evo 2 model. Please follow the instructions in the README to install it." | ||
| LOGGER.error(message) | ||
| raise ImportError( | ||
|
|
@@ -380,7 +380,7 @@ def _load_evo2_model(self, model_name: str = None): | |
| filename=filename, | ||
| ) | ||
| # If file is split, download and join parts | ||
| except: | ||
| except huggingface_hub.utils.EntryNotFoundError: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep it to |
||
| print(f"Loading checkpoint shards for {filename}") | ||
| # If file is split, get the first part's directory to use the same cache location | ||
| weights_path = os.path.join( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,8 +47,8 @@ def load_weights(scratch_dict, pretrained_dict, checkpointing=False): | |
| key_loaded = inject_substring(key_loaded) | ||
| try: | ||
| scratch_dict[key] = pretrained_dict[key_loaded] | ||
| except: | ||
| raise Exception("key mismatch in the state dicts!") | ||
| except KeyError: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep the original error's context by capturing it as |
||
| raise KeyError("key mismatch in the state dicts!") | ||
|
|
||
| # scratch_dict has been updated | ||
| return scratch_dict | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broaden to
except (ImportError, OSError, RuntimeError):for non-CUDA environments.