Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements/app/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fsspec>=2022.5.0, <=2022.7.1
croniter>=1.3.0, <1.4.0 # strict; TODO: for now until we find something more robust.
traitlets>=5.3.0, <5.9.0
arrow>=1.2.0, <1.2.4
lightning-utilities>=0.6.0.post0, <0.7.0
lightning-utilities>=0.7.0, <0.8.0
beautifulsoup4>=4.8.0, <4.11.2
inquirer>=2.10.0, <=3.1.2
psutil<5.9.5
Expand Down
2 changes: 1 addition & 1 deletion requirements/fabric/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ torch>=1.11.0, <=2.0.0
fsspec[http]>2021.06.0, <2023.2.0
packaging>=17.1, <=23.0
typing-extensions>=4.0.0, <=4.4.0
lightning-utilities>=0.6.0.post0, <0.7.0
lightning-utilities>=0.7.0, <0.8.0
2 changes: 1 addition & 1 deletion requirements/pytorch/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ fsspec[http]>2021.06.0, <2023.2.0
torchmetrics>=0.7.0, <0.12.0 # needed for using fixed compare_version
packaging>=17.1, <=23.0
typing-extensions>=4.0.0, <=4.4.0
lightning-utilities>=0.6.0.post0, <0.7.0
lightning-utilities>=0.7.0, <0.8.0
4 changes: 4 additions & 0 deletions src/lightning/fabric/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

- Added support for writing logs to remote file systems with the `CSVLogger` ([#16880](https://github.com/Lightning-AI/lightning/pull/16880))


- Added support for frozen dataclasses in the optimizer state ([#16656](https://github.com/Lightning-AI/lightning/pull/16656))


### Changed

- Fabric now chooses `accelerator="auto", strategy="auto", devices="auto"` as defaults ([#16842](https://github.com/Lightning-AI/lightning/pull/16842))
Expand Down
2 changes: 1 addition & 1 deletion src/lightning/fabric/utilities/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ def _optimizers_to_device(optimizers: Iterable[Optimizer], device: _DEVICE) -> N
def _optimizer_to_device(optimizer: Optimizer, device: _DEVICE) -> None:
"""Moves the state of a single optimizer to the device."""
for p, v in optimizer.state.items():
optimizer.state[p] = apply_to_collection(v, Tensor, move_data_to_device, device)
optimizer.state[p] = apply_to_collection(v, Tensor, move_data_to_device, device, allow_frozen=True)
6 changes: 6 additions & 0 deletions tests/tests_fabric/utilities/test_optimizer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import collections
import dataclasses

import torch
from torch import Tensor
Expand All @@ -7,10 +8,15 @@


def test_optimizer_to_device():
@dataclasses.dataclass(frozen=True)
class FooState:
bar: int

class TestOptimizer(torch.optim.SGD):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.state["dummy"] = torch.tensor(0)
self.state["frozen"] = FooState(0)

layer = torch.nn.Linear(32, 2)
opt = TestOptimizer(layer.parameters(), lr=0.1)
Expand Down