Skip to content

Support using paddle in safe_open #630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zeroRains
Copy link

Support using paddle in safe_open API

This PR allows us to use safe_open API when set the framework='pp' or framework='paddle'. It just like the following code:

from safetensors import safe_open

tensors = {}
with safe_open(filename, framework="pp") as f:
    for k in f.keys():
        tensors[k] = f.get_tensor(k)

In this PR, I use the latest feature(MmapStorage) in paddle. It only support for paddle >= 3.1.0 or develop version.

We also can use the original way to load tensor if the paddle version is lower than 3.1.0.

ps: MmapStorage still a PR PaddlePaddle/Paddle#73820. It will be merged in develop and 3.1.0 branch later.

Copy link

@yuanlehome yuanlehome left a comment

Choose a reason for hiding this comment

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

LGTM,We hope that official classmates can help review and promote code integration. Thanks!

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