pytorch-diff-checkpoint
pytorch-diff-checkpoint is a simple library designed to efficiently save only the modified parameters of a fine-tuned base model and incur no additional VRAM overhead. This tool is particularly advantageous in scenarios where minimizing storage usage is crucial, as it ensures that only the altered parameters are stored.
It checks if a parameter is different by the "requires_grad" attribute, if the first element of the parameter is different, or if the parameter is not in the base model.
This automatically handles saving parameters changes by the optimizer or statistics like batch norm.
Installation
poetry add pytorch-diff-checkpoint
Usage
import torch
from torch.nn import Module
from diff_checkpoint import DiffCheckpoint
class SimpleModel(Module):
def __init__(self):
super(SimpleModel, self).__init__()
self.fc1 = torch.nn.Linear(10, 10)
self.bn1 = torch.nn.BatchNorm1d(10)
self.fc2 = torch.nn.Linear(10, 1)
def forward(self, x):
x = torch.relu(self.fc1(x))
x = self.bn1(x)
x = self.fc2(x)
return x
model = SimpleModel()
# Create a DiffCheckpoint from the base model
diff_checkpoint = DiffCheckpoint.from_base_model(model)
# Train
# ...
# Save the differential checkpoint
diff_checkpoint.save(model, 'diff_checkpoint.pth')
Metadata
Release files for pytorch-diff-checkpoint 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytorch_diff_checkpoint-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for pytorch_diff_checkpoint-1.2.0-py3-none-any.whl |
Release files / pytorch_diff_checkpoint-1.2.0-py3-none-any.whl
| Download URL | pytorch_diff_checkpoint-1.2.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ff30c68c3ca62c225014ab30b0b082619c31b75336522e70ccc1353978aa10f
|
|
BLAKE2b-256 checksum How to use checksums |
d80b0a7101fe218dafa0242955acbd4c4ca57c9285073050231841e5e400b17a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.10.7 Linux/6.5.0-35-generic
|
Security for pytorch-diff-checkpoint 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.