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 |
|---|---|---|---|---|---|---|---|---|
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/csrc/aio/py_test/test_ds_aio.py | csrc/aio/py_test/test_ds_aio.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
"""
Functionality of swapping optimizer tensors to/from (NVMe) storage devices.
"""
import multiprocessing as mp
from ds_aio_args import get_validated_args
from io_engine import io_engine_multiprocessing
def main():
pr... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/csrc/aio/py_test/aio_bench_generate_param.py | csrc/aio/py_test/aio_bench_generate_param.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
"""
Functionality of swapping optimizer tensors to/from (NVMe) storage devices.
"""
import os
import argparse
import json
from parse_aio_stats import READ_SPEED, WRITE_SPEED, get_sorted_results
from perf_sweep_utils import BE... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/csrc/aio/py_test/ds_aio_basic.py | csrc/aio/py_test/ds_aio_basic.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
"""
Functionality of swapping optimizer tensors to/from (NVMe) storage devices.
"""
import os
import time
from deepspeed.ops.aio import AsyncIOBuilder
from test_ds_aio_utils import task_log, create_filename, create_file, cre... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/csrc/aio/py_test/ds_aio_handle.py | csrc/aio/py_test/ds_aio_handle.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
import os
import time
from deepspeed.ops.aio import AsyncIOBuilder
from test_ds_aio_utils import task_log, create_filename, create_file, create_page_locked_tensor
from ds_aio_constants import *
class AIOHandle... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/csrc/aio/py_test/ds_aio_job.py | csrc/aio/py_test/ds_aio_job.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
"""
Functionality of swapping tensors to/from (NVMe) storage devices.
"""
import subprocess
import shlex
class Job(object):
def __init__(self, cmd_line, output_file=None, work_dir=None):
self.cmd_line = cmd_lin... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/csrc/gds/py_test/validate_gds.py | csrc/gds/py_test/validate_gds.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
"""
Functionality of swapping optimizer tensors to/from (NVMe) storage devices.
"""
from deepspeed.ops.op_builder import GDSBuilder
assert GDSBuilder().is_compatible(True)
assert GDSBuilder().load(True)
| python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/git_version_info.py | deepspeed/git_version_info.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
try:
# This is populated by setup.py
from .git_version_info_installed import * # noqa: F401 # type: ignore
except ModuleNotFoundError:
import os
if os.path.isfile('version.txt'):
# Will be missing f... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/constants.py | deepspeed/constants.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import os
from datetime import timedelta
#############################################
# Torch distributed constants
#############################################
TORCH_DISTRIBUTED_DEFAULT_PORT = 29500
# Default process gr... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/__init__.py | deepspeed/__init__.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import sys
import types
import json
from typing import Optional, Union
import torch
from torch.optim import Optimizer
from torch.optim.lr_scheduler import _LRScheduler
from packaging import version as pkg_version
# Skip Tri... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/env_report.py | deepspeed/env_report.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import os
import torch
import deepspeed
import subprocess
import argparse
from .ops.op_builder.all_ops import ALL_OPS
from .git_version_info import installed_ops, torch_info, accelerator_name
from deepspeed.accelerator impor... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/linear/quantization.py | deepspeed/linear/quantization.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import copy
import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Optional
from deepspeed.accelerator import get_accelerator
from deepspeed.ops.fp_quantizer import Quantizer, FP_Quantize
fro... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/linear/optimized_linear.py | deepspeed/linear/optimized_linear.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
import math
import torch.nn as nn
import torch.nn.functional as F
from dataclasses import is_dataclass
from deepspeed.accelerator import get_accelerator
import deepspeed.comm as dist
from .config import LoRACon... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/linear/config.py | deepspeed/linear/config.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from dataclasses import dataclass, field
from typing import List
import torch
@dataclass
class LoRAConfig:
"""
Configuration settings for LoRAOptimizedLinear.
Attributes:
lora_r (int): LoRA attention ... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/linear/__init__.py | deepspeed/linear/__init__.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from .optimized_linear import OptimizedLinear
from .config import LoRAConfig, QuantizationConfig
from .context_manager import Init, init_lora
| python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/linear/context_manager.py | deepspeed/linear/context_manager.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from .optimized_linear import LoRAOptimizedLinear, OptimizedLinear
import torch
try:
import transformers
except ImportError:
transformers = None
def init_lora(model):
model.requires_grad_(False)
for m in ... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/launcher/runner.py | deepspeed/launcher/runner.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
"""
DeepSpeed runner is the main front-end to launching multi-worker
training jobs with DeepSpeed. By default this uses pdsh to parallel
ssh into multiple worker nodes and launch all the necessary processes
per rank for train... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/launcher/launcher_helper.py | deepspeed/launcher/launcher_helper.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import os
import sys
import argparse
import subprocess
from deepspeed.utils import logger
from deepspeed.launcher.constants import MPICH_LAUNCHER
def parse_args(args=None):
parser = argparse.ArgumentParser(description=... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/launcher/constants.py | deepspeed/launcher/constants.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
PDSH_LAUNCHER = 'pdsh'
PDSH_MAX_FAN_OUT = 1024
OPENMPI_LAUNCHER = 'openmpi'
MPICH_LAUNCHER = 'mpich'
IMPI_LAUNCHER = 'impi'
SLURM_LAUNCHER = 'slurm'
MVAPICH_LAUNCHER = 'mvapich'
MVAPICH_TMP_HOSTFILE = '/tmp/deepspeed_mvapic... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/launcher/multinode_runner.py | deepspeed/launcher/multinode_runner.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import os
import sys
import shutil
import subprocess
import warnings
import re
from shlex import split
from abc import ABC, abstractmethod
from deepspeed.accelerator import get_accelerator
from ..utils import logger, get_num... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/launcher/__init__.py | deepspeed/launcher/__init__.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
'''Copyright The Microsoft DeepSpeed Team'''
| python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/launcher/launch.py | deepspeed/launcher/launch.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
"""
DeepSpeed launcher, this is similar to torch's distributed.launch but supports
additional features such as arbitrary gpu exclusion.
deepspeed.launcher.launch is intended to be run on a single worker node and
will spawn s... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/patch_fake_tensor.py | deepspeed/compile/patch_fake_tensor.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
try:
from torch._subclasses import FakeTensorMode
from torch._subclasses.fake_tensor import unset_fake_temporarily
from torch._dynamo.variables.builder import wrap_to_fake_tensor_and_record
except I... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/input_storage.py | deepspeed/compile/input_storage.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from typing import Any, Tuple, Optional
from dataclasses import dataclass
import torch
@dataclass
class TensorMetadata:
"""Metadata for a tensor to be stored in CPU memory"""
shape: Tuple[int, ...]
dtype: torc... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/graph_param.py | deepspeed/compile/graph_param.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from dataclasses import dataclass, field
from typing import Any, Dict, List, Tuple
from functools import reduce
import torch
from torch.fx import Graph, Node
from .fx import get_output_node
from .util import get_param_node... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/fx.py | deepspeed/compile/fx.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from typing import Callable, Any, List, Dict
from collections import defaultdict
import torch
from torch.fx import Node, Graph
from .util import get_last_uses
def get_output_node(graph: Graph):
for v in graph.nodes:
... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/util.py | deepspeed/compile/util.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import functools
import operator
from typing import List, Tuple, Dict, Optional
from collections import defaultdict
import torch
from torch.fx import Node, Graph
from torch.fx.node import map_aggregate, Argument, map_arg
t... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/init_z1.py | deepspeed/compile/init_z1.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import copy
import torch
from deepspeed.accelerator import get_accelerator
from .passes import zero1_compile, zero3_compile
from .backend import make_backend, launch_compile_passes, init_schedule
from .util import get_deep... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/list_schedule.py | deepspeed/compile/list_schedule.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from collections import defaultdict
from typing import List, Dict
from copy import copy
from dataclasses import dataclass
import torch
from torch.fx import Graph, Node
from torch.fx.node import map_arg
try:
from torch.... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/patch_compiled_func.py | deepspeed/compile/patch_compiled_func.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
from deepspeed.utils.torch import required_torch_version
backward_inputs = []
enabled_patched_func = False
original_grad_fn = None
base_meta = type(torch.autograd.Function)
if required_torch_version(min_versi... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/init_z3.py | deepspeed/compile/init_z3.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
from deepspeed import comm as dist
from deepspeed.accelerator import get_accelerator
from deepspeed.runtime.zero.partition_parameters import InsertPostInitMethodToModuleSubClasses
from deepspeed.runtime.zero.pa... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/config.py | deepspeed/compile/config.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from deepspeed.runtime.config_utils import DeepSpeedConfigModel
class CompileConfig(DeepSpeedConfigModel):
""" Configure compile settings """
deepcompile: bool = False
""" Turn on/off the DeepCompile mode """
... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/__init__.py | deepspeed/compile/__init__.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from .util import pad_tensors
| python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/partitioner.py | deepspeed/compile/partitioner.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from typing import Tuple, List
import torch
from torch.fx import GraphModule, Graph, Node
try:
from torch.utils.checkpoint import CheckpointPolicy
from torch._functorch.partitioners import _is_primal
except ImportE... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/backend.py | deepspeed/compile/backend.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from typing import Dict, List, Callable, Tuple
import time
import gc
from collections import OrderedDict
import torch
from torch.fx import Graph, GraphModule
try:
import torch.utils._pytree as pytree
import torch._... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/inductor.py | deepspeed/compile/inductor.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
try:
import torch.utils._pytree as pytree
from torch._inductor.lowering import register_lowering, fallbacks, add_needs_realized_inputs
from torch._inductor.ir import TensorBox, FallbackKernel, Layou... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/passes/offload_parameters.py | deepspeed/compile/passes/offload_parameters.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from typing import List, Tuple
import torch
from torch.fx import Node, GraphModule
from deepspeed.compile.util import get_last_uses
from ..graph_param import DSGraphParamManager
def add_offload_parameter(graph_id: int, gm... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/passes/offload_activation.py | deepspeed/compile/passes/offload_activation.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from typing import List, Dict, Set, Tuple
import random
from collections import defaultdict
import torch
from torch.fx import Graph, Node
from ..fx import get_output_node, move_primals_to_head
from ..graph_param import DSG... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/passes/__init__.py | deepspeed/compile/passes/__init__.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from ..profilers.graph_profile import MemoryProfilingInterpreter
import deepspeed.comm as dist
def run_opt_passes(nz3,
graph_index,
graph_id,
gm,
... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/passes/prefetch.py | deepspeed/compile/passes/prefetch.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from typing import List, Tuple
import torch
from torch.fx import Graph, Node, GraphModule
from deepspeed.accelerator import get_accelerator
import deepspeed.comm as dist
from ..profilers.comm_profile import create_predict... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/passes/zero3_compile.py | deepspeed/compile/passes/zero3_compile.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import gc
from typing import List, Dict, Tuple
import _operator
import torch
from torch.fx import Graph, Node, GraphModule
from ..util import get_input_nodes, get_param_nodes, get_index_by_graph_id, get_deepcompile_handle,... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/passes/selective_gather.py | deepspeed/compile/passes/selective_gather.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from collections import defaultdict
from typing import List, Tuple
import torch
from torch.fx import GraphModule
import deepspeed.comm as dist
from deepspeed.accelerator import get_accelerator
from ..util import get_deepc... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/passes/offload_adam_states.py | deepspeed/compile/passes/offload_adam_states.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import copy
from typing import List, Tuple
import torch
from torch.fx import Graph, GraphModule
from deepspeed.accelerator import get_accelerator
from deepspeed.runtime.zero.offload_states import _make_offload_state_key
t... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/passes/zero1_compile.py | deepspeed/compile/passes/zero1_compile.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from typing import List, Tuple
import torch
from torch.fx import GraphModule
from ..util import get_deepcompile_handle
from ..fx import add_postprocess, move_primals_to_head, _make_node_meta, get_output_node
NAME = "zero1... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/profilers/comm_profile.py | deepspeed/compile/profilers/comm_profile.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import os
import torch
try:
from torch._subclasses.fake_tensor import unset_fake_temporarily
except ImportError:
# Unsupported torch version
pass
import deepspeed
import deepspeed.comm as dist
from deepspeed.ac... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/profilers/__init__.py | deepspeed/compile/profilers/__init__.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from typing import List, Tuple
from dataclasses import dataclass, field
from torch.fx import Graph
@dataclass
class ProfilingResult:
fwd_graph: Graph = None
bwd_graph: Graph = None
needs_backward: bool = False... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compile/profilers/graph_profile.py | deepspeed/compile/profilers/graph_profile.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import time
from typing import Any, Tuple, Dict
import statistics
import torch
from torch.fx import GraphModule, Interpreter
from torch.fx.node import map_aggregate
try:
from torch.utils._pytree import tree_all, tree_l... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/elasticity/elastic_agent.py | deepspeed/elasticity/elastic_agent.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from torch.distributed.elastic.agent.server.local_elastic_agent import LocalElasticAgent
from typing import Any, Dict, Optional, Tuple
from datetime import datetime
from torch.distributed.elastic.utils.distributed import get... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/elasticity/elasticity.py | deepspeed/elasticity/elasticity.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import os
import json
import numpy as np
import math
from packaging import version as pkg_version
from .config import ElasticityConfig, ElasticityConfigError, ElasticityError, \
ElasticityIncompatibleWorldSize
from .con... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/elasticity/constants.py | deepspeed/elasticity/constants.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
#########################################
# Elasticity
#########################################
''' Elasticity Utility in DeepSpeed can be used to create highly elastic jobs compatible
with a large number of GPUs. For elast... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/elasticity/utils.py | deepspeed/elasticity/utils.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from deepspeed.utils.torch import required_torch_version
def is_torch_elastic_compatible():
'''
Helper to lookup torch version. Elastic training is
introduced in 1.11.x
'''
return required_torch... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/elasticity/config.py | deepspeed/elasticity/config.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import json
from .constants import *
class ElasticityError(Exception):
"""
Base exception for all elasticity related errors
"""
class ElasticityConfigError(ElasticityError):
"""
Elasticity configurati... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/elasticity/__init__.py | deepspeed/elasticity/__init__.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from .elasticity import compute_elastic_config, elasticity_enabled, ensure_immutable_elastic_config
from .utils import is_torch_elastic_compatible
from .constants import ENABLED, ENABLED_DEFAULT, ELASTICITY
if is_torch_elast... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/comm/reduce_op.py | deepspeed/comm/reduce_op.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from enum import Enum
class ReduceOp(Enum):
SUM = 0
PRODUCT = 1
MIN = 2
MAX = 3
BAND = 4
BOR = 5
BXOR = 6
AVG = 7
UNUSED = 8
| python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/comm/constants.py | deepspeed/comm/constants.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
NCCL_BACKEND = 'nccl'
CCL_BACKEND = 'ccl'
MPI_BACKEND = 'mpi'
GLOO_BACKEND = 'gloo'
SCCL_BACKEND = 'sccl'
HCCL_BACKEND = 'hccl'
DEFAULT_AML_MASTER_PORT = "54965"
DEFAULT_AML_NCCL_SOCKET_IFNAME = "^docker0,lo"
#############... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/comm/ccl.py | deepspeed/comm/ccl.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
'''
Copyright 2021 The Microsoft DeepSpeed Team
'''
import torch
from deepspeed.accelerator import get_accelerator
from deepspeed.ops.op_builder import NotImplementedBuilder
from .reduce_op import ReduceOp
from .torch import... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/comm/utils.py | deepspeed/comm/utils.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import os
import inspect
from deepspeed.utils import get_caller_func
def get_local_rank_from_launcher():
# DeepSpeed launcher will set it so get from there
rank = os.environ.get('LOCAL_RANK')
if rank is None:... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/comm/comm.py | deepspeed/comm/comm.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
"""
DeepSpeed Communication Package: deepspeed.comm
deepspeed.comm
-- import and use deepspeed.ops.comm
-- use torch.distributed directly if both this package and torch.distributed use the same NCCL ve... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | true |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/comm/config.py | deepspeed/comm/config.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from deepspeed.runtime.config_utils import DeepSpeedConfigModel
from .constants import *
class CommsLoggerConfig(DeepSpeedConfigModel):
enabled: bool = COMMS_LOGGER_ENABLED_DEFAULT
prof_all: bool = COMMS_LOGGER_PR... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/comm/__init__.py | deepspeed/comm/__init__.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from .utils import *
from .comm import *
| python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/comm/torch.py | deepspeed/comm/torch.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import deepspeed
from deepspeed import utils
from packaging import version
import inspect
from .utils import *
from .backend import *
from .comm import *
from ..runtime import compiler
from deepspeed.utils.torch import requ... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/comm/backend.py | deepspeed/comm/backend.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
"""
DeepSpeed Communication Backend.
In the future, directly use NCCL/MPI/Gloo/etc without requiring torch.distributed. Simply wrap torch.distributed for now.
# Custom DS Backends -- Direct C/Ops
- NCCL -- [EXPERIMENTAL]
... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/datastates/config.py | deepspeed/datastates/config.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# Apache-2.0 License Copyright (c) UChicago Argonne LLC, operator of Argonne National Laboratory.
# DeepSpeed Team
from deepspeed.runtime.config_utils import DeepSpeedConfigObject
import copy
DATASTATES_CHECKPOINTING = "datastates_ckpt"
DA... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/datastates/__init__.py | deepspeed/datastates/__init__.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# Apache-2.0 License Copyright (c) UChicago Argonne LLC, operator of Argonne National Laboratory.
# DeepSpeed Team
| python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compression/compress.py | deepspeed/compression/compress.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import re
from .helper import compression_preparation, fix_compression, recursive_getattr, is_module_compressible
from .config import get_compression_config
from ..runtime.config_utils import dict_raise_error_on_duplicate_ke... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compression/helper.py | deepspeed/compression/helper.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
from .basic_layer import Embedding_Compress, LinearLayer_Compress, Conv2dLayer_Compress, BNLayer_Compress, ColumnParallelLinear_Compress, RowParallelLinear_Compress
from .constants import *
from deepspeed.utils ... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compression/basic_layer.py | deepspeed/compression/basic_layer.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
import math
from torch import nn
from torch.nn import init
import deepspeed.comm as dist
from .utils import TopKBinarizer, SymQuantizer, AsymQuantizer, TernaryQuantizer, BinaryQuantizer
from deepspeed.utils impo... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | true |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compression/constants.py | deepspeed/compression/constants.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
#########################################
# Compression Methods
# It has several sub-components
# #########################################
COMPRESSION_TRAINING = "compression_training"
SHARED_PARAMETERS = "shared_parameters... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compression/utils.py | deepspeed/compression/utils.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
from torch import autograd
import math
class TopKBinarizer(autograd.Function):
"""
Top-k Binarizer.
Computes a binary mask M from a real value matrix S such that `M_{i,j} = 1` if and only if `S_{i,... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compression/config.py | deepspeed/compression/config.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from .constants import *
import copy
from ..runtime.config_utils import get_scalar_param, get_list_param
def get_compression_config(param_dict):
#
output = {}
if COMPRESSION_TRAINING not in param_dict.keys():
... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compression/__init__.py | deepspeed/compression/__init__.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from .compress import init_compression, redundancy_clean
from .scheduler import compression_scheduler
from .helper import convert_conv1d_to_linear
| python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/compression/scheduler.py | deepspeed/compression/scheduler.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from .compress import get_module_name
from .constants import *
from .helper import recursive_getattr
from deepspeed.utils import logger
class compression_scheduler():
'''
Used to schedule different compression meth... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/eigenvalue.py | deepspeed/runtime/eigenvalue.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
from deepspeed.utils import log_dist
import numpy as np
import logging
from deepspeed.utils.torch import required_torch_version
class Eigenvalue(object):
def __init__(self,
verbose=False,... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/quantize.py | deepspeed/runtime/quantize.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
import math
from deepspeed.utils import logger
from deepspeed.ops.quantizer import ds_quantizer
TWO_D_PARAMS = 6
class Quantizer(object):
def __init__(self,
q_groups=1,
... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/state_dict_factory.py | deepspeed/runtime/state_dict_factory.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
import os
import copy
import collections
import json
from abc import ABC, abstractmethod
from deepspeed.utils import logger
from deepspeed.runtime.checkpoint_engine.torch_checkpoint_engine import TorchCheckpoin... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/constants.py | deepspeed/runtime/constants.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from deepspeed.accelerator import get_accelerator
#############################################
# Routes
#############################################
ROUTE_TRAIN = "train"
ROUTE_EVAL = "eval"
ROUTE_PREDICT = "predict"
ROUT... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/torch_autocast.py | deepspeed/runtime/torch_autocast.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from typing import Iterable, Set, List, Union
import importlib
from contextlib import contextmanager
import torch
import deepspeed.comm as dist
from deepspeed.utils import logger
from deepspeed.accelerator import get_accele... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/precision_config.py | deepspeed/runtime/precision_config.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from deepspeed.runtime.config_utils import DeepSpeedConfigModel
from .fp16.loss_scaler import (
INITIAL_LOSS_SCALE,
SCALE_WINDOW,
DELAYED_SHIFT,
CONSECUTIVE_HYSTERESIS,
MIN_LOSS_SCALE,
)
################... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/progressive_layer_drop.py | deepspeed/runtime/progressive_layer_drop.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import numpy as np
from deepspeed.utils import log_dist
class ProgressiveLayerDrop(object):
r""" Progressive Layer Dropping (PLD) for model training.
This implements the PLD technique for compressed model train... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/weight_quantizer.py | deepspeed/runtime/weight_quantizer.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
from ..module_inject.replace_policy import HFBertLayerPolicy, replace_policies
from deepspeed.accelerator import get_accelerator
class WeightQuantization(object):
def __init__(self, mlp_extra_grouping=Tru... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/hybrid_engine.py | deepspeed/runtime/hybrid_engine.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
from deepspeed.inference.config import DeepSpeedInferenceConfig
from deepspeed.module_inject.replace_policy import replace_policies
from deepspeed.module_inject.utils import policy_to_ds_container
from .engine i... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/utils.py | deepspeed/runtime/utils.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
"""
Copyright NVIDIA/Megatron
Helper functions and classes from multiple sources.
"""
from collections.abc import Iterable
import os
import psutil
import gc
from math import sqrt
from numpy import prod
import torch
from t... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | true |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/config.py | deepspeed/runtime/config.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import os
from typing import Union
from enum import Enum
import torch
import json
import hjson
import copy
import base64
from .constants import *
from .config_utils import (
get_scalar_param,
dict_raise_error_on_du... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | true |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/compiler.py | deepspeed/runtime/compiler.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
import contextlib
import functools
from deepspeed.utils.torch import required_torch_version
from deepspeed.accelerator import get_accelerator
try:
from torch.compiler import is_compiling as torch_is_compili... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/__init__.py | deepspeed/runtime/__init__.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
| python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/dataloader.py | deepspeed/runtime/dataloader.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from torch.utils.data import DataLoader, RandomSampler
from torch.utils.data.distributed import DistributedSampler
from deepspeed.accelerator import get_accelerator
from deepspeed.runtime.data_pipeline.data_sampling.data_sa... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/config_utils.py | deepspeed/runtime/config_utils.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
"""
Collection of DeepSpeed configuration utilities
"""
import collections
import json
import torch
from functools import reduce
from pydantic import BaseModel, ConfigDict, field_serializer
from deepspeed.utils import logger... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/base_optimizer.py | deepspeed/runtime/base_optimizer.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import os
import torch
from typing import Any
from deepspeed.utils import logger
from deepspeed.utils.tensor_fragment import map_to_flat_opt_states
from deepspeed.runtime.utils import bwc_tensor_model_parallel_rank, see_mem... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/engine.py | deepspeed/runtime/engine.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import os
import re
import stat
import torch
import hashlib
from collections import defaultdict, OrderedDict, deque
from shutil import copyfile
import gc
from torch.nn.modules import Module
from torch.nn.parameter import Pa... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | true |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/bf16_optimizer.py | deepspeed/runtime/bf16_optimizer.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from collections import OrderedDict
import torch
import sys
from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors
from deepspeed import comm as dist
from deepspeed.runtime.constants import PIPE_REPLICATED... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/lr_schedules.py | deepspeed/runtime/lr_schedules.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
"""
Implementation of learning rate schedules.
Taken and modified from PyTorch v1.0.1 source
https://github.com/pytorch/pytorch/blob/v1.1.0/torch/optim/lr_scheduler.py
"""
import argparse
from torch.optim import Optimizer
i... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | true |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/sparse_tensor.py | deepspeed/runtime/sparse_tensor.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
"""
Implementation of a compressed sparse tensor. Similar in
functionality to TensorFlow's IndexedSlices implementation.
"""
import torch
class SparseTensor(object):
""" Compressed Sparse Tensor """
def __init__(s... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/superoffload/superoffload_utils.py | deepspeed/runtime/superoffload/superoffload_utils.py | # Copyright (c) DeepSpeed Team.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
"""
SuperOffload utilities for 1) running CPU optimizers in separate processes.
"""
from typing import Dict, Optional, Any
import torch
import torch.multiprocessing as mp
import psutil
from deepspeed.ops.adam import DeepSpeedCPUA... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/superoffload/__init__.py | deepspeed/runtime/superoffload/__init__.py | # Copyright (c) DeepSpeed Team.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
| python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/superoffload/superoffload_stage3.py | deepspeed/runtime/superoffload/superoffload_stage3.py | # Copyright (c) DeepSpeed Team.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import time
import torch
from typing import List
from deepspeed.runtime.superoffload.superoffload_utils import SuperOffloadCPUOptimizer, TaskKeys, ResultKeys, EventTypes
from deepspeed.runtime.zero.partition_parameters import Para... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/checkpoint_engine/torch_checkpoint_engine.py | deepspeed/runtime/checkpoint_engine/torch_checkpoint_engine.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
from deepspeed.utils import log_dist
from deepspeed.runtime.checkpoint_engine.checkpoint_engine import \
CheckpointEngine, CheckpointCommitInfo
from deepspeed.runtime.model_checkpointing import CHECKPOINT_SE... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/checkpoint_engine/nebula_checkpoint_engine.py | deepspeed/runtime/checkpoint_engine/nebula_checkpoint_engine.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import os
import torch
import torch_nebula
from deepspeed.runtime.checkpoint_engine.checkpoint_engine import \
CheckpointEngine, CheckpointCommitInfo
from deepspeed.utils import logger, log_dist
from deepspeed.nebula.co... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/checkpoint_engine/checkpoint_engine.py | deepspeed/runtime/checkpoint_engine/checkpoint_engine.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import os
import abc
from abc import ABC
from dataclasses import dataclass
@dataclass
class CheckpointCommitInfo(object):
tag: str
save_dir: str
save_latest: bool
class CheckpointEngine(ABC):
# init che... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/checkpoint_engine/fast_checkpoint_engine.py | deepspeed/runtime/checkpoint_engine/fast_checkpoint_engine.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import torch
from deepspeed.runtime.checkpoint_engine.checkpoint_engine import \
CheckpointEngine, CheckpointCommitInfo
from deepspeed.runtime.model_checkpointing import (
CHECKPOINT_WRITER,
CHECKPOINT_SERIALIZAT... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/checkpoint_engine/utils.py | deepspeed/runtime/checkpoint_engine/utils.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
from deepspeed.runtime.model_checkpointing.constants import *
from deepspeed.runtime.model_checkpointing.utils import create_data_parallel_writer_config
from deepspeed.utils import logger
from deepspeed import comm as dist
f... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
deepspeedai/DeepSpeed | https://github.com/deepspeedai/DeepSpeed/blob/2390bc5c4128b4c347be522a2b2d0f109c7879f3/deepspeed/runtime/checkpoint_engine/datastates_checkpoint_engine.py | deepspeed/runtime/checkpoint_engine/datastates_checkpoint_engine.py | # Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# Apache-2.0 License Copyright (c) UChicago Argonne LLC, operator of Argonne National Laboratory.
# DeepSpeed Team
from deepspeed.runtime.checkpoint_engine.checkpoint_engine import \
CheckpointEngine, CheckpointCommitInfo
ENGINE_NAME =... | python | Apache-2.0 | 2390bc5c4128b4c347be522a2b2d0f109c7879f3 | 2026-01-04T14:40:27.668296Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.