Repository navigation
[checkpoint]: remove embedded pickle from async optimizer checkpoints - #6479
Merged
yuxuan-lou merged 2 commits intoOct 25, 2026
Merged
Conversation
Replace file-selected pickle decoding with a versioned typed JSON schema and native tensor references. Reject legacy embedded objects in training loaders and provide an explicit migration tool for trusted checkpoints. Use v2 parameter groups across checkpoint plugins, validate optimizer index paths without restricting model blob caches, and preserve pinned buffers across repeated saves. Add format, migration and plugin regressions and collect the CPU security tests in both CI entry points.
Require torch >= 2.10 before loading legacy optimizer files, parameter groups or state shards with weights_only=True. Earlier versions have known weights-only vulnerabilities. Keep this policy local to optimizer readers; v2 safetensors and the project dependency range are unchanged. Cover rejection before deserialization, patched-version dispatch and v2 loading without the legacy version gate. Document the compatibility boundary and trusted migration path.
yuxuan-lou
approved these changes
Oct 25, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📌 Checklist before creating the PR
[doc/gemini/tensor/...]: A concise descriptionpip install pre-commit && pre-commit install🚨 Issue number
Fixes #6471.
Related PR: #6478, which retains the existing format with a restricted unpickler. This PR proposes a versioned format without embedded pickle, with explicit migration for trusted legacy files.
📝 What does this PR do?
Background
Async optimizer checkpoints store non-tensor values, including
param_groups, as pickle bytes in uint8 tensors.load_flat()uses the checkpoint's ownnon_tensor_keysmetadata to select which tensors to unpickle. A valid safetensors container can therefore reach unrestricted object decoding throughBooster.load_optimizer(), before optimizer-state validation.Changes
colossalai checkpoint migrate-optimizer --trust-legacy-pickle SOURCE DESTINATIONfor trusted old files or directories, preserving inputs and refusing existing destinations.User and compatibility impact
Test environment
Python 3.10.12, torch 2.11.0+cu128, one NVIDIA H20 for single-GPU tests. Tested tree:
a7434bd5, based on main0ac6a922.Test commands and results
CPU targets, run separately in each environment:
CUDA_VISIBLE_DEVICES="" python -m pytest -p no:cacheprovider -ra \ tests/test_checkpoint_io/test_optimizer_safetensors_v2.py \ tests/test_checkpoint_io/test_optimizer_safetensors_plugins.py bash .github/scripts/ci/run_colossalai_batch.sh cpu bash .github/scripts/ci/run_cpu_unit_tests.shThe scopes overlap. These are local results, not GitHub Actions results. Version-gate controls produced nine expected failures on the previous implementation in each environment and pass after the gate.
Known issues / unexecuted tests
Risk and rollback
The main risk is checkpoint compatibility. Migration preserves source files, and reverting code does not convert v2 files back to the old format. Keep original checkpoints and the previous validated environment when planning rollback. Migration is not an authenticity check for untrusted input.
Documentation and release impact
Update the English and Chinese checkpoint documentation with the v2 format, legacy loading policy and migration command. No dependency, image or release-version change.
💥 Checklist before requesting a review
⭐️ Do you enjoy contributing to Colossal-AI?
Tell us more if you don't enjoy contributing to Colossal-AI.