Skip to content

Commit 7904137

Browse files
committed
change to exit early
Summary Signed-off-by: HDCharles <[email protected]>
1 parent 91ee4ba commit 7904137

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/llmcompressor/pytorch/model_load/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def load_safetensors_state_dict(file_path: str) -> Dict[str, torch.Tensor]:
144144
def copy_python_files_from_model_cache(model, save_path: str):
145145
config = model.config
146146
cache_path = None
147-
if hasattr(config, "_name_or_path") and len(config._name_or_path) > 0:
147+
if hasattr(config, "_name_or_path") and len(config._name_or_path.strip()) > 0:
148148
import os
149149
import shutil
150150

src/llmcompressor/transformers/utils/helpers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ def infer_recipe_from_model_path(model_path: Union[str, Path]) -> Optional[str]:
5858
- Hugging face model ID
5959
:return: The path to the recipe file if found, None otherwise.
6060
"""
61-
model_path = model_path.as_posix() if isinstance(model_path, Path) else model_path
61+
model_path = (
62+
model_path.as_posix() if isinstance(model_path, Path) else model_path.strip()
63+
)
64+
if model_path == "":
65+
logger.debug("got path_or_name=<empty string>" "unable to find recipe")
66+
return None
6267

6368
if os.path.isdir(model_path) or os.path.isfile(model_path):
6469
# Model path is a local path to the model directory or file

0 commit comments

Comments
 (0)