From 467d4aa3ea6b4177e34c4f4f773443322de78e47 Mon Sep 17 00:00:00 2001 From: Arpit Rawat Date: Fri, 6 Feb 2026 22:49:48 +0530 Subject: [PATCH 1/3] refactor Checkpoint state_dict to handled by Serializable --- ignite/handlers/checkpoint.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ignite/handlers/checkpoint.py b/ignite/handlers/checkpoint.py index dd20a8f69c55..c2acb04def5a 100644 --- a/ignite/handlers/checkpoint.py +++ b/ignite/handlers/checkpoint.py @@ -768,8 +768,8 @@ def state_dict(self) -> OrderedDict: """Method returns state dict with saved items: list of ``(priority, filename)`` pairs. Can be used to save internal state of the class. """ - # TODO: this method should use _state_dict_all_req_keys - return OrderedDict([("_saved", [(p, f) for p, f in self._saved])]) + keys = self._state_dict_all_req_keys + return OrderedDict([(k, [(p, f) for p, f in getattr(self, k)]) for k in keys]) def load_state_dict(self, state_dict: Mapping) -> None: """Method replaces internal state of the class with provided state dict data. @@ -777,8 +777,8 @@ def load_state_dict(self, state_dict: Mapping) -> None: Args: state_dict: a dict with "saved" key and list of ``(priority, filename)`` pairs as values. """ - super().load_state_dict(state_dict) - self._saved = [Checkpoint.Item(p, f) for p, f in state_dict["_saved"]] + key = self._state_dict_all_req_keys[0] + self._saved = [Checkpoint.Item(p, f) for p, f in state_dict[key]] @staticmethod def get_default_score_fn(metric_name: str, score_sign: float = 1.0) -> Callable: From c7c00e9628924b1c8eab44d1aab1d8255b920be0 Mon Sep 17 00:00:00 2001 From: Arpit Rawat Date: Fri, 6 Feb 2026 22:58:09 +0530 Subject: [PATCH 2/3] revert load_state_dict --- ignite/handlers/checkpoint.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ignite/handlers/checkpoint.py b/ignite/handlers/checkpoint.py index c2acb04def5a..947b0251e4b8 100644 --- a/ignite/handlers/checkpoint.py +++ b/ignite/handlers/checkpoint.py @@ -777,6 +777,7 @@ def load_state_dict(self, state_dict: Mapping) -> None: Args: state_dict: a dict with "saved" key and list of ``(priority, filename)`` pairs as values. """ + super().load_state_dict(state_dict) key = self._state_dict_all_req_keys[0] self._saved = [Checkpoint.Item(p, f) for p, f in state_dict[key]] From 1af10c592eb81eb9468456bb873c59ffba066e20 Mon Sep 17 00:00:00 2001 From: Arpit Rawat Date: Sat, 7 Feb 2026 11:15:04 +0530 Subject: [PATCH 3/3] revert back to str based state_dict loading --- ignite/handlers/checkpoint.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ignite/handlers/checkpoint.py b/ignite/handlers/checkpoint.py index 947b0251e4b8..21d6d14e589d 100644 --- a/ignite/handlers/checkpoint.py +++ b/ignite/handlers/checkpoint.py @@ -778,8 +778,7 @@ def load_state_dict(self, state_dict: Mapping) -> None: state_dict: a dict with "saved" key and list of ``(priority, filename)`` pairs as values. """ super().load_state_dict(state_dict) - key = self._state_dict_all_req_keys[0] - self._saved = [Checkpoint.Item(p, f) for p, f in state_dict[key]] + self._saved = [Checkpoint.Item(p, f) for p, f in state_dict["_saved"]] @staticmethod def get_default_score_fn(metric_name: str, score_sign: float = 1.0) -> Callable: