Why a skops File Changes Every Time You Save the Same Model
Save the same scikit-learn model twice with skops and you get two files with different SHA-256 hashes, even though nothing about the model changed. That matters to any tool that decides whether something changed by hashing files. This guide opens the two files, shows the two reasons they differ, and compares the models the reliable way: by what they predict. It uses skops 0.16.0 with scikit-learn 1.9.1.
The Example
A tiny LinearRegression learns y = 2x from three points. A script saves it twice, to first.skops and second.skops, and prints the start of each file's SHA-256 hash.
Prerequisites
- scikit-learn and skops in your project, for example with
uv add scikit-learn skops. This guide uses skops 0.16.0 and scikit-learn 1.9.1 on Python 3.15.2.
Step 1: Save the Same Model Twice
import hashlib
from pathlib import Path
import skops.io as sio
from sklearn.linear_model import LinearRegression
model = LinearRegression().fit([[1], [2], [3]], [2, 4, 6])
for name in ("first.skops", "second.skops"):
sio.dump(model, name)
digest = hashlib.sha256(Path(name).read_bytes()).hexdigest()
print(name, digest[:16])

uv run python save_twice.py
first.skops 7f41d4cf14e1a00b
second.skops 286595b6004fac75

The same model, saved a moment apart, gave two different hashes.
Step 2: Look Inside the Two Files
A skops file is a zip file. This script lists each one's entries and the date and time stored with each:
import zipfile
for name in ("first.skops", "second.skops"):
with zipfile.ZipFile(name) as archive:
print(name)
for entry in archive.infolist():
print(" ", entry.filename, entry.date_time)
first.skops
4557892240.npy (2026, 11, 30, 17, 59, 16)
4308029008.npy (2026, 11, 30, 17, 59, 16)
4557891856.npy (2026, 11, 30, 17, 59, 16)
4556894736.npy (2026, 11, 30, 17, 59, 16)
schema.json (2026, 11, 30, 17, 59, 16)
second.skops
4557892240.npy (2026, 11, 30, 17, 59, 16)
4308029008.npy (2026, 11, 30, 17, 59, 16)
4557891856.npy (2026, 11, 30, 17, 59, 16)
4556894736.npy (2026, 11, 30, 17, 59, 16)
schema.json (2026, 11, 30, 17, 59, 16)

Each file holds the model's arrays as .npy entries, plus a schema.json that describes the model. The arrays' names are long numbers, and every entry carries the time it was saved. Within this one run, the names and times match. So something else differs.
Step 3: Find What Differs
This script compares each entry's bytes between the two files:
import zipfile
with zipfile.ZipFile("first.skops") as first, zipfile.ZipFile("second.skops") as second:
for name in first.namelist():
same = first.read(name) == second.read(name)
print(f"{name:20} {'same bytes' if same else 'different'}")
4557892240.npy same bytes
4308029008.npy same bytes
4557891856.npy same bytes
4556894736.npy same bytes
schema.json different
The model's numbers are identical. Only schema.json differs, and inside it, skops records __id__ values, numbers that it takes from Python's id() of the objects it saves. Listing a few of them from each file:
first.skops __id__ values: [4307166464, 4308029008, 4324069600] ...
second.skops __id__ values: [4308029008, 4324069600, 4324069600] ...
Python's id() reference explains why they move: an object's id is "unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same id() value." Objects created while saving get new ids each time.
Step 4: Save Again, in a New Run
Running save_twice.py a second time, a few seconds later, changed both the hashes and the entries:
first.skops fda41295c9da823b
second.skops 27516b5ab32ef906
first.skops
4562430608.npy (2026, 11, 30, 17, 59, 34)
4312387152.npy (2026, 11, 30, 17, 59, 34)
Each array's name is also an id() number, so the names changed in the new run, and the time moved on to 17:59:34. Python's zipfile reference explains the time: when an entry is written by name, "the date and time is set to the current date and time."
So a skops file changes on every save for two reasons: ids that differ between saves, and the time of saving.
Compare the Models, Not the Files
To check that two saved models are the same model, load them and compare what they hold and what they predict:
import skops.io as sio
first = sio.load("first.skops")
second = sio.load("second.skops")
print("first: ", first.coef_, first.intercept_)
print("second:", second.coef_, second.intercept_)
print("Same predictions:", (first.predict([[10]]) == second.predict([[10]])).all())
first: [2.] 1.3322676295501878e-15
second: [2.] 1.3322676295501878e-15
Same predictions: True

Both files hold the same model. sio.load loaded them without a list of trusted types, because LinearRegression uses only types skops trusts by default.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Deciding a model changed because its file's hash changed | Every save gives a new hash, so the model always looks changed | Compare predictions, or the model's numbers |
| Expecting the same file from the same code on two computers | The ids and the save time differ there too | Compare the models' outputs |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| A tool that tracks files by hash reports the model as changed after a retrain with identical results | skops writes new ids and a new time on every save | Judge the model by its metrics and predictions, not by the file's hash |
FAQ
Is the model inside really identical?
Here, yes: the four .npy arrays were byte-for-byte the same, and both models gave the same coefficient and the same prediction.
Does this make skops less safe?
No. The ids are labels inside the file; loading still checks every type against the trusted list, which is what skops is for.
Conclusion
Two saves of the same LinearRegression gave two different SHA-256 hashes, because skops's schema.json records Python object ids and every zip entry carries the save time. The arrays inside were identical, and both models predicted the same. When you need to know whether a model changed, compare the models, not the files.
Additional Resources
- Secure persistence with skops —
dump,loadand trusted types. - zipfile.ZipFile.writestr — where the entry times come from.
