Skip to content

Do not include non_persistent buffer in state_dict#1826

Merged
emailweixu merged 1 commit intopytorchfrom
PR_fix_state_dict
Jan 23, 2026
Merged

Do not include non_persistent buffer in state_dict#1826
emailweixu merged 1 commit intopytorchfrom
PR_fix_state_dict

Conversation

@emailweixu
Copy link
Contributor

@emailweixu emailweixu commented Jan 21, 2026

Per the original implementation of state_dict for pytorch Module, non persistent buffers are not included in state_dict.

Background: state_dict usually include both parameters and buffers. However, if a buffer is registered with persistent=False, it will not be included in state_dict (the default value for persistent is True).

@emailweixu emailweixu requested a review from le-horizon January 21, 2026 22:35
Copy link
Contributor

@le-horizon le-horizon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG.

Could you add a bit more explanation in the PR desc, which case this fix is for? E.g. two modules sharing parameter? or the other case?

Thanks,
Le

@emailweixu
Copy link
Contributor Author

LG.

Could you add a bit more explanation in the PR desc, which case this fix is for? E.g. two modules sharing parameter? or the other case?

Thanks, Le

Updated

@emailweixu emailweixu merged commit 6276d26 into pytorch Jan 23, 2026
2 checks passed
@emailweixu emailweixu deleted the PR_fix_state_dict branch January 23, 2026 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants