feat: add pickle-free safetensors checkpoints - #26
Merged
opensource-SantanderAI merged 1 commit intoJul 23, 2026
Merged
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
opensource-SantanderAI
approved these changes
Jul 23, 2026
opensource-SantanderAI
merged commit Jul 23, 2026
29c8b22
into
SantanderAI:main
9 of 10 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.ptand.pthcheckpoints read-only throughtorch.load(..., weights_only=True)and addLinearAdapter.migrate_checkpoint()Type of change
feat- new featurefix- bug fixdocs- documentation onlytest- adding or updating testsrefactor- code refactoring (no feature/fix)ci- CI/CD changeschore- maintenanceLinked issues
Closes #20
Checklist
pytest tests/ -v --cov=linear_adapter_trainer)ruff check . && black --check . && mypy linear_adapter_trainer)Notes for reviewers
New writes now require the
.safetensorsextension. Existing.ptand.pthcheckpoints remain readable through the restricted legacy path and can be
migrated explicitly. Parser selection is extension-based, so a corrupt or
renamed safetensors artifact is never passed to
torch.load.The implementation uses safetensors' native string metadata for a single-file
artifact. The metadata contains format version
1and canonical JSON for thefive
AdapterConfigfields. Unknown, missing, mistyped, or invalid fields arerejected before tensor loading. Writes use a temporary file in the destination
directory,
fsync, andos.replace.Atomic writes use
tempfile.mkstemp, so new checkpoints are owner-only(
0600) on POSIX. The Windows durability path was reviewed but not executedbecause upstream CI is Linux-only. The updated notebook cell's output was
cleared rather than regenerated without live API access.
Linux verification used Python 3.12.13, CPU-only Torch 2.13.0, and safetensors
0.8.0. Results: 97 tests passed, total coverage is 80%, the checkpoint module
has 100% coverage, and Ruff, Black, Mypy, build, pip-audit, dependency-license,
SPDX, internal-pattern, changed-code Bandit, secret, and private-pattern checks
passed.