Skip to content

Commit

Permalink
Use .from_pretrained(..., use_auth_token=token) instead of token=token
Browse files Browse the repository at this point in the history
until it's fully supported across HF libs
  • Loading branch information
borzunov committed Jul 22, 2023
1 parent 16fa4f9 commit 519d6b7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/petals/server/from_pretrained.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def load_pretrained_block(
max_disk_space: Optional[int] = None,
) -> nn.Module:
if config is None:
config = AutoDistributedConfig.from_pretrained(model_name, token=token)
config = AutoDistributedConfig.from_pretrained(model_name, use_auth_token=token)
if cache_dir is None:
cache_dir = DEFAULT_CACHE_DIR

Expand Down
2 changes: 1 addition & 1 deletion src/petals/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __init__(

self.block_config = AutoDistributedConfig.from_pretrained(
converted_model_name_or_path,
token=token,
use_auth_token=token,
revision=revision,
)

Expand Down
8 changes: 6 additions & 2 deletions src/petals/utils/auto_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ class _AutoDistributedBase:

@classmethod
def from_pretrained(cls, model_name_or_path: Union[str, os.PathLike, None], *args, **kwargs) -> PretrainedConfig:
if always_needs_auth(model_name_or_path) and "token" not in kwargs and "use_auth_token" not in kwargs:
kwargs["token"] = True
if (
always_needs_auth(model_name_or_path)
and kwargs.get("token") is None
and kwargs.get("use_auth_token") is None
):
kwargs["use_auth_token"] = True

config = AutoConfig.from_pretrained(model_name_or_path, *args, **kwargs)
if config.model_type not in _CLASS_MAPPING:
Expand Down
25 changes: 0 additions & 25 deletions tests/scripts/remove_old_models.py

This file was deleted.

0 comments on commit 519d6b7

Please sign in to comment.