2023-03-17 03:00:15 +00:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
from typing import Callable, Tuple
|
|
|
|
|
|
|
|
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
|
|
|
|
def configure(self,
|
|
|
|
model: nn.Module,
|
|
|
|
optimizer: Optimizer,
|
|
|
|
criterion: Callable = None) -> Tuple[nn.Module, OptimizerWrapper, Callable]:
|
|
|
|
# TODO: implement this method
|
|
|
|
pass
|