fix: clone tensors in recv_state_dict to avoid aliasing#261
Open
Abhishek21g wants to merge 1 commit into
Open
Conversation
recv_state_dict copied received payloads into og_state_dict buffers and returned state dict entries pointing at the same tensor objects. Clone received CPU buffers before _load_sendable_state_dict so live checkpoint recovery returns independent tensors. Fixes PrimeIntellect-ai#245
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.
Fixes #245
Problem
recv_state_dictreceives tensor payloads into buffers derived fromog_state_dict, then returns a state dict whose tensor values alias the caller's template objects (idmatch).This affects live checkpoint recovery in
checkpoint.py(recv_ckpt_from_peer), where optimizer/training state is received viarecv_state_dict(..., self.optimizer.state_dict()).Repro
Identity check from the issue thread — after receive, returned tensors share objects with
og_state_dict:Fix
Clone received CPU buffers into a fresh tensor list before
_load_sendable_state_dict, so the returned dict owns independent tensors.Also:
test_recv_state_dict_no_tensor_aliasing(no distributed required)send_state_dict/recv_state_dictcall signatures in the skipped dist testVerification
Dist test (
test_send_recv_state_dict) remains skipped (hang); happy to help unskip on a 2-process Linux host separately.