repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/constants.py
colossalai/auto_parallel/tensor_shard/constants.py
import operator import torch __all__ = [ "ELEMENTWISE_MODULE_OP", "ELEMENTWISE_FUNC_OP", "RESHAPE_FUNC_OP", "CONV_MODULE_OP", "CONV_FUNC_OP", "LINEAR_MODULE_OP", "LINEAR_FUNC_OP", "BATCHNORM_MODULE_OP", "POOL_MODULE_OP", "NON_PARAM_FUNC_OP", "BCAST_FUNC_OP", "EMBEDDING_...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/__init__.py
colossalai/auto_parallel/tensor_shard/__init__.py
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/sharding_strategy.py
colossalai/auto_parallel/tensor_shard/sharding_strategy.py
from copy import deepcopy from dataclasses import dataclass from enum import Enum from typing import Any, Dict, List, Tuple, Union import torch from torch.fx.node import Node from colossalai.tensor.comm_spec import CommSpec from colossalai.tensor.sharding_spec import ShardingSpec from .constants import ( ELEMENT...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/initialize.py
colossalai/auto_parallel/tensor_shard/initialize.py
from typing import Dict, List, Tuple import torch import torch.distributed as dist import torch.nn as nn from torch.fx.graph import Graph from colossalai._analyzer.fx.codegen import ActivationCheckpointCodeGen from colossalai._analyzer.fx.graph_module import ColoGraphModule from colossalai._analyzer.fx.passes import ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/options.py
colossalai/auto_parallel/tensor_shard/options.py
from dataclasses import dataclass from enum import Enum __all__ = ["SolverOptions", "SolverPerference", "DataloaderOption", "ShardOption"] class SolverPerference(Enum): """ This enum class is to define the solver preference. """ STANDARD = 0 DP = 1 TP = 2 class ShardOption(Enum): """ ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/solver/cost_graph.py
colossalai/auto_parallel/tensor_shard/solver/cost_graph.py
import torch from colossalai.auto_parallel.tensor_shard.constants import INFINITY_COST class CostGraph: """ A graph data structure to simplify the edge cost graph. It has two main functions: 1. To feed the quadratic resharding costs into solver, we need to linearize it. We build edge_cost in CostGrap...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/solver/strategies_constructor.py
colossalai/auto_parallel/tensor_shard/solver/strategies_constructor.py
import torch from torch.fx import Graph from colossalai.auto_parallel.tensor_shard.node_handler import ( GetattrHandler, OutputHandler, PlaceholderHandler, operator_registry, ) from colossalai.auto_parallel.tensor_shard.sharding_strategy import StrategiesVector from colossalai.auto_parallel.tensor_shar...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/solver/graph_analysis.py
colossalai/auto_parallel/tensor_shard/solver/graph_analysis.py
from dataclasses import dataclass from typing import List from torch.fx.graph import Graph from torch.fx.graph_module import GraphModule from torch.fx.node import Node from colossalai.fx.passes.utils import get_node_module __all__ = ["LiveVariable", "LiveVariableVector", "LiveStage", "GraphAnalyser"] @dataclass cl...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/solver/solver.py
colossalai/auto_parallel/tensor_shard/solver/solver.py
"""This code is adapted from Alpa https://github.com/alpa-projects/alpa/ with some changes. """ import multiprocessing import time import warnings from typing import Dict import numpy as np from torch.fx.graph import Graph from torch.fx.node import Node from colossalai.auto_parallel.tensor_shard.constants imp...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/solver/__init__.py
colossalai/auto_parallel/tensor_shard/solver/__init__.py
from .cost_graph import CostGraph from .graph_analysis import GraphAnalyser from .solver import Solver from .strategies_constructor import StrategiesConstructor __all__ = ["GraphAnalyser", "Solver", "StrategiesConstructor", "CostGraph"]
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/utils/broadcast.py
colossalai/auto_parallel/tensor_shard/utils/broadcast.py
from enum import Enum, auto from typing import List import torch from torch.fx.node import Node from colossalai.auto_parallel.tensor_shard.sharding_strategy import ( CommAction, CommType, OperationData, OperationDataType, ) from colossalai.tensor.comm_spec import CollectiveCommPattern, CommSpec from c...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/utils/reshape.py
colossalai/auto_parallel/tensor_shard/utils/reshape.py
from enum import Enum from typing import Dict, List, Tuple import torch class PreviousStatus(Enum): """ This class shows the status of previous comparison. """ RESET = 0 # ORIGIN means the dimension size of original tensor is larger in the previous comparison. ORIGIN = 1 # TGT means the ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/utils/misc.py
colossalai/auto_parallel/tensor_shard/utils/misc.py
import functools from typing import Any, Callable, Tuple, Type, Union import torch from colossalai.logging import get_dist_logger from colossalai.tensor.sharding_spec import ShardingSpec, ShardingSpecException __all__ = ["ignore_sharding_exception", "pytree_map"] def ignore_sharding_exception(func): """ A ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/utils/factory.py
colossalai/auto_parallel/tensor_shard/utils/factory.py
import copy import operator import warnings from functools import reduce from typing import Dict, List, Optional, Union import torch from torch.fx.node import Node from torch.utils._pytree import tree_map from colossalai.device.device_mesh import DeviceMesh from colossalai.tensor.shape_consistency import ShapeConsist...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/utils/__init__.py
colossalai/auto_parallel/tensor_shard/utils/__init__.py
from .broadcast import ( BroadcastType, comm_actions_for_oprands, get_broadcast_shape, is_broadcastable, recover_sharding_spec_for_broadcast_shape, ) from .factory import generate_resharding_costs, generate_sharding_spec from .misc import check_sharding_spec_validity, ignore_sharding_exception, pytr...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/utils/sharding.py
colossalai/auto_parallel/tensor_shard/utils/sharding.py
import operator from copy import deepcopy from functools import reduce from typing import Dict import torch from colossalai.tensor.sharding_spec import ShardingSpec __all__ = [ "transpose_partition_dim", "update_partition_dim", "enumerate_all_possible_1d_sharding", "enumerate_all_possible_2d_sharding...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/default_reshape_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/default_reshape_handler.py
from typing import Dict, List import torch from ..sharding_strategy import OperationData, OperationDataType from .node_handler import MetaInfoNodeHandler from .registry import operator_registry from .strategy import DefaultReshapeGenerator, StrategyGenerator __all__ = ["DefaultReshapeHandler"] @operator_registry.r...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/tensor_constructor_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/tensor_constructor_handler.py
from typing import Dict, List import torch from ..sharding_strategy import OperationData, OperationDataType from .node_handler import NodeHandler from .registry import operator_registry from .strategy import StrategyGenerator from .strategy.tensor_constructor_generator import TensorConstructorGenerator __all__ = ["T...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/layer_norm_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/layer_norm_handler.py
from typing import Dict, List import torch from ..sharding_strategy import OperationData, OperationDataType from .node_handler import MetaInfoModuleHandler from .registry import operator_registry from .strategy import LayerNormGenerator, StrategyGenerator __all__ = ["LayerNormModuleHandler"] @operator_registry.reg...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/registry.py
colossalai/auto_parallel/tensor_shard/node_handler/registry.py
class Registry: def __init__(self, name): self.name = name self.store = {} def register(self, source): def wrapper(func): if isinstance(source, (list, tuple)): # support register a list of items for this func for element in source: ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/matmul_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/matmul_handler.py
import operator from abc import ABC, abstractmethod from copy import deepcopy from enum import Enum from functools import reduce from typing import Dict, List, Union import torch from colossalai.auto_parallel.tensor_shard.utils.broadcast import ( BroadcastType, get_broadcast_dim_info, get_broadcast_shape,...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/where_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/where_handler.py
import copy from typing import Dict, List import torch from ..sharding_strategy import OperationData, OperationDataType, ShardingStrategy from ..utils import recover_sharding_spec_for_broadcast_shape from .node_handler import NodeHandler from .registry import operator_registry from .strategy import StrategyGenerator,...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/unary_elementwise_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/unary_elementwise_handler.py
from typing import Dict, List import torch from ..sharding_strategy import OperationData, OperationDataType from .node_handler import MetaInfoNodeHandler from .registry import operator_registry from .strategy import StrategyGenerator, UnaryElementwiseGenerator __all__ = ["UnaryElementwiseHandler"] @operator_regist...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/view_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/view_handler.py
from typing import Dict, List import torch from ..sharding_strategy import OperationData, OperationDataType from .node_handler import NodeHandler from .registry import operator_registry from .strategy import StrategyGenerator, ViewGenerator __all__ = ["ViewHandler"] @operator_registry.register(torch.Tensor.reshape...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/split_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/split_handler.py
from typing import Dict, List import torch from ..sharding_strategy import OperationData, OperationDataType from .node_handler import NodeHandler from .registry import operator_registry from .strategy import SplitGenerator, StrategyGenerator __all__ = ["SplitHandler"] @operator_registry.register(torch.Tensor.split...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/binary_elementwise_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/binary_elementwise_handler.py
from typing import Dict, List, Union import torch from torch.fx.node import Node from colossalai.auto_parallel.tensor_shard.sharding_strategy import OperationData, OperationDataType, ShardingStrategy from ..constants import BCAST_FUNC_OP from ..utils import comm_actions_for_oprands, recover_sharding_spec_for_broadca...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/placeholder_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/placeholder_handler.py
from typing import Dict, List from torch.fx.node import Node from colossalai.device.device_mesh import DeviceMesh from ..sharding_strategy import OperationData, OperationDataType, StrategiesVector from .node_handler import NodeHandler from .strategy import PlaceholderGenerator, StrategyGenerator __all__ = ["Placeho...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/transpose_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/transpose_handler.py
from typing import Dict, List import torch from ..sharding_strategy import OperationData, OperationDataType from .node_handler import NodeHandler from .registry import operator_registry from .strategy import StrategyGenerator, TransposeGenerator __all__ = ["TransposeHandler"] @operator_registry.register(torch.Tens...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/conv_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/conv_handler.py
from typing import Dict, List import torch import torch.nn.functional as F from ..sharding_strategy import OperationData, OperationDataType, ShardingStrategy from ..utils import transpose_partition_dim from .node_handler import MetaInfoModuleHandler, MetaInfoNodeHandler from .registry import operator_registry from .s...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/node_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/node_handler.py
from abc import ABC, abstractmethod from typing import Dict, List, Tuple, Union import torch from torch.fx.node import Node from colossalai.auto_parallel.meta_profiler.shard_metainfo import ShardMetaInfo, meta_register from colossalai.auto_parallel.tensor_shard.options import ShardOption, SolverPerference from coloss...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/addmm_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/addmm_handler.py
from typing import Dict, List, Union import torch from ..sharding_strategy import OperationData, OperationDataType, ShardingStrategy from ..utils import comm_actions_for_oprands, recover_sharding_spec_for_broadcast_shape from .node_handler import NodeHandler from .registry import operator_registry from .strategy impo...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/getattr_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/getattr_handler.py
from typing import Dict, List from ..sharding_strategy import OperationData, OperationDataType from .node_handler import NodeHandler from .strategy import GetattrGenerator, StrategyGenerator __all__ = ["GetattrHandler"] class GetattrHandler(NodeHandler): """ A GetattrHandler which deals with the sharding st...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/normal_pooling_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/normal_pooling_handler.py
from typing import Dict, List import torch from ..sharding_strategy import OperationData, OperationDataType from .node_handler import MetaInfoModuleHandler from .registry import operator_registry from .strategy import NormalPoolStrategyGenerator, StrategyGenerator __all__ = ["NormPoolingHandler"] @operator_registr...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/__init__.py
colossalai/auto_parallel/tensor_shard/node_handler/__init__.py
from .addmm_handler import ADDMMFunctionHandler from .batch_norm_handler import BatchNormModuleHandler from .binary_elementwise_handler import BinaryElementwiseHandler from .bmm_handler import AddBMMFunctionHandler, BMMFunctionHandler from .conv_handler import ConvFunctionHandler, ConvModuleHandler from .default_reshap...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/permute_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/permute_handler.py
from typing import Dict, List import torch from ..sharding_strategy import OperationData, OperationDataType from .node_handler import NodeHandler from .registry import operator_registry from .strategy import PermuteGenerator, StrategyGenerator __all__ = ["PermuteHandler"] @operator_registry.register(torch.Tensor.p...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/softmax_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/softmax_handler.py
from typing import Dict, List import torch from ..sharding_strategy import OperationData, OperationDataType from .node_handler import NodeHandler from .registry import operator_registry from .strategy import SoftmaxGenerator, StrategyGenerator __all__ = ["SoftmaxHandler"] @operator_registry.register(torch.nn.Softm...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/linear_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/linear_handler.py
from typing import Dict, List, Union import torch import torch.nn.functional as F from colossalai.auto_parallel.tensor_shard.utils import transpose_partition_dim, update_partition_dim from colossalai.logging import get_dist_logger from colossalai.tensor.sharding_spec import ShardingNotDivisibleError from ..sharding_...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/embedding_handler.py
from typing import Dict, List, Union import torch import torch.nn.functional as F from colossalai.auto_parallel.tensor_shard.utils import update_partition_dim from colossalai.logging import get_dist_logger from colossalai.tensor.sharding_spec import ShardingNotDivisibleError from ..sharding_strategy import Operation...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/batch_norm_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/batch_norm_handler.py
from typing import Dict, List import torch from ..sharding_strategy import OperationData, OperationDataType from .node_handler import MetaInfoModuleHandler from .registry import operator_registry from .strategy import BatchNormStrategyGenerator, StrategyGenerator __all__ = ["BatchNormModuleHandler"] @operator_regi...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/getitem_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/getitem_handler.py
import operator from typing import Dict, List import torch from ..sharding_strategy import OperationData, OperationDataType from .node_handler import NodeHandler from .registry import operator_registry from .strategy import StrategyGenerator, TensorStrategyGenerator, TensorTupleStrategyGenerator __all__ = ["GetItemH...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/output_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/output_handler.py
from typing import Dict, List import torch from colossalai.device.device_mesh import DeviceMesh from ..sharding_strategy import OperationData, OperationDataType, StrategiesVector from .node_handler import NodeHandler from .strategy import OutputGenerator, StrategyGenerator __all__ = ["OutputHandler"] class Output...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/sum_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/sum_handler.py
from typing import Dict, List import torch from ..sharding_strategy import OperationData, OperationDataType from .node_handler import NodeHandler from .registry import operator_registry from .strategy import StrategyGenerator, SumGenerator __all__ = ["SumHandler"] @operator_registry.register(torch.Tensor.sum) @ope...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/bmm_handler.py
colossalai/auto_parallel/tensor_shard/node_handler/bmm_handler.py
from typing import Dict, List, Union import torch from ..sharding_strategy import OperationData, OperationDataType, ShardingStrategy from ..utils import comm_actions_for_oprands, recover_sharding_spec_for_broadcast_shape from .node_handler import NodeHandler from .registry import operator_registry from .strategy impo...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/getattr_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/getattr_generator.py
from typing import List from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, ShardingStrategy, TrainCycleItem from colossalai.auto_parallel.tensor_shard.utils import ( enumerate_all_possible_1d_sharding, enumerate_all_possible_2d_sharding, ignore_sharding_exception, ) from coloss...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/reshape_generator.py
import copy from typing import List from colossalai.auto_parallel.tensor_shard.node_handler.strategy.strategy_generator import FollowingStrategyGenerator from colossalai.auto_parallel.tensor_shard.sharding_strategy import ( CommAction, CommType, MemoryCost, ShardingStrategy, TrainCycleItem, ) from ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/binary_elementwise_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/binary_elementwise_generator.py
import operator from functools import reduce from typing import List import torch from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, ShardingStrategy, TrainCycleItem from colossalai.auto_parallel.tensor_shard.utils import ( enumerate_all_possible_1d_sharding, enumerate_all_possibl...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/matmul_strategy_generator.py
import operator from functools import reduce from typing import List from colossalai.auto_parallel.tensor_shard.options import SolverPerference from colossalai.auto_parallel.tensor_shard.sharding_strategy import ( CommType, MemoryCost, ShardingStrategy, TrainCycleItem, ) from colossalai.auto_parallel.t...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
true
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/output_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/output_generator.py
from typing import Dict, List from torch.fx import Node from colossalai.auto_parallel.tensor_shard.sharding_strategy import ( MemoryCost, OperationData, ShardingStrategy, TrainCycleItem, ) from colossalai.device.device_mesh import DeviceMesh from .strategy_generator import OutputStrategyGenerator __...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/batch_norm_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/batch_norm_generator.py
import copy import operator from functools import reduce from typing import List from colossalai.auto_parallel.tensor_shard.sharding_strategy import ( CommType, MemoryCost, ShardingStrategy, TrainCycleItem, ) from colossalai.auto_parallel.tensor_shard.utils import ignore_sharding_exception from colossa...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/sum_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/sum_generator.py
import copy import operator from functools import reduce from typing import List from colossalai.auto_parallel.tensor_shard.node_handler.strategy.strategy_generator import FollowingStrategyGenerator from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, ShardingStrategy, TrainCycleItem __all_...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/getitem_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/getitem_generator.py
import copy from typing import List from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, ShardingStrategy, TrainCycleItem from colossalai.logging import get_dist_logger from colossalai.tensor.sharding_spec import ShardingSpecException from .strategy_generator import FollowingStrategyGenerat...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/unary_elementwise_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/unary_elementwise_generator.py
import copy from typing import List from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, ShardingStrategy, TrainCycleItem from .strategy_generator import FollowingStrategyGenerator __all__ = ["UnaryElementwiseGenerator"] class UnaryElementwiseGenerator(FollowingStrategyGenerator): ""...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/conv_strategy_generator.py
import copy import operator from functools import reduce from typing import List from colossalai.auto_parallel.tensor_shard.sharding_strategy import ( CommType, MemoryCost, ShardingStrategy, TrainCycleItem, ) from colossalai.auto_parallel.tensor_shard.utils import ignore_sharding_exception from colossa...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/layer_norm_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/layer_norm_generator.py
import copy import operator from functools import reduce from typing import List from colossalai.auto_parallel.tensor_shard.sharding_strategy import ( CommType, MemoryCost, ShardingStrategy, TrainCycleItem, ) from colossalai.auto_parallel.tensor_shard.utils import ( enumerate_all_possible_1d_shardi...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/strategy_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/strategy_generator.py
import operator from abc import ABC, abstractmethod from functools import reduce from typing import Any, Dict, List, Union import torch from torch.fx import Node from colossalai.auto_parallel.tensor_shard.sharding_strategy import ( CommAction, CommType, OperationData, OperationDataType, ShardingSt...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/normal_pooling_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/normal_pooling_generator.py
import copy import operator from functools import reduce from typing import List from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, ShardingStrategy, TrainCycleItem from colossalai.auto_parallel.tensor_shard.utils import ( enumerate_all_possible_1d_sharding, enumerate_all_possible_...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/tensor_constructor_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/tensor_constructor_generator.py
from typing import List from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, ShardingStrategy, TrainCycleItem from .strategy_generator import StrategyGenerator __all__ = ["TensorConstructorGenerator"] class TensorConstructorGenerator(StrategyGenerator): """ TensorConstructorGener...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/placeholder_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/placeholder_generator.py
from typing import Dict, List from colossalai.auto_parallel.tensor_shard.sharding_strategy import ( MemoryCost, OperationData, ShardingStrategy, TrainCycleItem, ) from colossalai.device.device_mesh import DeviceMesh from .strategy_generator import StrategyGenerator __all__ = ["PlaceholderGenerator"] ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/__init__.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/__init__.py
from .batch_norm_generator import BatchNormStrategyGenerator from .binary_elementwise_generator import BinaryElementwiseStrategyGenerator from .conv_strategy_generator import ConvStrategyGenerator from .embedding_generator import EmbeddingStrategyGenerator from .getattr_generator import GetattrGenerator from .getitem_g...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/softmax_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/softmax_generator.py
import copy import operator from functools import reduce from typing import List from colossalai.auto_parallel.tensor_shard.node_handler.strategy.strategy_generator import FollowingStrategyGenerator from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, ShardingStrategy, TrainCycleItem __all_...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/where_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/where_generator.py
import copy from typing import List from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, ShardingStrategy, TrainCycleItem from colossalai.auto_parallel.tensor_shard.utils import ( enumerate_all_possible_1d_sharding, enumerate_all_possible_2d_sharding, ignore_sharding_exception, )...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py
colossalai/auto_parallel/tensor_shard/node_handler/strategy/embedding_generator.py
import copy import operator from functools import reduce from typing import List from colossalai.auto_parallel.tensor_shard.sharding_strategy import ( CommType, MemoryCost, ShardingStrategy, TrainCycleItem, ) from colossalai.auto_parallel.tensor_shard.utils import ignore_sharding_exception from colossa...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/pipeline_shard/__init__.py
colossalai/auto_parallel/pipeline_shard/__init__.py
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/offload/amp_optimizer.py
colossalai/auto_parallel/offload/amp_optimizer.py
from enum import Enum from typing import Dict, Tuple import torch from torch.optim import Optimizer from colossalai.accelerator import get_accelerator from colossalai.amp.naive_amp.grad_scaler import DynamicGradScaler from colossalai.interface import OptimizerWrapper from colossalai.logging import get_dist_logger fr...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/offload/runtime.py
colossalai/auto_parallel/offload/runtime.py
from typing import List import torch from torch.fx.node import Node from .region import Region from .util import GlobalRuntimeInfo, requires_upload_p_in_fwd class SynPreFwdPostBwdOP(torch.autograd.Function): """ A customized prefetch and offload operation. Args: input_: input tensor. fw...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/offload/base_offload_module.py
colossalai/auto_parallel/offload/base_offload_module.py
from functools import partial from typing import Optional, Set import torch import torch.nn as nn from colossalai.utils import _cast_float, get_current_device from colossalai.utils.common import free_storage from .region_manager import RegionManager from .util import GlobalRuntimeInfo class BaseOffloadModule: ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/offload/util.py
colossalai/auto_parallel/offload/util.py
from dataclasses import dataclass from typing import List import torch from colossalai.context.singleton_meta import SingletonMeta from colossalai.fx.profiler import calculate_fwd_out, calculate_fwd_tmp from .region import Region @dataclass class NodeInfo: node_id: int = 0 runtime_fwd_mem: float = 0 ru...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/offload/region_manager.py
colossalai/auto_parallel/offload/region_manager.py
from typing import Any, Dict, List, Tuple import torch from torch.fx import Graph, Node from .region import Region from .solver import SolverFactory from .training_simulator import TrainingSimulator from .util import NodeInfo class RegionManager: """ RegionManager is used to construct and manage the offload...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/offload/mem_optimize.py
colossalai/auto_parallel/offload/mem_optimize.py
from typing import Dict import torch import torch.fx from torch.fx import GraphModule from torch.utils._pytree import tree_map from colossalai.fx import ColoTracer, is_compatible_with_meta from colossalai.fx.passes.meta_info_prop import MetaInfoProp from .base_offload_module import BaseOffloadModule from .region_man...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/offload/region.py
colossalai/auto_parallel/offload/region.py
from typing import Dict, List, Tuple import torch from torch.fx import Node from colossalai.utils.common import free_storage from colossalai.zero.gemini.chunk.chunk import alloc_storage class Region: """ Region: A container owning a piece of contiguous nodes in the DNN computing graph. Args: r_...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/offload/solver.py
colossalai/auto_parallel/offload/solver.py
import time from abc import ABC, abstractmethod from typing import Dict, List, Type NOT_NVML = False try: from pynvml import * except: NOT_NVML = True import torch from torch.fx.node import Node from colossalai.accelerator import get_accelerator from .region import Region from .training_simulator import Asy...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/offload/__init__.py
colossalai/auto_parallel/offload/__init__.py
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/offload/training_simulator.py
colossalai/auto_parallel/offload/training_simulator.py
import bisect from abc import ABC, abstractmethod from collections import OrderedDict from typing import Dict, List from torch.fx.node import Node from .region import Region from .util import * @dataclass class ExecutionPeriod: start_time: float = 0 end_time: float = 0 class TrainingSimulator(ABC): ""...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/checkpoint/build_c_ext.py
colossalai/auto_parallel/checkpoint/build_c_ext.py
import os from setuptools import Extension, setup this_dir = os.path.dirname(os.path.abspath(__file__)) ext_modules = [ Extension( "rotorc", sources=[os.path.join(this_dir, "ckpt_solver_rotor.c")], ) ] setup( name="rotor c extension", version="0.1", description="rotor c extension ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/checkpoint/ckpt_solver_chen.py
colossalai/auto_parallel/checkpoint/ckpt_solver_chen.py
import math from copy import deepcopy from typing import List, Set, Tuple from torch.fx import Graph, Node from colossalai.fx.profiler import calculate_fwd_in, calculate_fwd_tmp from .ckpt_solver_base import CheckpointSolverBase __all__ = ["CheckpointSolverChen"] class CheckpointSolverChen(CheckpointSolverBase): ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/checkpoint/ckpt_solver_base.py
colossalai/auto_parallel/checkpoint/ckpt_solver_base.py
from abc import ABC, abstractmethod from copy import deepcopy from typing import Any, List import torch from torch.fx import Graph, Node from colossalai.auto_parallel.passes.runtime_apply_pass import ( runtime_apply, runtime_apply_for_iterable_object, runtime_comm_spec_apply, ) from colossalai.fx.codegen....
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/checkpoint/ckpt_solver_rotor.py
colossalai/auto_parallel/checkpoint/ckpt_solver_rotor.py
from copy import deepcopy from typing import Any, List, Tuple from torch import Tensor from torch.fx import Graph, Node from colossalai.auto_parallel.passes.runtime_apply_pass import runtime_apply, runtime_comm_spec_apply from colossalai.fx.codegen.activation_checkpoint_codegen import _find_nested_ckpt_regions from c...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/checkpoint/__init__.py
colossalai/auto_parallel/checkpoint/__init__.py
from .ckpt_solver_base import CheckpointSolverBase from .ckpt_solver_chen import CheckpointSolverChen from .ckpt_solver_rotor import CheckpointSolverRotor
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/checkpoint/operation.py
colossalai/auto_parallel/checkpoint/operation.py
import math from abc import ABC from typing import List from torch.utils._pytree import tree_map class Chain: def __init__( self, ftime: List[float], btime: List[float], x: List[int], xbar: List[int], ftmp: List[int], btmp: List[int], check_consiste...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/passes/runtime_apply_pass.py
colossalai/auto_parallel/passes/runtime_apply_pass.py
from typing import Dict, List import torch from torch.fx.node import Node from colossalai._analyzer.fx.node_util import MetaInfo from colossalai.auto_parallel.tensor_shard.sharding_strategy import CommType, OperationDataType from colossalai.tensor.comm_spec import CommSpec from colossalai.tensor.shape_consistency imp...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/passes/constants.py
colossalai/auto_parallel/passes/constants.py
import torch OUTPUT_SAVED_OPS = [torch.nn.functional.relu, torch.nn.functional.softmax, torch.flatten] OUTPUT_SAVED_MOD = [ torch.nn.ReLU, torch.nn.Softmax, ] # SHAPE_ARGUMENT_OPS contains node with (input, *shape) style args. # This list could be extended if any other method has the same # argument style as...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/passes/comm_metainfo_pass.py
colossalai/auto_parallel/passes/comm_metainfo_pass.py
from typing import Dict import torch from torch.fx import GraphModule from torch.fx.node import Node from colossalai.auto_parallel.meta_profiler import ShardMetaInfo from colossalai.auto_parallel.passes.runtime_apply_pass import runtime_apply, runtime_comm_spec_apply from colossalai.auto_parallel.tensor_shard.shardin...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/passes/meta_info_prop.py
colossalai/auto_parallel/passes/meta_info_prop.py
import uuid from dataclasses import asdict from typing import List import torch import torch.fx from torch.fx import GraphModule from torch.fx.node import Node from colossalai.auto_parallel.meta_profiler import ShardMetaInfo from colossalai.auto_parallel.passes.constants import OUTPUT_SAVED_MOD, OUTPUT_SAVED_OPS from...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/passes/__init__.py
colossalai/auto_parallel/passes/__init__.py
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/passes/runtime_preparation_pass.py
colossalai/auto_parallel/passes/runtime_preparation_pass.py
import operator from typing import Dict, List, Union import torch from torch.fx.node import Node from colossalai._analyzer.fx.node_util import MetaInfo from colossalai.auto_parallel.tensor_shard.constants import RESHAPE_FUNC_OP from colossalai.auto_parallel.tensor_shard.sharding_strategy import CommType, OperationDat...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/cli/cli.py
colossalai/cli/cli.py
import click from .check import check from .launcher import run class Arguments: def __init__(self, arg_dict): for k, v in arg_dict.items(): self.__dict__[k] = v @click.group() def cli(): pass cli.add_command(run) cli.add_command(check) if __name__ == "__main__": cli()
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/cli/__init__.py
colossalai/cli/__init__.py
from .cli import cli __all__ = ["cli"]
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/cli/launcher/run.py
colossalai/cli/launcher/run.py
import os import sys from typing import List import click import torch from packaging import version from colossalai.context import Config from .hostinfo import HostInfo, HostInfoList from .multinode_runner import MultiNodeRunner # Constants that define our syntax NODE_SEP = "," def fetch_hostfile(hostfile_path: ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/cli/launcher/hostinfo.py
colossalai/cli/launcher/hostinfo.py
import socket class HostInfo: """ A data class to store host connection-related data. Args: hostname (str): name or IP address of the host port (str): the port for ssh connection """ def __init__( self, hostname: str, port: str = None, ): self....
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/cli/launcher/multinode_runner.py
colossalai/cli/launcher/multinode_runner.py
from multiprocessing import Pipe, Process from multiprocessing import connection as mp_connection import click import fabric from .hostinfo import HostInfo, HostInfoList def run_on_host( hostinfo: HostInfo, workdir: str, recv_conn: mp_connection.Connection, send_conn: mp_connection.Connection, e...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/cli/launcher/__init__.py
colossalai/cli/launcher/__init__.py
import click from colossalai.context import Config from .run import launch_multi_processes @click.command( help="Launch distributed training on a single node or multiple nodes", context_settings=dict(ignore_unknown_options=True), ) @click.option( "-H", "-host", "--host", type=str, defaul...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/cli/check/check_installation.py
colossalai/cli/check/check_installation.py
import subprocess import click import torch from torch.utils.cpp_extension import CUDA_HOME import colossalai def to_click_output(val): # installation check output to understandable symbols for readability VAL_TO_SYMBOL = {True: "\u2713", False: "x", None: "N/A"} if val in VAL_TO_SYMBOL: return...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/cli/check/__init__.py
colossalai/cli/check/__init__.py
import click from .check_installation import check_installation __all__ = ["check"] @click.command(help="Check if Colossal-AI is correct based on the given option") @click.option("-i", "--installation", is_flag=True, help="Check if Colossal-AI is built correctly") def check(installation): if installation: ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/inference/logit_processors.py
colossalai/inference/logit_processors.py
# This code is adapted from huggingface transformers: https://github.com/huggingface/transformers/blob/v4.36.2/src/transformers/generation/logits_process.py import logging from typing import List, Union import torch import torch.nn.functional as F _LOGITS_PROCESSOR_MAP = {} def register_logits_processor(process_typ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/inference/struct.py
colossalai/inference/struct.py
import enum from dataclasses import dataclass from typing import Any, List from colossalai.inference.config import DiffusionGenerationConfig from colossalai.logging import get_dist_logger logger = get_dist_logger(__name__) """ The abstraction of request and sequence are defined here. """ class RequestStatus(enum.E...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/inference/sampler.py
colossalai/inference/sampler.py
from typing import List, Optional, Tuple, Union import torch from transformers.generation import GenerationConfig from colossalai.inference.logit_processors import get_logits_processor def greedy_sample( logprobs: torch.Tensor, ) -> torch.Tensor: """ Sample tokens greedyly. """ results = torch.a...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/inference/graph_runner.py
colossalai/inference/graph_runner.py
from typing import Dict, List import torch from torch import nn from colossalai.inference.config import InputMetaData from colossalai.logging import get_dist_logger class CUDAGraphRunner: def __init__(self, model: nn.Module): self.model = model self.graph = None self.input_buffers: Dict[...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/inference/flash_decoding_utils.py
colossalai/inference/flash_decoding_utils.py
import torch from colossalai.context.singleton_meta import SingletonMeta from colossalai.utils import get_current_device class FDIntermTensors(metaclass=SingletonMeta): """Singleton class to hold tensors used for storing intermediate values in flash-decoding. For now, it holds intermediate output and logsume...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/inference/utils.py
colossalai/inference/utils.py
""" Utils for model inference """ import math import os import re from enum import Enum from pathlib import Path from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline from torch import nn from colossalai.logging import get_dist_logger from colossalai.testing import free_port ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/inference/config.py
colossalai/inference/config.py
""" Our config contains various options for inference optimization, it is a unified API that wraps all the configurations for inference. """ import logging from abc import ABC, abstractmethod from dataclasses import dataclass, fields from typing import Any, Callable, Dict, List, Optional, Union import torch from tran...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false