Skip to content
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

[finetune] Save and load loras in safetensors #171

Closed
olegklimov opened this issue Oct 5, 2023 · 1 comment
Closed

[finetune] Save and load loras in safetensors #171

olegklimov opened this issue Oct 5, 2023 · 1 comment
Assignees

Comments

@olegklimov
Copy link
Contributor

https://github.com/huggingface/safetensors/blob/main/bindings/python/convert.py

def convert_file(
    pt_filename: str,
    sf_filename: str,
):
    loaded = torch.load(pt_filename, map_location="cpu")
    if "state_dict" in loaded:
        loaded = loaded["state_dict"]
    shared = shared_pointers(loaded)
    for shared_weights in shared:
        for name in shared_weights[1:]:
            loaded.pop(name)

    # For tensors to be contiguous
    loaded = {k: v.contiguous() for k, v in loaded.items()}

    dirname = os.path.dirname(sf_filename)
    os.makedirs(dirname, exist_ok=True)
    save_file(loaded, sf_filename, metadata={"format": "pt"})
@olegklimov olegklimov moved this to Backlog 🤔 in Self-hosted / Enterprise Oct 5, 2023
@olegklimov olegklimov moved this from Backlog 🤔 to TODO in Self-hosted / Enterprise Oct 30, 2023
@JegernOUTT JegernOUTT moved this from TODO to In Progress in Self-hosted / Enterprise Oct 31, 2023
@JegernOUTT JegernOUTT moved this from In Progress to On Review in Self-hosted / Enterprise Oct 31, 2023
@JegernOUTT
Copy link
Member

#199

@github-project-automation github-project-automation bot moved this from On Review to Released in Docker Nightly in Self-hosted / Enterprise Dec 18, 2023
@mitya52 mitya52 moved this from Released in Docker Nightly to Released in Docker V1.2 in Self-hosted / Enterprise Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released in Docker V1.2
Development

No branches or pull requests

3 participants