Skip to content

Commit 4f22163

Browse files
committed
Merge branch 'master' into bump/python_3.9+
2 parents ce62f96 + 20d19d2 commit 4f22163

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

.github/checkgroup.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,15 @@ subprojects:
8989
checks:
9090
- "lightning.Benchmarks"
9191

92-
- id: "pytorch-lightning: TPU workflow"
93-
paths:
94-
# tpu CI availability is very limited, so we only require tpu tests
95-
# to pass when their configurations are modified
96-
- ".github/workflows/tpu-tests.yml"
97-
- "tests/tests_pytorch/run_tpu_tests.sh"
98-
checks:
99-
- "test-on-tpus (pytorch, pjrt, v4-8)"
92+
# Temporarily disabled
93+
# - id: "pytorch-lightning: TPU workflow"
94+
# paths:
95+
# # tpu CI availability is very limited, so we only require tpu tests
96+
# # to pass when their configurations are modified
97+
# - ".github/workflows/tpu-tests.yml"
98+
# - "tests/tests_pytorch/run_tpu_tests.sh"
99+
# checks:
100+
# - "test-on-tpus (pytorch, pjrt, v4-8)"
100101

101102
- id: "fabric: Docs"
102103
paths:
File renamed without changes.

src/lightning/fabric/accelerators/cpu.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from typing import Union
14+
from typing import List, Union
1515

1616
import torch
1717
from typing_extensions import override
@@ -39,13 +39,13 @@ def teardown(self) -> None:
3939

4040
@staticmethod
4141
@override
42-
def parse_devices(devices: Union[int, str, list[int]]) -> int:
42+
def parse_devices(devices: Union[int, str]) -> int:
4343
"""Accelerator device parsing logic."""
4444
return _parse_cpu_cores(devices)
4545

4646
@staticmethod
4747
@override
48-
def get_parallel_devices(devices: Union[int, str, list[int]]) -> list[torch.device]:
48+
def get_parallel_devices(devices: Union[int, str]) -> List[torch.device]:
4949
"""Gets parallel devices for the Accelerator."""
5050
devices = _parse_cpu_cores(devices)
5151
return [torch.device("cpu")] * devices
@@ -72,12 +72,12 @@ def register_accelerators(cls, accelerator_registry: _AcceleratorRegistry) -> No
7272
)
7373

7474

75-
def _parse_cpu_cores(cpu_cores: Union[int, str, list[int]]) -> int:
75+
def _parse_cpu_cores(cpu_cores: Union[int, str]) -> int:
7676
"""Parses the cpu_cores given in the format as accepted by the ``devices`` argument in the
7777
:class:`~lightning.pytorch.trainer.trainer.Trainer`.
7878
7979
Args:
80-
cpu_cores: An int > 0.
80+
cpu_cores: An int > 0 or a string that can be converted to an int > 0.
8181
8282
Returns:
8383
An int representing the number of processes

src/lightning/pytorch/accelerators/cpu.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from typing import Any, Union
14+
from typing import Any, Dict, List, Union
1515

1616
import torch
1717
from lightning_utilities.core.imports import RequirementCache
@@ -38,7 +38,7 @@ def setup_device(self, device: torch.device) -> None:
3838
raise MisconfigurationException(f"Device should be CPU, got {device} instead.")
3939

4040
@override
41-
def get_device_stats(self, device: _DEVICE) -> dict[str, Any]:
41+
def get_device_stats(self, device: _DEVICE) -> Dict[str, Any]:
4242
"""Get CPU stats from ``psutil`` package."""
4343
return get_cpu_stats()
4444

@@ -48,13 +48,13 @@ def teardown(self) -> None:
4848

4949
@staticmethod
5050
@override
51-
def parse_devices(devices: Union[int, str, list[int]]) -> int:
51+
def parse_devices(devices: Union[int, str]) -> int:
5252
"""Accelerator device parsing logic."""
5353
return _parse_cpu_cores(devices)
5454

5555
@staticmethod
5656
@override
57-
def get_parallel_devices(devices: Union[int, str, list[int]]) -> list[torch.device]:
57+
def get_parallel_devices(devices: Union[int, str]) -> List[torch.device]:
5858
"""Gets parallel devices for the Accelerator."""
5959
devices = _parse_cpu_cores(devices)
6060
return [torch.device("cpu")] * devices
@@ -89,7 +89,7 @@ def register_accelerators(cls, accelerator_registry: _AcceleratorRegistry) -> No
8989
_PSUTIL_AVAILABLE = RequirementCache("psutil")
9090

9191

92-
def get_cpu_stats() -> dict[str, float]:
92+
def get_cpu_stats() -> Dict[str, float]:
9393
if not _PSUTIL_AVAILABLE:
9494
raise ModuleNotFoundError(
9595
f"Fetching CPU device stats requires `psutil` to be installed. {str(_PSUTIL_AVAILABLE)}"

src/lightning/pytorch/trainer/trainer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,9 +1362,10 @@ def save_checkpoint(
13621362
"Saving a checkpoint is only possible if a model is attached to the Trainer. Did you call"
13631363
" `Trainer.save_checkpoint()` before calling `Trainer.{fit,validate,test,predict}`?"
13641364
)
1365-
checkpoint = self._checkpoint_connector.dump_checkpoint(weights_only)
1366-
self.strategy.save_checkpoint(checkpoint, filepath, storage_options=storage_options)
1367-
self.strategy.barrier("Trainer.save_checkpoint")
1365+
with self.profiler.profile("save_checkpoint"):
1366+
checkpoint = self._checkpoint_connector.dump_checkpoint(weights_only)
1367+
self.strategy.save_checkpoint(checkpoint, filepath, storage_options=storage_options)
1368+
self.strategy.barrier("Trainer.save_checkpoint")
13681369

13691370
"""
13701371
State properties

0 commit comments

Comments
 (0)