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/legacy/inference/hybridengine/polices/llama.py
colossalai/legacy/inference/hybridengine/polices/llama.py
from functools import partial from typing import List import torch from torch.nn import Module from transformers.models.llama.modeling_llama import ( LlamaAttention, LlamaDecoderLayer, LlamaForCausalLM, LlamaModel, LlamaRMSNorm, ) from colossalai.shardformer.policies.base_policy import ModulePolic...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/inference/hybridengine/polices/__init__.py
colossalai/legacy/inference/hybridengine/polices/__init__.py
from .llama import LlamaModelInferPolicy __all__ = ["LlamaModelInferPolicy"]
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/inference/pipeline/microbatch_manager.py
colossalai/legacy/inference/pipeline/microbatch_manager.py
from enum import Enum from typing import Dict import torch from ..tensor_parallel.batch_infer_state import BatchInferState from ..tensor_parallel.kvcache_manager import MemoryManager __all__ = "MicroBatchManager" class Status(Enum): PREFILL = 1 GENERATE = 2 DONE = 3 COOLDOWN = 4 class MicroBatchD...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/inference/pipeline/__init__.py
colossalai/legacy/inference/pipeline/__init__.py
from .microbatch_manager import MicroBatchManager __all__ = ["MicroBatchManager"]
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/inference/pipeline/benchmark/benchmark.py
colossalai/legacy/inference/pipeline/benchmark/benchmark.py
import argparse import time import torch import torch.distributed as dist import transformers import colossalai from colossalai.inference import PPInferEngine from colossalai.inference.pipeline.policies import LlamaModelInferPolicy GIGABYTE = 1024**3 MEGABYTE = 1024 * 1024 colossalai.launch_from_torch() def data_...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/registry/registry.py
colossalai/legacy/registry/registry.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- from types import ModuleType from typing import List class Registry: """This is a registry class used to register classes and modules so that a universal object builder can be enabled. Args: name (str): The name of the registry . third_part...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/registry/__init__.py
colossalai/legacy/registry/__init__.py
import torch.distributed.optim as dist_optim import torch.nn as nn import torch.optim as optim from .registry import Registry LAYERS = Registry("layers", third_party_library=[nn]) MODELS = Registry("models") OPTIMIZERS = Registry("optimizers", third_party_library=[optim, dist_optim]) DATASETS = Registry("datasets") D...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/parallel_context.py
colossalai/legacy/context/parallel_context.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- import random import socket from collections import Counter from typing import Union import numpy as np import torch import torch.distributed as dist from colossalai.context.config import Config from colossalai.context.singleton_meta import SingletonMeta from colossala...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/parallel_mode.py
colossalai/legacy/context/parallel_mode.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- from enum import Enum # parallel modes class ParallelMode(Enum): """This is an enumeration class containing all possible parallel modes.""" GLOBAL = "global" # common parallel DATA = "data" # model parallel - containing tensor and pipeline parall...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/__init__.py
colossalai/legacy/context/__init__.py
from .parallel_context import ParallelContext from .parallel_mode import ParallelMode from .process_group_initializer import * from .random import *
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/process_group_initializer/process_group_initializer.py
colossalai/legacy/context/process_group_initializer/process_group_initializer.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- from abc import ABC, abstractmethod from colossalai.context import Config class ProcessGroupInitializer(ABC): """An object, knowing the parallelism configuration, that initializes parallel groups. Args: rank (int): The rank of current process. ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/process_group_initializer/initializer_data.py
colossalai/legacy/context/process_group_initializer/initializer_data.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- from torch import distributed as dist from colossalai.legacy.registry import DIST_GROUP_INITIALIZER from ..parallel_mode import ParallelMode from .process_group_initializer import ProcessGroupInitializer @DIST_GROUP_INITIALIZER.register_module class Initializer_Data(...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/process_group_initializer/initializer_2p5d.py
colossalai/legacy/context/process_group_initializer/initializer_2p5d.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- import math import torch.distributed as dist from colossalai.context import Config from colossalai.legacy.global_variables import tensor_parallel_env as env from colossalai.legacy.registry import DIST_GROUP_INITIALIZER from ..parallel_mode import ParallelMode from .pr...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/process_group_initializer/initializer_3d.py
colossalai/legacy/context/process_group_initializer/initializer_3d.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- import math import torch.distributed as dist from colossalai.legacy.global_variables import tensor_parallel_env as env from colossalai.legacy.registry import DIST_GROUP_INITIALIZER from ..parallel_mode import ParallelMode from .process_group_initializer import Process...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/process_group_initializer/initializer_1d.py
colossalai/legacy/context/process_group_initializer/initializer_1d.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- import torch.distributed as dist from colossalai.legacy.global_variables import tensor_parallel_env as env from colossalai.legacy.registry import DIST_GROUP_INITIALIZER from ..parallel_mode import ParallelMode from .process_group_initializer import ProcessGroupInitiali...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/process_group_initializer/initializer_sequence.py
colossalai/legacy/context/process_group_initializer/initializer_sequence.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- import torch.distributed as dist from colossalai.legacy.registry import DIST_GROUP_INITIALIZER from ..parallel_mode import ParallelMode from .initializer_tensor import Initializer_Tensor from .process_group_initializer import ProcessGroupInitializer @DIST_GROUP_INITIA...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/process_group_initializer/initializer_model.py
colossalai/legacy/context/process_group_initializer/initializer_model.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- import torch.distributed as dist from colossalai.legacy.registry import DIST_GROUP_INITIALIZER from ..parallel_mode import ParallelMode from .process_group_initializer import ProcessGroupInitializer @DIST_GROUP_INITIALIZER.register_module class Initializer_Model(Proc...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/process_group_initializer/initializer_2d.py
colossalai/legacy/context/process_group_initializer/initializer_2d.py
import math import torch.distributed as dist from colossalai.legacy.global_variables import tensor_parallel_env as env from colossalai.legacy.registry import DIST_GROUP_INITIALIZER from ..parallel_mode import ParallelMode from .process_group_initializer import ProcessGroupInitializer def _check_summa_env_var(summa...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/process_group_initializer/__init__.py
colossalai/legacy/context/process_group_initializer/__init__.py
from .initializer_1d import Initializer_1D from .initializer_2d import Initializer_2D from .initializer_2p5d import Initializer_2p5D from .initializer_3d import Initializer_3D from .initializer_data import Initializer_Data from .initializer_model import Initializer_Model from .initializer_pipeline import Initializer_Pi...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/process_group_initializer/initializer_pipeline.py
colossalai/legacy/context/process_group_initializer/initializer_pipeline.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- from torch import distributed as dist from colossalai.legacy.registry import DIST_GROUP_INITIALIZER from ..parallel_mode import ParallelMode from .process_group_initializer import ProcessGroupInitializer @DIST_GROUP_INITIALIZER.register_module class Initializer_Pipel...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/process_group_initializer/initializer_tensor.py
colossalai/legacy/context/process_group_initializer/initializer_tensor.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- import torch.distributed as dist from colossalai.legacy.registry import DIST_GROUP_INITIALIZER from ..parallel_mode import ParallelMode from .process_group_initializer import ProcessGroupInitializer @DIST_GROUP_INITIALIZER.register_module class Initializer_Tensor(Pro...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/random/seed_manager.py
colossalai/legacy/context/random/seed_manager.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- import torch from torch import Tensor from colossalai.legacy.context.parallel_mode import ParallelMode class SeedManager: """This class is a manager of all random seeds involved in the system. Note: The parallel_mode should be concluded in ``ParallelM...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/random/_helper.py
colossalai/legacy/context/random/_helper.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- import functools from contextlib import contextmanager import torch.cuda from torch import Tensor from ..parallel_mode import ParallelMode from .seed_manager import SeedManager _SEED_MANAGER = SeedManager() def get_seeds(): """Returns the seeds of the seed manag...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/context/random/__init__.py
colossalai/legacy/context/random/__init__.py
from ._helper import ( add_seed, get_current_mode, get_seeds, get_states, moe_set_seed, reset_seeds, seed, set_mode, set_seed_states, sync_states, with_seed, ) __all__ = [ "seed", "set_mode", "with_seed", "add_seed", "get_seeds", "get_states", "ge...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/load_balance.py
colossalai/legacy/moe/load_balance.py
from copy import deepcopy from typing import List, Optional, Tuple import torch import torch.distributed as dist from torch import Tensor, nn from torch.distributed import ProcessGroup from colossalai.cluster import ProcessGroupMesh from colossalai.legacy.moe.manager import MOE_MANAGER from colossalai.shardformer.lay...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/utils.py
colossalai/legacy/moe/utils.py
import contextlib import os from typing import Any, Callable, Dict, List, Optional, Tuple import torch import torch.distributed as dist import torch.nn as nn import torch.nn.functional as F from torch.distributed.distributed_c10d import get_process_group_ranks from colossalai.accelerator import get_accelerator from c...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/manager.py
colossalai/legacy/moe/manager.py
from typing import Tuple import torch import torch.distributed as dist from colossalai.context.singleton_meta import SingletonMeta from colossalai.tensor.moe_tensor.api import get_moe_info from colossalai.tensor.moe_tensor.moe_info import MoeParallelInfo class MoEManager(metaclass=SingletonMeta): """MoE manager...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/openmoe/train.py
colossalai/legacy/moe/openmoe/train.py
import argparse import os from functools import partial from typing import Dict import torch import torch.distributed as dist from datasets import load_dataset from huggingface_hub import snapshot_download from model.modeling_openmoe import OpenMoeForCausalLM, set_openmoe_args from model.openmoe_policy import OpenMoeF...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/openmoe/infer.py
colossalai/legacy/moe/openmoe/infer.py
from argparse import ArgumentParser import torch from model.modeling_openmoe import OpenMoeForCausalLM, set_openmoe_args from transformers import T5Tokenizer from transformers.models.llama import LlamaConfig def parse_args(): parser = ArgumentParser() parser.add_argument("--model", default="base", type=str, ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/openmoe/model/openmoe_policy.py
colossalai/legacy/moe/openmoe/model/openmoe_policy.py
from functools import partial from typing import Callable, Dict, List, Optional, Union import torch import torch.nn as nn import torch.nn.functional as F from torch import Tensor from torch.nn import Module from transformers.modeling_outputs import CausalLMOutputWithPast from transformers.utils import logging from co...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/openmoe/model/convert_openmoe_ckpt.py
colossalai/legacy/moe/openmoe/model/convert_openmoe_ckpt.py
# coding=utf-8 # Copyright 2022 Google LLC and HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/openmoe/model/__init__.py
colossalai/legacy/moe/openmoe/model/__init__.py
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/openmoe/model/modeling_openmoe.py
colossalai/legacy/moe/openmoe/model/modeling_openmoe.py
# coding=utf-8 # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved. # # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX # and OPT implementations in this library. It has been modified from its # original forms to accommodate minor architectural differences compared # to G...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
true
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/openmoe/benchmark/benchmark_fsdp.py
colossalai/legacy/moe/openmoe/benchmark/benchmark_fsdp.py
import argparse import functools import os import torch import torch.distributed as dist import tqdm from model.modeling_openmoe import LlamaConfig, OpenMoeDecoderLayer, OpenMoeForCausalLM, set_openmoe_args from torch.distributed.fsdp import FullyShardedDataParallel as FSDP from torch.distributed.fsdp.fully_sharded_da...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/openmoe/benchmark/utils.py
colossalai/legacy/moe/openmoe/benchmark/utils.py
from time import time from typing import Optional import torch import torch.distributed as dist import torch.nn as nn from torch import Tensor from colossalai.logging import DistributedLogger def print_model_numel(logger: DistributedLogger, model: nn.Module) -> None: B = 1024**3 M = 1024**2 K = 1024 ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/openmoe/benchmark/benchmark_cai.py
colossalai/legacy/moe/openmoe/benchmark/benchmark_cai.py
import argparse import json import os import torch import torch.distributed as dist from huggingface_hub import snapshot_download from model.modeling_openmoe import OpenMoeForCausalLM, set_openmoe_args from model.openmoe_policy import OpenMoeForCausalLMPolicy from torch.utils.data import Dataset from tqdm import tqdm ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/layer/experts.py
colossalai/legacy/moe/layer/experts.py
import math from typing import Callable, Optional, Tuple import torch import torch.nn as nn from colossalai.kernel.triton.llama_act_combine_kernel import HAS_TRITON from colossalai.legacy.moe.manager import MOE_MANAGER from colossalai.legacy.moe.utils import get_activation from colossalai.moe._operation import EPGrad...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/layer/__init__.py
colossalai/legacy/moe/layer/__init__.py
from .experts import * from .layers import * from .routers import *
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/layer/routers.py
colossalai/legacy/moe/layer/routers.py
import math from typing import Callable, Optional, Tuple import torch import torch.nn as nn from colossalai.kernel.triton.llama_act_combine_kernel import HAS_TRITON from colossalai.legacy.moe.manager import MOE_MANAGER from colossalai.legacy.moe.utils import get_activation from colossalai.moe._operation import EPGrad...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/moe/layer/layers.py
colossalai/legacy/moe/layer/layers.py
import dataclasses import math from typing import Any, Optional, Tuple import torch import torch.distributed as dist import torch.nn as nn import torch.nn.functional as F from colossalai.legacy.moe.load_balance import LoadBalancer from colossalai.legacy.moe.utils import create_ep_hierarchical_group, get_noise_generat...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/pipeline/pipeline_process_group.py
colossalai/legacy/pipeline/pipeline_process_group.py
import threading from typing import List import torch.distributed as dist from torch.distributed import rpc from colossalai.legacy.tensor import ProcessGroup class PipelineProcessGroup: # TODO : flexible API for DP size and TP size # In the future design mode, dp_degree and tp_degree should be removed d...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/pipeline/pipelinable.py
colossalai/legacy/pipeline/pipelinable.py
import torch from colossalai.legacy.context import ParallelMode from colossalai.legacy.core import global_context as gpc from colossalai.legacy.nn.layer.utils import CheckpointModule from colossalai.tensor import ColoParameter from colossalai.utils.model.utils import InsertPostInitMethodToModuleSubClasses from .layer...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/pipeline/utils.py
colossalai/legacy/pipeline/utils.py
import heapq import inspect from collections import OrderedDict from typing import List import torch from colossalai.legacy.nn.layer.utils import CheckpointModule from colossalai.logging import get_dist_logger def _binary_partition(weights: List, start: int, end: int): """Returns the binary partition position o...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/pipeline/__init__.py
colossalai/legacy/pipeline/__init__.py
from .layer_spec import LayerSpec from .pipelinable import PipelinableContext, PipelinableModel __all__ = ["PipelinableModel", "PipelinableContext", "LayerSpec"]
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/pipeline/layer_spec.py
colossalai/legacy/pipeline/layer_spec.py
import torch from colossalai.utils.model.utils import call_to_str class LayerSpec: """ """ def __init__(self, typename, *module_args, **module_kwargs): self.typename = typename self.module_args = module_args self.module_kwargs = module_kwargs self.children = None self...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/pipeline/middleware/topo.py
colossalai/legacy/pipeline/middleware/topo.py
from dataclasses import dataclass from typing import Dict, List # This file includes data structure used by Pipeline Middleware. @dataclass class ValPosition: partition_id: int offset: int def __str__(self) -> str: res = f"[partition_id:{self.partition_id},offset:{self.offset}]" return r...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/pipeline/middleware/__init__.py
colossalai/legacy/pipeline/middleware/__init__.py
from .topo import Partition, PartitionInputVal, PartitionOutputVal, Topo __all__ = ["Topo", "Partition", "PartitionOutputVal", "PartitionInputVal"]
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/pipeline/middleware/adaptor/fx.py
colossalai/legacy/pipeline/middleware/adaptor/fx.py
import torch from torch.fx.graph_module import GraphModule from colossalai.legacy.pipeline.middleware.topo import Partition, PartitionInputVal, PartitionOutputVal, Topo def partition_name_to_id(partition_name, is_input=False, is_output=False): if is_input: partition_id = 0 elif is_output: par...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/pipeline/middleware/adaptor/__init__.py
colossalai/legacy/pipeline/middleware/adaptor/__init__.py
from .fx import get_topology as get_fx_topology __all__ = ["get_fx_topology"]
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/pipeline/rpc/_pipeline_schedule.py
colossalai/legacy/pipeline/rpc/_pipeline_schedule.py
import threading from typing import Callable, Dict, List import torch from torch._C._distributed_rpc import PyRRef from torch.futures import Future from colossalai.legacy.pipeline.pipeline_process_group import ppg from colossalai.legacy.pipeline.rpc._pipeline_base import Phase, PipelineEngineBase, UniqueKey, WorkerBa...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/pipeline/rpc/utils.py
colossalai/legacy/pipeline/rpc/utils.py
import argparse import os import warnings from typing import Any, Callable, Tuple, Type, Union import torch import torch.distributed.rpc as rpc import torch.multiprocessing as mp from torch._C._distributed_rpc import _is_current_rpc_agent_set from torch.futures import Future from colossalai.initialize import launch f...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/pipeline/rpc/_pipeline_base.py
colossalai/legacy/pipeline/rpc/_pipeline_base.py
import inspect import math import threading from abc import ABC, abstractmethod from enum import Enum from functools import partial from typing import Any, Callable, Dict, List, Tuple import torch import torch.distributed.rpc as rpc from torch import autograd, nn, optim from torch._C._distributed_rpc import PyRRef fro...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
true
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/legacy/pipeline/rpc/__init__.py
colossalai/legacy/pipeline/rpc/__init__.py
from ._pipeline_schedule import ChimeraPipelineEngine, FillDrainPipelineEngine, OneFOneBPipelineEngine from .utils import pytree_map __all__ = ["FillDrainPipelineEngine", "OneFOneBPipelineEngine", "ChimeraPipelineEngine", "pytree_map"]
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/__init__.py
colossalai/nn/__init__.py
from .init import * from .layer import * from .loss import * from .lr_scheduler import * from .optimizer import *
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/init.py
colossalai/nn/init.py
import math import warnings import torch.nn as nn from torch import Tensor def zeros_(): """Return the initializer filling the input Tensor with the scalar zeros""" def initializer(tensor: Tensor, fan_in: int = None, fan_out: int = None): return nn.init.zeros_(tensor) return initializer def o...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/loss/__init__.py
colossalai/nn/loss/__init__.py
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/layer/layernorm.py
colossalai/nn/layer/layernorm.py
"""This code is from NVIDIA apex: https://github.com/NVIDIA/apex with some changes. """ import numbers import torch from torch.cuda.amp import custom_bwd, custom_fwd from torch.nn import init from torch.nn.parameter import Parameter from colossalai.kernel.kernel_loader import LayerNormLoader try: from ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/layer/utils.py
colossalai/nn/layer/utils.py
def divide(numerator, denominator): """Only allow exact division. Args: numerator (int): Numerator of the division. denominator (int): Denominator of the division. Returns: int: the result of exact division. """ assert denominator != 0, "denominator can not be zero" ass...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/layer/__init__.py
colossalai/nn/layer/__init__.py
from .utils import *
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/layer/scaled_softmax.py
colossalai/nn/layer/scaled_softmax.py
# This code from NVIDIA Megatron: # with minor changes. import enum import torch import torch.nn as nn from colossalai.kernel.kernel_loader import ScaledMaskedSoftmaxLoader, ScaledUpperTriangleMaskedSoftmaxLoader # NOTE: These kernels are compiled on specific GPU arch and not widely applicable. # try: # fro...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/lr_scheduler/onecycle.py
colossalai/nn/lr_scheduler/onecycle.py
from torch.optim.lr_scheduler import OneCycleLR as _OneCycleLR class OneCycleLR(_OneCycleLR): r"""Sets the learning rate of each parameter group according to the 1cycle learning rate policy. The 1cycle policy anneals the learning rate from an initial learning rate to some maximum learning rate and then ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/lr_scheduler/multistep.py
colossalai/nn/lr_scheduler/multistep.py
from typing import List from torch.optim.lr_scheduler import MultiStepLR as _MultiStepLR from .delayed import WarmupScheduler class MultiStepLR(_MultiStepLR): """Decays the learning rate of each parameter group by gamma once the number of epoch reaches one of the milestones. Notice that such decay can h...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/lr_scheduler/delayed.py
colossalai/nn/lr_scheduler/delayed.py
import torch from packaging.version import Version if Version(torch.__version__) >= Version("2.0.0"): from torch.optim.lr_scheduler import LRScheduler as _LRScheduler else: from torch.optim.lr_scheduler import _LRScheduler from colossalai.logging import get_dist_logger class _enable_get_lr_call: def __i...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/lr_scheduler/__init__.py
colossalai/nn/lr_scheduler/__init__.py
from .cosine import CosineAnnealingLR, CosineAnnealingWarmupLR, FlatAnnealingLR, FlatAnnealingWarmupLR from .linear import LinearWarmupLR from .multistep import MultiStepLR, MultiStepWarmupLR from .onecycle import OneCycleLR from .poly import PolynomialLR, PolynomialWarmupLR from .torch import ExponentialLR, LambdaLR, ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/lr_scheduler/cosine.py
colossalai/nn/lr_scheduler/cosine.py
from torch.optim.lr_scheduler import CosineAnnealingLR as _CosineAnnealingLR from .delayed import DelayerScheduler, WarmupDelayerScheduler, WarmupScheduler class CosineAnnealingLR(_CosineAnnealingLR): r"""Set the learning rate of each parameter group using a cosine annealing schedule, where :math:`\eta_{max}...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/lr_scheduler/poly.py
colossalai/nn/lr_scheduler/poly.py
from torch.optim.lr_scheduler import _LRScheduler from .delayed import WarmupScheduler class PolynomialLR(_LRScheduler): """Polynomial learning rate scheduler. Args: optimizer (:class:`torch.optim.Optimizer`): Wrapped optimizer. total_steps (int): Number of total training steps. end_...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/lr_scheduler/torch.py
colossalai/nn/lr_scheduler/torch.py
from torch.optim.lr_scheduler import ExponentialLR as _ExponentialLR from torch.optim.lr_scheduler import LambdaLR as _LambdaLR from torch.optim.lr_scheduler import MultiplicativeLR as _MultiplicativeLR from torch.optim.lr_scheduler import StepLR as _StepLR class LambdaLR(_LambdaLR): """Sets the learning rate of ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/lr_scheduler/linear.py
colossalai/nn/lr_scheduler/linear.py
from torch.optim.lr_scheduler import _LRScheduler class LinearWarmupLR(_LRScheduler): """Linearly warmup learning rate and then linearly decay. Args: optimizer (:class:`torch.optim.Optimizer`): Wrapped optimizer. total_steps (int): Number of total training steps. warmup_steps (int, op...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/distributed_lamb.py
colossalai/nn/optimizer/distributed_lamb.py
# Disclaimer: Modified from https://github.com/NUS-HPC-AI-Lab/pytorch-lamb/blob/master/optim/lamb.py from typing import Dict, Optional import torch import torch.distributed as dist from colossalai.interface.optimizer import DistributedOptim from colossalai.tensor.d_tensor import is_distributed_tensor __all__ = ["D...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/fused_lamb.py
colossalai/nn/optimizer/fused_lamb.py
# modified from https://github.com/NVIDIA/apex/blob/master/apex/optimizers/fused_lamb.py import torch from colossalai.utils import multi_tensor_applier class FusedLAMB(torch.optim.Optimizer): """Implements LAMB algorithm. `FusedLAMB` requires CUDA extensions which can be built during installation or runtime...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/hybrid_adam.py
colossalai/nn/optimizer/hybrid_adam.py
from typing import Any, Optional import torch from colossalai.kernel.kernel_loader import FusedOptimizerLoader from colossalai.utils import get_current_device, multi_tensor_applier from .cpu_adam import CPUAdam class HybridAdam(CPUAdam): """Implements Adam algorithm. Supports parameters updating on both G...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/distributed_adafactor.py
colossalai/nn/optimizer/distributed_adafactor.py
import math from typing import Dict import torch import torch.distributed as dist from colossalai.interface.optimizer import DistributedOptim from colossalai.shardformer.layer._operation import _gather, _split from colossalai.tensor.d_tensor import get_sharding_spec, is_distributed_tensor # DistributedAdaFactor (wit...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/lars.py
colossalai/nn/optimizer/lars.py
"""Adapted from https://github.com/NUS-HPC-AI-Lab/LARS-ImageNet-PyTorch/blob/main/lars.py""" from typing import Iterable import torch from torch.optim import Optimizer class Lars(Optimizer): r"""Implements the LARS optimizer from `"Large batch training of convolutional networks" <https://arxiv.org/pdf/1708....
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/fused_adam.py
colossalai/nn/optimizer/fused_adam.py
# modified from https://github.com/NVIDIA/apex/blob/master/apex/optimizers/fused_adam.py """ Copyright 2020 The Microsoft DeepSpeed Team Copyright NVIDIA/apex This file is adapted from fused adam in NVIDIA/apex, commit a109f85 Licensed under the MIT License. """ import torch from colossalai.utils import get_current_d...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/came.py
colossalai/nn/optimizer/came.py
# Copied from https://github.com/yangluo7/CAME/blob/master/came_pytorch/CAME.py import torch import torch.optim class CAME(torch.optim.Optimizer): """Implements CAME algorithm. This implementation is based on: `CAME: Confidence-guided Adaptive Memory Efficient Optimization` Args: params (itera...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/galore.py
colossalai/nn/optimizer/galore.py
""" adapted from https://github.com/jiaweizzhao/GaLore/blob/master/galore_torch/adamw8bit.py""" import warnings from typing import List import torch from bitsandbytes.optim.optimizer import Optimizer2State from torch._C import _LinAlgError def get_galore_param_groups( model, weight_decay, rank=256, update_proj_...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/__init__.py
colossalai/nn/optimizer/__init__.py
from galore_torch import GaLoreAdafactor, GaLoreAdamW from colossalai.logging import get_dist_logger from .came import CAME from .cpu_adam import CPUAdam from .distributed_adafactor import DistributedAdaFactor from .distributed_came import DistributedCAME from .distributed_galore import DistGaloreAwamW from .distribu...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/adafactor.py
colossalai/nn/optimizer/adafactor.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICEN...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/distributed_came.py
colossalai/nn/optimizer/distributed_came.py
from typing import Dict import torch import torch.distributed as dist from colossalai.interface.optimizer import DistributedOptim from colossalai.shardformer.layer._operation import _gather, _split from colossalai.tensor.d_tensor import get_sharding_spec, is_distributed_tensor class DistributedCAME(DistributedOptim...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/lamb.py
colossalai/nn/optimizer/lamb.py
""" Adapted from the pytorch-lamb library at https://github.com/cybertronai/pytorch-lamb """ import torch from torch.optim import Optimizer class Lamb(Optimizer): r"""Implements Lamb algorithm. It has been proposed in `Large Batch Optimization for Deep Learning: Training BERT in 76 minutes`_. Arguments:...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/nvme_optimizer.py
colossalai/nn/optimizer/nvme_optimizer.py
import math import os import tempfile from typing import Callable, Dict, List, Optional import torch from torch.nn.parameter import Parameter class NVMeOptimizer(torch.optim.Optimizer): """A base class for offloading optimizer states. Args: params: parameters defaults (dict): default dict ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/distributed_galore.py
colossalai/nn/optimizer/distributed_galore.py
""" adapted from https://github.com/jiaweizzhao/GaLore/blob/master/galore_torch/adamw8bit.py""" import warnings from collections import defaultdict from typing import Dict, Optional import torch import torch.distributed as dist import torch.nn.functional as F from bitsandbytes.optim.optimizer import Optimizer2State ...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/cpu_adam.py
colossalai/nn/optimizer/cpu_adam.py
import math from typing import Optional import torch from colossalai.kernel.kernel_loader import CPUAdamLoader from .nvme_optimizer import NVMeOptimizer class CPUAdam(NVMeOptimizer): """ Implements Adam algorithm. Supports parameters updating on both GPU and CPU, depending on the device of parameters....
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/nn/optimizer/fused_sgd.py
colossalai/nn/optimizer/fused_sgd.py
# modified from https://github.com/NVIDIA/apex/blob/master/apex/optimizers/fused_sgd.py import torch from torch.optim.optimizer import Optimizer, required from colossalai.utils import multi_tensor_applier class FusedSGD(Optimizer): r"""Implements stochastic gradient descent (optionally with momentum). `Fuse...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/__init__.py
colossalai/auto_parallel/__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/meta_profiler/shard_metainfo.py
colossalai/auto_parallel/meta_profiler/shard_metainfo.py
from typing import Callable, List import torch from colossalai.auto_parallel.tensor_shard.sharding_strategy import OperationData, ShardingStrategy, TrainCycleItem from colossalai.tensor.sharding_spec import ShardingSpec from .constants import INPLACE_MODULE, INPLACE_OPS, NO_SAVE_ACTIVATION from .registry import meta...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/meta_profiler/registry.py
colossalai/auto_parallel/meta_profiler/registry.py
__all__ = ["Registry"] 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 eleme...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/meta_profiler/constants.py
colossalai/auto_parallel/meta_profiler/constants.py
import operator import torch import torch.nn as nn # list of inplace module INPLACE_MODULE = [nn.ReLU] # list of inplace operations INPLACE_OPS = [torch.flatten] # list of operations that do not save forward activations NO_SAVE_ACTIVATION = [torch.add, torch.sub, operator.add, operator.sub]
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/meta_profiler/__init__.py
colossalai/auto_parallel/meta_profiler/__init__.py
from .meta_registry import * from .registry import meta_register from .shard_metainfo 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/meta_profiler/meta_registry/activation.py
colossalai/auto_parallel/meta_profiler/meta_registry/activation.py
from typing import Callable, List, Tuple import torch from colossalai._analyzer._subclasses.flop_tensor import ewise_flop_counter as elementwise_flop_counter from colossalai._analyzer.fx.node_util import compute_size_in_bytes as activation_size from colossalai.auto_parallel.tensor_shard.sharding_strategy import Memor...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/meta_profiler/meta_registry/where.py
colossalai/auto_parallel/meta_profiler/meta_registry/where.py
from typing import List, Tuple import torch from colossalai._analyzer._subclasses.flop_tensor import flop_mapping from colossalai._analyzer.fx.node_util import compute_size_in_bytes as activation_size from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, TrainCycleItem from ..registry impor...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py
colossalai/auto_parallel/meta_profiler/meta_registry/binary_elementwise_ops.py
from typing import List, Tuple import torch from colossalai._analyzer._subclasses.flop_tensor import flop_mapping from colossalai._analyzer.fx.node_util import compute_size_in_bytes as activation_size from colossalai.auto_parallel.tensor_shard.constants import BCAST_FUNC_OP from colossalai.auto_parallel.tensor_shard....
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/meta_profiler/meta_registry/conv.py
colossalai/auto_parallel/meta_profiler/meta_registry/conv.py
from typing import List, Tuple import torch from colossalai._analyzer._subclasses.flop_tensor import flop_mapping from colossalai._analyzer.fx.node_util import compute_size_in_bytes from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, OperationDataType, TrainCycleItem from ..registry impor...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/meta_profiler/meta_registry/pooling.py
colossalai/auto_parallel/meta_profiler/meta_registry/pooling.py
from typing import List, Tuple import torch from colossalai._analyzer._subclasses.flop_tensor import flop_mapping from colossalai._analyzer.fx.node_util import compute_size_in_bytes from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, OperationDataType, TrainCycleItem from ..registry impor...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/meta_profiler/meta_registry/non_spmd.py
colossalai/auto_parallel/meta_profiler/meta_registry/non_spmd.py
import operator from typing import List, Tuple import torch from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, TrainCycleItem from ..registry import meta_register __all__ = ["non_spmd_meta_info"] @meta_register.register(torch.Size) @meta_register.register(torch.Tensor.size) @meta_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/meta_profiler/meta_registry/norm.py
colossalai/auto_parallel/meta_profiler/meta_registry/norm.py
from typing import List, Tuple import torch from colossalai._analyzer._subclasses.flop_tensor import flop_mapping from colossalai._analyzer.fx.node_util import compute_size_in_bytes from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, OperationDataType, TrainCycleItem from ..registry impor...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/meta_profiler/meta_registry/__init__.py
colossalai/auto_parallel/meta_profiler/meta_registry/__init__.py
from .activation import * from .binary_elementwise_ops import * from .conv import * from .embedding import * from .linear import * from .non_spmd import * from .norm import * from .pooling import * from .tensor import * from .where 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/meta_profiler/meta_registry/embedding.py
colossalai/auto_parallel/meta_profiler/meta_registry/embedding.py
from typing import List, Tuple import torch from colossalai._analyzer._subclasses.flop_tensor import flop_mapping from colossalai._analyzer.fx.node_util import compute_size_in_bytes from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, OperationDataType, TrainCycleItem from ..registry impor...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/meta_profiler/meta_registry/tensor.py
colossalai/auto_parallel/meta_profiler/meta_registry/tensor.py
from typing import Callable, List, Tuple import torch from colossalai._analyzer.fx.node_util import compute_size_in_bytes from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, OperationDataType, TrainCycleItem from ..registry import meta_register __all__ = ["tensor_related_metainfo"] def...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false
hpcaitech/ColossalAI
https://github.com/hpcaitech/ColossalAI/blob/b1915d2889543949eb5b610241f1515c73df5059/colossalai/auto_parallel/meta_profiler/meta_registry/linear.py
colossalai/auto_parallel/meta_profiler/meta_registry/linear.py
from functools import reduce from typing import List, Tuple import torch from colossalai._analyzer._subclasses.flop_tensor import flop_mapping from colossalai._analyzer.fx.node_util import compute_size_in_bytes from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, TrainCycleItem from ..regi...
python
Apache-2.0
b1915d2889543949eb5b610241f1515c73df5059
2026-01-04T14:40:19.002665Z
false