Skip to content

How to change the model weights in safetensors? #575

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
JulioZhao97 opened this issue Feb 21, 2025 · 1 comment
Open

How to change the model weights in safetensors? #575

JulioZhao97 opened this issue Feb 21, 2025 · 1 comment

Comments

@JulioZhao97
Copy link

Feature request

For example, I want to change some weight with shape [K,K,C] into [K,K,C/2], how can I achieve this hacking?

Motivation

N/A

Your contribution

N/A

@Narsil
Copy link
Collaborator

Narsil commented Mar 13, 2025

Load the file, modify the tensors, resave the file.

This operation is destructive (you have less data than before) therefore doing a full rewrite of the file is necessary (there cannot be any holes in safetensors files)

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

No branches or pull requests

2 participants