Skip to content

[Bug Report] download_file_from_hf drops revision, local_files_only and other keyword-only kwargs #2038

Closed

Description

@nurlanmnn

Describe the bug

utils.download_file_from_hf silently ignores Hub options like revision, local_files_only, token and force_download. It passes extra kwargs through select_compatible_kwargs(kwargs, hf_hub_download), and that helper keeps only names from inspect.getfullargspec(...).args. In huggingface_hub, those options are keyword-only parameters of hf_hub_download, so they are never in .args and get dropped. (getfullargspec also doesn't follow functools.wraps, and hf_hub_download is decorated.)

So download_file_from_hf(repo, file, revision="some-commit") downloads the latest file instead of the pinned one, and local_files_only=True still goes to the network.

Code example

from huggingface_hub import hf_hub_download
from transformer_lens.utilities.hf_utils import select_compatible_kwargs

print(select_compatible_kwargs({"revision": "abc", "local_files_only": True, "bogus": 1}, hf_hub_download))
# prints {}
# expected {'revision': 'abc', 'local_files_only': True}

System Info

  • Installed from source (uv sync on dev)
  • macOS
  • Python 3.12, huggingface_hub 1.15.0

Additional context

I have a small fix ready: switch to inspect.signature(...).parameters and keep positional-or-keyword and keyword-only names.

Checklist

  • I have checked that there is no similar issue in the repo (required)

Activity

  1. added
    bug
    complexity-simple
    TransformerBridge
    on Nov 19, 2026
  2. jlarson4 commented on Nov 19, 2026

    @jlarson4
    Collaborator

    Closed with the merge of #2039

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

TransformerBridgebugcomplexity-simple

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions