Unverified Commit 554aa959 authored by Hongxin Liu's avatar Hongxin Liu Committed by GitHub
Browse files

[legacy] move communication and nn to legacy and refactor logger (#4671)

* [legacy] move communication to legacy (#4640)

* [legacy] refactor logger and clean up legacy codes (#4654)

* [legacy] make logger independent to gpc

* [legacy] make optim independent to registry

* [legacy] move test engine to legacy

* [legacy] move nn to legacy (#4656)

* [legacy] move nn to legacy

* [checkpointio] fix save hf config

* [test] remove useledd rpc pp test

* [legacy] fix nn init

* [example] skip tutorial hybriad parallel example

* [devops] test doc check

* [devops] test doc check
parent 536397cc
...@@ -4,7 +4,7 @@ from typing import Optional, Set ...@@ -4,7 +4,7 @@ from typing import Optional, Set
import torch import torch
import torch.nn as nn import torch.nn as nn
from colossalai.nn.parallel.data_parallel import _cast_float from colossalai.utils import _cast_float
from colossalai.zero.legacy.gemini.tensor_utils import free_storage from colossalai.zero.legacy.gemini.tensor_utils import free_storage
from .region_manager import RegionManager from .region_manager import RegionManager
......
class Registry: class Registry:
# TODO: refactor the registry classes used in colossalai.legacy.registry, colossalai.fx and here
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
......
...@@ -11,8 +11,6 @@ from typing import Iterator, List, Mapping, Optional, OrderedDict, Tuple ...@@ -11,8 +11,6 @@ from typing import Iterator, List, Mapping, Optional, OrderedDict, Tuple
import torch import torch
import torch.nn as nn import torch.nn as nn
from torch.optim import Optimizer from torch.optim import Optimizer
from transformers.modeling_utils import PreTrainedModel, get_parameter_dtype
from transformers.modeling_utils import unwrap_model as unwrap_huggingface_model
from colossalai.interface import ModelWrapper, OptimizerWrapper from colossalai.interface import ModelWrapper, OptimizerWrapper
from colossalai.nn.optimizer import ColossalaiOptimizer from colossalai.nn.optimizer import ColossalaiOptimizer
...@@ -383,6 +381,11 @@ def save_config_file(model: nn.Module, checkpoint_path: str, is_master: bool = T ...@@ -383,6 +381,11 @@ def save_config_file(model: nn.Module, checkpoint_path: str, is_master: bool = T
checkpoint_path (str): Path to the checkpoint directory. checkpoint_path (str): Path to the checkpoint directory.
is_master (bool): Whether current rank is main process. is_master (bool): Whether current rank is main process.
""" """
try:
from transformers.modeling_utils import PreTrainedModel, get_parameter_dtype
from transformers.modeling_utils import unwrap_model as unwrap_huggingface_model
except ImportError:
return
if not isinstance(model, PreTrainedModel): if not isinstance(model, PreTrainedModel):
return return
......
import torch import torch
import colossalai.nn as col_nn import colossalai.legacy.nn as col_nn
class MLP(torch.nn.Module): class MLP(torch.nn.Module):
......
import torch import torch
from colossalai.nn.layer.colossalai_layer import Embedding, Linear from colossalai.legacy.nn.layer.colossalai_layer import Embedding, Linear
from colossalai.utils import get_current_device from colossalai.utils import get_current_device
from .bias_dropout_add import bias_dropout_add_fused_train from .bias_dropout_add import bias_dropout_add_fused_train
......
from .collective import all_gather, reduce_scatter, all_reduce, broadcast, reduce from .collective import all_gather, all_reduce, broadcast, reduce, reduce_scatter
from .p2p import (send_forward, send_forward_recv_forward, send_backward_recv_forward, send_backward, from .p2p import (
send_backward_recv_backward, send_forward_recv_backward, send_forward_backward_recv_forward_backward, recv_backward,
recv_forward, recv_backward) recv_forward,
send_backward,
send_backward_recv_backward,
send_backward_recv_forward,
send_forward,
send_forward_backward_recv_forward_backward,
send_forward_recv_backward,
send_forward_recv_forward,
)
from .ring import ring_forward from .ring import ring_forward
from .utils import send_obj_meta, recv_obj_meta from .utils import recv_obj_meta, send_obj_meta
__all__ = [ __all__ = [
'all_gather', 'all_gather',
......
...@@ -6,7 +6,7 @@ from typing import Callable, List, Tuple, Union ...@@ -6,7 +6,7 @@ from typing import Callable, List, Tuple, Union
import torch.cuda import torch.cuda
import colossalai.communication as comm import colossalai.legacy.communication as comm
from colossalai.amp.naive_amp import NaiveAMPModel from colossalai.amp.naive_amp import NaiveAMPModel
from colossalai.context.parallel_mode import ParallelMode from colossalai.context.parallel_mode import ParallelMode
from colossalai.core import global_context as gpc from colossalai.core import global_context as gpc
......
...@@ -5,10 +5,10 @@ from typing import Iterable, Tuple ...@@ -5,10 +5,10 @@ from typing import Iterable, Tuple
import torch.cuda import torch.cuda
import colossalai.communication.p2p_v2 as comm import colossalai.legacy.communication.p2p_v2 as comm
from colossalai import engine
from colossalai.context.parallel_mode import ParallelMode from colossalai.context.parallel_mode import ParallelMode
from colossalai.core import global_context as gpc from colossalai.core import global_context as gpc
from colossalai.legacy.engine import Engine
from colossalai.utils.cuda import get_current_device from colossalai.utils.cuda import get_current_device
from ._pipeline_schedule import PipelineSchedule from ._pipeline_schedule import PipelineSchedule
...@@ -60,7 +60,7 @@ class PipelineScheduleV2(PipelineSchedule): ...@@ -60,7 +60,7 @@ class PipelineScheduleV2(PipelineSchedule):
""" """
def forward_backward_step(self, def forward_backward_step(self,
engine: engine.Engine, engine: Engine,
data_iter: Iterable, data_iter: Iterable,
forward_only=False, forward_only=False,
return_loss=True, return_loss=True,
......
from ._ops import *
from .layer import *
from .loss import *
from .metric import *
...@@ -4,7 +4,7 @@ import torch ...@@ -4,7 +4,7 @@ import torch
import torch.distributed as dist import torch.distributed as dist
from colossalai.global_variables import tensor_parallel_env as env from colossalai.global_variables import tensor_parallel_env as env
from colossalai.nn.layer.utils import divide from colossalai.legacy.nn.layer.utils import divide
from colossalai.tensor import ColoTensor, ColoTensorSpec, ProcessGroup from colossalai.tensor import ColoTensor, ColoTensorSpec, ProcessGroup
GeneralTensor = Union[ColoTensor, torch.Tensor] GeneralTensor = Union[ColoTensor, torch.Tensor]
...@@ -232,7 +232,7 @@ def dual_all_to_all(x, pg, scatter_dim: int, gather_dim: int): ...@@ -232,7 +232,7 @@ def dual_all_to_all(x, pg, scatter_dim: int, gather_dim: int):
return _DualAllToAll.apply(x, pg, scatter_dim, gather_dim) return _DualAllToAll.apply(x, pg, scatter_dim, gather_dim)
### table wise embedding shard # table wise embedding shard
def _all_to_all_for_tablewise(x: torch.Tensor, def _all_to_all_for_tablewise(x: torch.Tensor,
......
import torch.nn.functional as F
from typing import Optional from typing import Optional
import torch.nn.functional as F
from colossalai.tensor import ColoTensor, ColoTensorSpec, ComputePattern, ComputeSpec, ReplicaSpec, ShardSpec
from colossalai.tensor.op_wrapper import colo_op_impl from colossalai.tensor.op_wrapper import colo_op_impl
from colossalai.tensor import ComputePattern, ColoTensorSpec, ComputePattern, ComputeSpec, ColoTensor, ShardSpec, \
ReplicaSpec
from ._utils import GeneralTensor, convert_to_colo_tensor, reduce_input from ._utils import GeneralTensor, convert_to_colo_tensor, reduce_input
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment