Skip to content

Conversation

@dtrifiro
Copy link

If files are local, there's no need to go through the (optional) blobfile dependency, we can just read them using the standard open/read API.

This solves some issues when trying to load files that have already been downloaded to the HF cache.

See for example vllm-project/vllm#21750

@dtrifiro dtrifiro force-pushed the make-blobfile-optional branch from 06cb4c1 to 7f6835e Compare September 1, 2025 13:27
@tiran
Copy link

tiran commented Sep 1, 2025

@dtrifiro here is a better version that also handles file:// URI correctly:

import urllib.parse

def read_file(blobpath: str) -> bytes:
    # convert file:// URI to local file path
    if blobpath.startswith("file://"):
        parsed = urllib.parse.urlparse(blobpath)
        if parsed.hostname and parsed.hostname != "localhost":
            # must be None, empty, or localhost
            raise ValueError(f"invalid file URI {blobpath}")
        blobpath = urllib.parse.unquote(parsed.path)

    # a path without :// is a local path
    if "://" not in blobpath:
        with open(blobpath, "rb") as f:
            return f.read()

    if blobpath.startswith(("http://", "https://")):
        # avoiding blobfile for public files helps avoid auth issues, like MFA prompts.
        import requests

        resp = requests.get(blobpath)
        resp.raise_for_status()
        return resp.content

    try:
        import blobfile
    except ImportError as e:
        raise ImportError(
            "blobfile is not installed. Please install it by running `pip install blobfile`."
        ) from e
    with blobfile.BlobFile(blobpath, "rb") as f:
        return f.read()

@dtrifiro
Copy link
Author

dtrifiro commented Sep 2, 2025

Updated as suggested

@dtrifiro dtrifiro closed this Sep 3, 2025
@dtrifiro dtrifiro reopened this Sep 4, 2025
@dtrifiro
Copy link
Author

Hey @hauntsaninja, mind taking a look if you have some bandwidth?

Thanks!

mkumatag pushed a commit to mkumatag/vllm-cpu that referenced this pull request Sep 23, 2025
Deployment of kimi models fails because of a missing `blobfile` dependency. We don't really need it, so we can add this fix
openai/tiktoken#446 to just load local files normally if present.
mkumatag pushed a commit to mkumatag/vllm-cpu that referenced this pull request Sep 23, 2025
- Dockerfile.rocm.ubi: add aiter dependencies, keep disabled aiter by
default
- Dockerfile*.ubi: fix tiktoken patch step (upstream:
openai/tiktoken#446)
- docker-bake: add note about `ROCM_VERSION` variable
- Dockerfile.rocm.ubi: remove deprecated
`VLLM_WHEEL_STRATEGY`/`FLASH_ATTENTION_WHEEL_STRATEGY` args
@dtrifiro
Copy link
Author

dtrifiro commented Oct 3, 2025

@dtrifiro dtrifiro closed this Oct 3, 2025
npanpaliya pushed a commit to odh-on-pz/vllm-cpu that referenced this pull request Oct 27, 2025
npanpaliya pushed a commit to odh-on-pz/vllm-cpu that referenced this pull request Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants