Skip to content

Commit f215626

Browse files
authored
Merge branch 'master' into patch-2
2 parents 31a1fce + c110f4f commit f215626

File tree

24 files changed

+762
-104
lines changed

24 files changed

+762
-104
lines changed

.github/checkgroup.yml

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ subprojects:
1919
- "!*.md"
2020
- "!**/*.md"
2121
checks:
22-
- "pl-cpu (macOS-13, lightning, 3.9, 2.1, oldest)"
22+
- "pl-cpu (macOS-14, lightning, 3.9, 2.1, oldest)"
2323
- "pl-cpu (macOS-14, lightning, 3.10, 2.1)"
2424
- "pl-cpu (macOS-14, lightning, 3.11, 2.2.2)"
2525
- "pl-cpu (macOS-14, lightning, 3.11, 2.3)"
@@ -40,9 +40,9 @@ subprojects:
4040
- "pl-cpu (macOS-14, pytorch, 3.9, 2.1)"
4141
- "pl-cpu (ubuntu-20.04, pytorch, 3.9, 2.1)"
4242
- "pl-cpu (windows-2022, pytorch, 3.9, 2.1)"
43-
- "pl-cpu (macOS-13, pytorch, 3.10, 2.1)"
44-
- "pl-cpu (ubuntu-22.04, pytorch, 3.10, 2.1)"
45-
- "pl-cpu (windows-2022, pytorch, 3.10, 2.1)"
43+
- "pl-cpu (macOS-14, pytorch, 3.12, 2.5.1)"
44+
- "pl-cpu (ubuntu-22.04, pytorch, 3.12, 2.5.1)"
45+
- "pl-cpu (windows-2022, pytorch, 3.12, 2.5.1)"
4646

4747
- id: "pytorch_lightning: Azure GPU"
4848
paths:
@@ -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:
@@ -171,7 +172,7 @@ subprojects:
171172
- "!*.md"
172173
- "!**/*.md"
173174
checks:
174-
- "fabric-cpu (macOS-13, lightning, 3.9, 2.1, oldest)"
175+
- "fabric-cpu (macOS-14, lightning, 3.9, 2.1, oldest)"
175176
- "fabric-cpu (macOS-14, lightning, 3.10, 2.1)"
176177
- "fabric-cpu (macOS-14, lightning, 3.11, 2.2.2)"
177178
- "fabric-cpu (macOS-14, lightning, 3.11, 2.3)"
@@ -192,9 +193,9 @@ subprojects:
192193
- "fabric-cpu (macOS-14, fabric, 3.9, 2.1)"
193194
- "fabric-cpu (ubuntu-20.04, fabric, 3.9, 2.1)"
194195
- "fabric-cpu (windows-2022, fabric, 3.9, 2.1)"
195-
- "fabric-cpu (macOS-13, fabric, 3.10, 2.1)"
196-
- "fabric-cpu (ubuntu-22.04, fabric, 3.10, 2.1)"
197-
- "fabric-cpu (windows-2022, fabric, 3.10, 2.1)"
196+
- "fabric-cpu (macOS-14, fabric, 3.12, 2.5.1)"
197+
- "fabric-cpu (ubuntu-22.04, fabric, 3.12, 2.5.1)"
198+
- "fabric-cpu (windows-2022, fabric, 3.12, 2.5.1)"
198199

199200
- id: "lightning_fabric: Azure GPU"
200201
paths:
@@ -266,14 +267,14 @@ subprojects:
266267
- "install-pkg (ubuntu-22.04, lightning, 3.11)"
267268
- "install-pkg (ubuntu-22.04, notset, 3.9)"
268269
- "install-pkg (ubuntu-22.04, notset, 3.11)"
269-
- "install-pkg (macOS-13, fabric, 3.9)"
270-
- "install-pkg (macOS-13, fabric, 3.11)"
271-
- "install-pkg (macOS-13, pytorch, 3.9)"
272-
- "install-pkg (macOS-13, pytorch, 3.11)"
273-
- "install-pkg (macOS-13, lightning, 3.9)"
274-
- "install-pkg (macOS-13, lightning, 3.11)"
275-
- "install-pkg (macOS-13, notset, 3.9)"
276-
- "install-pkg (macOS-13, notset, 3.11)"
270+
- "install-pkg (macOS-14, fabric, 3.9)"
271+
- "install-pkg (macOS-14, fabric, 3.11)"
272+
- "install-pkg (macOS-14, pytorch, 3.9)"
273+
- "install-pkg (macOS-14, pytorch, 3.11)"
274+
- "install-pkg (macOS-14, lightning, 3.9)"
275+
- "install-pkg (macOS-14, lightning, 3.11)"
276+
- "install-pkg (macOS-14, notset, 3.9)"
277+
- "install-pkg (macOS-14, notset, 3.11)"
277278
- "install-pkg (windows-2022, fabric, 3.9)"
278279
- "install-pkg (windows-2022, fabric, 3.11)"
279280
- "install-pkg (windows-2022, pytorch, 3.9)"

.github/workflows/ci-pkg-install.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
strategy:
4343
fail-fast: false
4444
matrix:
45-
os: ["ubuntu-22.04", "macOS-13", "windows-2022"]
45+
os: ["ubuntu-22.04", "macOS-14", "windows-2022"]
4646
pkg-name: ["fabric", "pytorch", "lightning", "notset"]
4747
python-version: ["3.9", "3.11"]
4848
steps:

.github/workflows/ci-tests-fabric.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ jobs:
5656
- { os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.12", pytorch-version: "2.5.1" }
5757
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.12", pytorch-version: "2.5.1" }
5858
# only run PyTorch latest with Python latest, use Fabric scope to limit dependency issues
59-
- { os: "macOS-13", pkg-name: "fabric", python-version: "3.10", pytorch-version: "2.1" }
60-
- { os: "ubuntu-22.04", pkg-name: "fabric", python-version: "3.10", pytorch-version: "2.1" }
61-
- { os: "windows-2022", pkg-name: "fabric", python-version: "3.10", pytorch-version: "2.1" }
59+
- { os: "macOS-14", pkg-name: "fabric", python-version: "3.12", pytorch-version: "2.5.1" }
60+
- { os: "ubuntu-22.04", pkg-name: "fabric", python-version: "3.12", pytorch-version: "2.5.1" }
61+
- { os: "windows-2022", pkg-name: "fabric", python-version: "3.12", pytorch-version: "2.5.1" }
6262
# "oldest" versions tests, only on minimum Python
63-
- { os: "macOS-13", pkg-name: "lightning", python-version: "3.9", pytorch-version: "2.1", requires: "oldest" }
63+
- { os: "macOS-14", pkg-name: "lightning", python-version: "3.9", pytorch-version: "2.1", requires: "oldest" }
6464
- {
6565
os: "ubuntu-20.04",
6666
pkg-name: "lightning",
@@ -101,7 +101,10 @@ jobs:
101101

102102
- name: Set min. dependencies
103103
if: ${{ matrix.requires == 'oldest' }}
104-
run: python .actions/assistant.py replace_oldest_ver
104+
run: |
105+
python .actions/assistant.py replace_oldest_ver
106+
pip install "cython<3.0" wheel
107+
pip install "pyyaml==5.4" --no-build-isolation
105108
106109
- name: Adjust PyTorch versions in requirements files
107110
if: ${{ matrix.requires != 'oldest' }}

.github/workflows/ci-tests-pytorch.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ jobs:
6060
- { os: "ubuntu-22.04", pkg-name: "lightning", python-version: "3.12", pytorch-version: "2.5.1" }
6161
- { os: "windows-2022", pkg-name: "lightning", python-version: "3.12", pytorch-version: "2.5.1" }
6262
# only run PyTorch latest with Python latest, use PyTorch scope to limit dependency issues
63-
- { os: "macOS-13", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "2.1" }
64-
- { os: "ubuntu-22.04", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "2.1" }
65-
- { os: "windows-2022", pkg-name: "pytorch", python-version: "3.10", pytorch-version: "2.1" }
63+
- { os: "macOS-14", pkg-name: "pytorch", python-version: "3.12", pytorch-version: "2.5.1" }
64+
- { os: "ubuntu-22.04", pkg-name: "pytorch", python-version: "3.12", pytorch-version: "2.5.1" }
65+
- { os: "windows-2022", pkg-name: "pytorch", python-version: "3.12", pytorch-version: "2.5.1" }
6666
# "oldest" versions tests, only on minimum Python
67-
- { os: "macOS-13", pkg-name: "lightning", python-version: "3.9", pytorch-version: "2.1", requires: "oldest" }
67+
- { os: "macOS-14", pkg-name: "lightning", python-version: "3.9", pytorch-version: "2.1", requires: "oldest" }
6868
- {
6969
os: "ubuntu-20.04",
7070
pkg-name: "lightning",
@@ -106,7 +106,10 @@ jobs:
106106

107107
- name: Set min. dependencies
108108
if: ${{ matrix.requires == 'oldest' }}
109-
run: python .actions/assistant.py replace_oldest_ver
109+
run: |
110+
python .actions/assistant.py replace_oldest_ver
111+
pip install "cython<3.0" wheel
112+
pip install "pyyaml==5.4" --no-build-isolation
110113
111114
- name: Adjust PyTorch versions in requirements files
112115
if: ${{ matrix.requires != 'oldest' }}
File renamed without changes.

examples/fabric/build_your_own_trainer/run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def training_step(self, batch, batch_idx: int):
4141

4242
def configure_optimizers(self):
4343
optim = torch.optim.Adam(self.parameters(), lr=1e-4)
44-
return optim, {
44+
return {
45+
"optimizer": optim,
4546
"scheduler": torch.optim.lr_scheduler.ReduceLROnPlateau(optim, mode="max", verbose=True),
4647
"monitor": "val_accuracy",
4748
"interval": "epoch",

src/lightning/fabric/accelerators/cpu.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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/fabric/utilities/throughput.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,14 @@ def measure_flops(
347347
torch.int8: 389.9e12,
348348
"int4": 779.8e12,
349349
},
350+
"rtx 4080 super": {
351+
torch.float32: 52.2e12,
352+
"tfloat32": 52.2e12,
353+
torch.bfloat16: 52.2e12,
354+
torch.float16: 52.2e12,
355+
torch.int8: 417.6e12,
356+
"int4": 835.2e12,
357+
},
350358
"l4": {
351359
torch.float32: 30.3e12,
352360
"tfloat32": 60e12,

src/lightning/pytorch/accelerators/cpu.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/lightning/pytorch/demos/transformer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def forward(self, x: Tensor) -> Tensor:
8888
# TODO: Could make this a `nn.Parameter` with `requires_grad=False`
8989
self.pe = self._init_pos_encoding(device=x.device)
9090

91-
x = x + self.pe[: x.size(0), :]
91+
x = x + self.pe[:, x.size(1)]
9292
return self.dropout(x)
9393

9494
def _init_pos_encoding(self, device: torch.device) -> Tensor:
@@ -97,7 +97,7 @@ def _init_pos_encoding(self, device: torch.device) -> Tensor:
9797
div_term = torch.exp(torch.arange(0, self.dim, 2, device=device).float() * (-math.log(10000.0) / self.dim))
9898
pe[:, 0::2] = torch.sin(position * div_term)
9999
pe[:, 1::2] = torch.cos(position * div_term)
100-
pe = pe.unsqueeze(0).transpose(0, 1)
100+
pe = pe.unsqueeze(0)
101101
return pe
102102

103103

0 commit comments

Comments
 (0)