Skip to content

Commit

Permalink
Fix TypeError in configure_optimizers when running with ReduceLROnPla…
Browse files Browse the repository at this point in the history
…teau (#20471)

* fix TypeError in configure_optimizers

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Lukas Salchow <[email protected]>
Co-authored-by: Luca Antiga <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Dec 10, 2024
1 parent 6b88ddc commit 64d0d02
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/lightning/pytorch/utilities/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,25 @@ class LRSchedulerConfigType(TypedDict, total=False):
strict: bool


class OptimizerLRSchedulerConfig(TypedDict):
class OptimizerConfigDict(TypedDict):
optimizer: Optimizer
lr_scheduler: NotRequired[Union[LRSchedulerTypeUnion, LRSchedulerConfigType]]


class OptimizerLRSchedulerConfigDict(TypedDict):
optimizer: Optimizer
lr_scheduler: Union[LRSchedulerTypeUnion, LRSchedulerConfigType]
monitor: NotRequired[str]


OptimizerLRScheduler = Optional[
Union[
Optimizer,
Sequence[Optimizer],
tuple[Sequence[Optimizer], Sequence[Union[LRSchedulerTypeUnion, LRSchedulerConfig]]],
OptimizerLRSchedulerConfig,
Sequence[OptimizerLRSchedulerConfig],
OptimizerConfigDict,
OptimizerLRSchedulerConfigDict,
Sequence[OptimizerConfigDict],
Sequence[OptimizerLRSchedulerConfigDict],
]
]

Expand Down

0 comments on commit 64d0d02

Please sign in to comment.