Skip to content

Commit

Permalink
Switch resolving order if source not specified in load_adapter() (#681
Browse files Browse the repository at this point in the history
)

If `source` is not specified in `load_adapter()`, will switch priorities
to first search on HF Hub and only on AH if not found there. Related to
AH deprecation (#668).

This also fixes an bug with auto-resolving adapters for which no model
index file is given in AH (e.g. currently for Llama-2).
  • Loading branch information
calpt authored Apr 17, 2024
1 parent a3545c5 commit 51ba69a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/adapters/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,15 +719,15 @@ def resolve_adapter_path(
return pull_from_hf_model_hub(adapter_name_or_path, version=version, **kwargs)
elif source is None:
try:
logger.info("Attempting to load adapter from source 'ah'...")
return pull_from_hub(
adapter_name_or_path, model_name, adapter_config=adapter_config, version=version, **kwargs
)
except EnvironmentError as ex:
logger.info(ex)
logger.info("Attempting to load adapter from source 'hf'...")
return pull_from_hf_model_hub(adapter_name_or_path, version=version, **kwargs)
except (EnvironmentError, ValueError) as ex:
logger.info(ex)
logger.info("Attempting to load adapter from source 'ah'...")
try:
return pull_from_hf_model_hub(adapter_name_or_path, version=version, **kwargs)
return pull_from_hub(
adapter_name_or_path, model_name, adapter_config=adapter_config, version=version, **kwargs
)
except Exception as ex:
logger.info(ex)
raise EnvironmentError(
Expand Down

0 comments on commit 51ba69a

Please sign in to comment.