Repository navigation
[Checkpointer] Refresh ModelWrapper hook-produced tensors in place - #3675
Merged
Merged
Conversation
[ghstack-poisoned]
tianyu-l
approved these changes
Jun 15, 2026
[ghstack-poisoned]
fegin
added a commit
that referenced
this pull request
Jun 15, 2026
…Forward (#3638) Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * __->__ #3638 * #3675 FusedSwiGLU now checkpoints in the stock FeedForward layout (w1.weight/w3.weight) via register_state_dict_post_hook / register_load_state_dict_pre_hook, so its checkpoints interoperate with the non-fused module and the HF adapter (a native w13 key is still accepted). This is possible now that we removed the usage of get_model_state_dict/set_model_state_dict. Resolves #3569. Adds CPU unit tests for both load directions and native-w13 back-compat.
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.
Stack from ghstack (oldest at bottom):
TLDR
We need cached state_dict for the pinned memory copy. But state_dict hooks can invalidate the cache. This PR fixes by using
copy_for those tensors that storages change.Summary
ModelWrapper caches the flattened model state dict so async DCP staging reuses its pinned host buffers (the stager keys them by source storage). A module state_dict hook that emits a freshly allocated tensor (e.g. splitting a fused parameter into the stock layout) is disconnected from the parameter, so once training updates the parameter the cached copy goes stale and the checkpoint saves init-time values.
state_dict() now refreshes only those hook-produced tensors in place, so their storage stays stable (pinned buffers stay reusable) while values stay current. Parameter-backed tensors share storage with the live parameter and need no copy; models without such hooks return the cache unchanged.
Adds CPU unit tests for stable storage plus in-place refresh.