Skip to content

Commit fceef79

Browse files
author
Your Name
committed
fix_hydra
1 parent 3c86193 commit fceef79

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pytorch_lightning/plugins/training_type/tpu_spawn.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
from pytorch_lightning.plugins.training_type.ddp_spawn import DDPSpawnPlugin
2424
from pytorch_lightning.plugins.training_type.utils import on_colab_kaggle
2525
from pytorch_lightning.trainer.states import TrainerState
26-
from pytorch_lightning.utilities import _TPU_AVAILABLE, rank_zero_warn
26+
from pytorch_lightning.utilities import _TPU_AVAILABLE, rank_zero_warn, _OMEGACONF_AVAILABLE
2727
from pytorch_lightning.utilities.distributed import rank_zero_only, ReduceOp
2828
from pytorch_lightning.utilities.exceptions import MisconfigurationException
2929
from pytorch_lightning.utilities.seed import seed_everything
30+
from pytorch_lightning.utilities.apply_func import apply_to_collection
3031

3132
if _TPU_AVAILABLE:
3233
import torch_xla.core.xla_model as xm
@@ -37,6 +38,10 @@
3738
else:
3839
xm, xla_pl, xmp, ParallelLoader, rendezvous = [None] * 5
3940

41+
if _OMEGACONF_AVAILABLE:
42+
from omegaconf import OmegaConf
43+
from omegaconf import DictConfig, ListConfig
44+
4045

4146
class TPUSpawnPlugin(DDPSpawnPlugin):
4247

@@ -304,4 +309,6 @@ def save_checkpoint(self, checkpoint: Dict[str, Any], filepath: str) -> None:
304309
filepath: write-target file's path
305310
"""
306311
# Todo: TypeError: 'mappingproxy' object does not support item assignment
312+
if _OMEGACONF_AVAILABLE:
313+
checkpoint = apply_to_collection(checkpoint, (DictConfig, ListConfig), OmegaConf.to_container)
307314
self.save({k: v for k, v in checkpoint.items() if k != "callbacks"}, filepath)

0 commit comments

Comments
 (0)