2023-03-17 03:00:15 +00:00
|
|
|
from abc import ABC, abstractmethod
|
2023-06-15 09:38:42 +00:00
|
|
|
from typing import Callable, Optional, Tuple
|
2023-03-17 03:00:15 +00:00
|
|
|
|
|
|
|
import torch.nn as nn
|
|
|
|
from torch.optim import Optimizer
|
|
|
|
|
2023-03-27 02:24:14 +00:00
|
|
|
from colossalai.interface import OptimizerWrapper
|
2023-03-17 03:00:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
class MixedPrecision(ABC):
|
|
|
|
"""
|
|
|
|
An abstract class for mixed precision training.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@abstractmethod
|
2023-07-17 10:01:30 +00:00
|
|
|
def configure(
|
|
|
|
self,
|
|
|
|
model: nn.Module,
|
|
|
|
optimizer: Optional[Optimizer] = None,
|
|
|
|
criterion: Optional[Callable] = None,
|
|
|
|
) -> Tuple[nn.Module, OptimizerWrapper, Callable]:
|
2023-03-17 03:00:15 +00:00
|
|
|
# TODO: implement this method
|
|
|
|
pass
|