Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

add support for precision="16-mixed" #7

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/lightning_colossalai/precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ class ColossalAIPrecisionPlugin(PrecisionPlugin):
If precison is not 16.
"""

def __init__(self, precision: Literal["16", 16] = 16) -> None:
def __init__(self, precision: Literal["16", 16, "16-mixed"] = 16) -> None:
if precision not in ("16", 16):
raise ValueError(
f"`Trainer(strategy='colossalai', precision={precision!r})` is not supported."
" Consider setting `precision=16`."
)
self.precision = cast(Literal["16"], str(precision))
self.precision = cast(Literal["16", "16-mixed"], str(precision))

def backward( # type: ignore[override]
self,
Expand Down
2 changes: 1 addition & 1 deletion src/lightning_colossalai/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def setup_precision_plugin(self) -> None:

def setup(self, trainer: Trainer) -> None:
precision = self.precision_plugin.precision
if precision != "16":
if precision not in ("16", "16-mixed"):
raise ValueError(
f"`Trainer(strategy='colossalai', precision={precision!r})` is not supported."
" Consider setting `precision=16`."
Expand Down