Skip to content

Conversation

@Narsil
Copy link
Contributor

@Narsil Narsil commented May 23, 2025

What does this PR do?

Add surface with file descriptors.

Checks that the object has a fileno() and a name, and reads the file.

loaded = {}
with fs.open("fs.safetensors", "rb") as f:
    with safe_open_handle(f, framework="np", device="cpu") as g:
        for key in g.keys():
            loaded[key] = g.get_tensor(key)

Fixes # (issue) or description of the problem this PR solves.

@Narsil Narsil marked this pull request as draft May 23, 2025 14:29
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Narsil Narsil marked this pull request as ready for review July 31, 2025 09:23
@Narsil Narsil changed the title [WIP]. Adding safe_handle. Adding _safe_open_handle. Jul 31, 2025
@Narsil Narsil requested a review from ArthurZucker July 31, 2025 09:24
Copy link
Contributor

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Narsil Narsil merged commit 48933f3 into main Aug 1, 2025
23 checks passed
@Narsil Narsil deleted the file_handle branch August 1, 2025 15:25
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.

4 participants