Skip to content

Commit

Permalink
[legacy] move nn to legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
ver217 committed Sep 7, 2023
1 parent 724628a commit 5190ac0
Show file tree
Hide file tree
Showing 135 changed files with 697 additions and 553 deletions.
2 changes: 1 addition & 1 deletion colossalai/auto_parallel/offload/base_offload_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torch
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 .region_manager import RegionManager
Expand Down
2 changes: 1 addition & 1 deletion colossalai/cli/benchmark/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import torch

import colossalai.nn as col_nn
import colossalai.legacy.nn as col_nn


class MLP(torch.nn.Module):
Expand Down
2 changes: 1 addition & 1 deletion colossalai/kernel/jit/option.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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 .bias_dropout_add import bias_dropout_add_fused_train
Expand Down
4 changes: 4 additions & 0 deletions colossalai/legacy/nn/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from ._ops import *
from .layer import *
from .loss import *
from .metric import *
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torch.distributed as dist

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

GeneralTensor = Union[ColoTensor, torch.Tensor]
Expand Down Expand Up @@ -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)


### table wise embedding shard
# table wise embedding shard


def _all_to_all_for_tablewise(x: torch.Tensor,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import torch.nn.functional as F
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 import ComputePattern, ColoTensorSpec, ComputePattern, ComputeSpec, ColoTensor, ShardSpec, \
ReplicaSpec

from ._utils import GeneralTensor, convert_to_colo_tensor, reduce_input


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import torch.nn.functional as F
from typing import Optional

import torch.nn.functional as F
from torch import Tensor

from colossalai.tensor import ColoTensor, ColoTensorSpec, ComputePattern, ComputeSpec, ReplicaSpec, ShardSpec, distspec
from colossalai.tensor.op_wrapper import colo_op_impl
from colossalai.tensor import ComputePattern, ComputePattern, ComputeSpec, ColoTensor, distspec, ColoTensorSpec, \
ShardSpec, ReplicaSpec

from ._utils import GeneralTensor, convert_to_colo_tensor


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from typing import List, Optional

import torch.nn.functional as F

from colossalai.tensor import ColoTensor, ColoTensorSpec, ReplicaSpec, distspec
from colossalai.tensor.op_wrapper import colo_op_impl
from colossalai.tensor import ColoTensor, distspec, ColoTensorSpec, ReplicaSpec

from ._utils import GeneralTensor, convert_to_colo_tensor


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from typing import Optional

import torch
import torch.nn.functional as F
from typing import Optional
from colossalai.tensor.op_wrapper import colo_op_impl

from colossalai.legacy.nn.loss.loss_1d import VocabParallelCrossEntropyLoss1D
from colossalai.tensor import ColoTensor, ColoTensorSpec
from colossalai.nn.loss.loss_1d import VocabParallelCrossEntropyLoss1D
from colossalai.tensor.op_wrapper import colo_op_impl

from ._utils import GeneralTensor, convert_to_colo_tensor


Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions colossalai/legacy/nn/layer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from .colossalai_layer import *
from .parallel_1d import *
from .parallel_2d import *
from .parallel_2p5d import *
from .parallel_3d import *
from .parallel_sequence import *
from .utils import *
from .vanilla import *
from .wrapper import *
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ._utils import partition_batch
from .dropout import Dropout
from .embedding import Embedding, PatchEmbedding
from .linear import Classifier, Linear
from .normalization import LayerNorm

__all__ = ['Linear', 'Classifier', 'Embedding', 'PatchEmbedding', 'LayerNorm', 'Dropout', 'partition_batch']
from ._utils import partition_batch
from .dropout import Dropout
from .embedding import Embedding, PatchEmbedding
from .linear import Classifier, Linear
from .normalization import LayerNorm

__all__ = ['Linear', 'Classifier', 'Embedding', 'PatchEmbedding', 'LayerNorm', 'Dropout', 'partition_batch']
Loading

0 comments on commit 5190ac0

Please sign in to comment.