What this thread does
Do first: compare the artifact's training-environment manifest with serving dependencies before calling joblib.load, then promote InconsistentVersionWarning to an exception.
Short answer
As of November 2026, scikit-learn 1.9.1 is the reference release, not permission to load an older fitted artifact. Persist preprocessing and estimator together. Recreate the same dependency versions or retrain; cross-version loading is unsupported (persistence guide).
Choose / don't choose
- Trusted, large-array artifact: choose joblib; don't load a pickle-based artifact from an untrusted producer (load warning).
- Several serving workers: choose an uncompressed artifact and read-only memory mapping; don't compress and expect shared mapped arrays.
- Reviewable type trust: choose
skops.io.loadwhen supported object types can be reviewed explicitly; don't blindly trust every type reported by the file. (skops guide).
Not for: training split leakage; see scikit-learn-train-validate-pipeline-without-preprocessing-leaks.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
joblib.dump(..., compress=3) | Documented size/speed compromise; default 0 means no compression; higher compression costs read/write time | Current stable joblib dump | dump |
joblib.dump(..., compress=0) | Select for mmap sharing; avoid a compression-triggering filename suffix | Current stable joblib dump | dump |
joblib.load(..., mmap_mode="r") | Memory mapping for eligible uncompressed arrays; default None; compressed arrays cannot be mapped | Current stable joblib load | load |
ensure_native_byte_order | Default "auto": true without mapping, false with it; explicit true conflicts with non-null mmap mode | Current stable joblib load | load |
skops.io.load(..., trusted=...) | Explicit reviewed list from get_untrusted_types(file=...); never automatically approve the whole list | Current stable skops | skops |
Order of operations
1. Save the fitted pipeline and an immutable environment manifest: Python, scikit-learn, NumPy, SciPy, joblib and every custom transformer/third-party estimator package at training time. Keep training recipe, data reference and validation score alongside it (persistence). 2. Select compress=3 for smaller transport or compress=0 plus mmap_mode="r" for shared arrays. Measure artifact bytes, cold-load latency and worker memory separately; no one choice optimizes all three (dump, load). 3. Before trusted loading, set warnings.simplefilter("error", InconsistentVersionWarning). Catch that warning as an exception, capture original_sklearn_version, refuse readiness and restore the matching environment or retrain. Reject other load exceptions too (persistence, warning API). 4. Compare representative prediction outputs and input feature schema with the saved acceptance baseline before admitting traffic. Successful deserialization alone does not establish semantic compatibility. 5. For skops, inspect unknown types first, approve only intended types, then load. Converting an untrusted pickle with skops convert is unsafe because conversion itself loads the pickle (skops).
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
InconsistentVersionWarning | Estimator's saved version differs from runtime | Treat as startup failure and use matching dependencies or a newly trained artifact | warning API |
ValueError: node array from the pickle has an incompatible dtype | Version 1.3.0 has broken backward compatibility for loading older models with joblib | Reject artifact; restore training environment or retrain; don't patch private serialized fields | BenjVig, July 7, 2023 |
That report supplies an actual incompatible tree-artifact load, rather than a guarantee that all estimators fail in the same way.
Missing
- No fitted pipeline, dependency manifest, array mutation requirement or latency budget is specified.
- Compression level 3 is joblib guidance; optimal compression and mmap benefit require measurements for the actual pipeline.
Started from a post by @BenjVig, packaged by the editor. Original post