id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
10,254
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,255
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,256
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,257
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,258
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
Parses pipeline engine configuration.
10,259
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,260
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,261
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,262
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,263
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,264
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,265
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,266
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,267
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,268
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,269
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,270
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,271
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,272
import os from typing import Union import torch import json import copy import base64 from .constants import * from .fp16.loss_scaler import ( INITIAL_LOSS_SCALE, SCALE_WINDOW, DELAYED_SHIFT, MIN_LOSS_SCALE, ) from .config_utils import ( get_scalar_param, dict_raise_error_on_duplicate_keys, ...
null
10,273
from dataclasses import dataclass import collections from collections import UserDict from typing import Deque, Set from torch.cuda import Event, Stream from deepspeed import comm as dist from deepspeed.utils.logging import logger from deepspeed.runtime.zero.offload_config import OffloadDeviceEnum from deepspeed.runtim...
null
10,274
from dataclasses import dataclass import collections from collections import UserDict from typing import Deque, Set from torch.cuda import Event, Stream from deepspeed import comm as dist from deepspeed.utils.logging import logger from deepspeed.runtime.zero.offload_config import OffloadDeviceEnum from deepspeed.runtim...
null
10,275
import os from typing import List import torch from deepspeed import comm as dist from deepspeed.utils import logger from deepspeed.ops.adam import DeepSpeedCPUAdam from deepspeed.ops.adam import FusedAdam from deepspeed.utils.nvtx import instrument_w_nvtx def _initialize_parameter_parallel_groups(parameter_parallel_s...
null
10,276
import os from typing import List import torch from deepspeed import comm as dist from deepspeed.utils import logger from deepspeed.ops.adam import DeepSpeedCPUAdam from deepspeed.ops.adam import FusedAdam from deepspeed.utils.nvtx import instrument_w_nvtx ZERO_SUPPORTED_OPTIMIZERS = [ torch.optim.Adam, torch.o...
null
10,277
import os from typing import List import torch from deepspeed import comm as dist from deepspeed.utils import logger from deepspeed.ops.adam import DeepSpeedCPUAdam from deepspeed.ops.adam import FusedAdam from deepspeed.utils.nvtx import instrument_w_nvtx def get_lst_from_rank0(lst: List[int]) -> None: """ NOT...
NOTE: creates both communication and synchronization overhead so should be used sparingly takes a list of ints from each rank and ensures that they are the same across ranks, throwing an exception if they are not.
10,278
import torch import os from deepspeed import comm as dist from torch._six import inf from packaging import version as pkg_version from collections import OrderedDict from deepspeed.runtime import ZeROOptimizer from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime.utils impo...
null
10,279
import torch import os from deepspeed import comm as dist from torch._six import inf from packaging import version as pkg_version from collections import OrderedDict from deepspeed.runtime import ZeROOptimizer from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime.utils impo...
null
10,280
import torch import os from deepspeed import comm as dist from torch._six import inf from packaging import version as pkg_version from collections import OrderedDict from deepspeed.runtime import ZeROOptimizer from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime.utils impo...
null
10,281
import torch import os from deepspeed import comm as dist from torch._six import inf from packaging import version as pkg_version from collections import OrderedDict from deepspeed.runtime import ZeROOptimizer from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime.utils impo...
null
10,282
import torch import os from deepspeed import comm as dist from torch._six import inf from packaging import version as pkg_version from collections import OrderedDict from deepspeed.runtime import ZeROOptimizer from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime.utils impo...
null
10,283
import torch import os from deepspeed import comm as dist from torch._six import inf from packaging import version as pkg_version from collections import OrderedDict from deepspeed.runtime import ZeROOptimizer from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime.utils impo...
null
10,284
import torch import os from deepspeed import comm as dist from torch._six import inf from packaging import version as pkg_version from collections import OrderedDict from deepspeed.runtime import ZeROOptimizer from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime.utils impo...
null
10,285
import torch import os from deepspeed import comm as dist from torch._six import inf from packaging import version as pkg_version from collections import OrderedDict from deepspeed.runtime import ZeROOptimizer from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime.utils impo...
null
10,286
import torch import os from deepspeed import comm as dist from torch._six import inf from packaging import version as pkg_version from collections import OrderedDict from deepspeed.runtime import ZeROOptimizer from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime.utils impo...
null
10,287
import torch import os from deepspeed import comm as dist from torch._six import inf from packaging import version as pkg_version from collections import OrderedDict from deepspeed.runtime import ZeROOptimizer from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime.utils impo...
Print out estimates on memory usage requirements for ZeRO 2 params, optim states and gradients for a given ``model`` and hardware setup. If you have an actual model object, use this function and everything will be derived automatically. If it's a hypothetical model, use ``estimate_zero2_model_states_mem_needs_all_cold`...
10,288
import torch from deepspeed import comm as dist def print_rank_0(message): if dist.get_rank() == 0: print(message)
null
10,289
import sys import gc import collections from typing import Deque, Dict, Tuple from torch.cuda import Event, Stream from torch._six import inf from deepspeed.runtime import ZeROOptimizer from deepspeed.utils import logger from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime...
null
10,290
import sys import gc import collections from typing import Deque, Dict, Tuple from torch.cuda import Event, Stream from torch._six import inf from deepspeed.runtime import ZeROOptimizer from deepspeed.utils import logger from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime...
null
10,291
import sys import gc import collections from typing import Deque, Dict, Tuple from torch.cuda import Event, Stream from torch._six import inf from deepspeed.runtime import ZeROOptimizer from deepspeed.utils import logger from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime...
null
10,292
import sys import gc import collections from typing import Deque, Dict, Tuple from torch.cuda import Event, Stream from torch._six import inf from deepspeed.runtime import ZeROOptimizer from deepspeed.utils import logger from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime...
null
10,293
import sys import gc import collections from typing import Deque, Dict, Tuple from torch.cuda import Event, Stream from torch._six import inf from deepspeed.runtime import ZeROOptimizer from deepspeed.utils import logger from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime...
null
10,294
import sys import gc import collections from typing import Deque, Dict, Tuple from torch.cuda import Event, Stream from torch._six import inf from deepspeed.runtime import ZeROOptimizer from deepspeed.utils import logger from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime...
null
10,295
import sys import gc import collections from typing import Deque, Dict, Tuple from torch.cuda import Event, Stream from torch._six import inf from deepspeed.runtime import ZeROOptimizer from deepspeed.utils import logger from deepspeed.runtime.fp16.loss_scaler import LossScaler, DynamicLossScaler from deepspeed.runtime...
Print out estimates on memory usage requirements for ZeRO 3 params, optim states and gradients for a given ``model`` and hardware setup. If you have an actual model object, use this function and everything will be derived automatically. If it's a hypothetical model, use ``estimate_zero3_model_states_mem_needs_all_cold`...
10,296
from pydantic import Field, validator import sys from typing import Optional from enum import Enum from deepspeed.runtime.config_utils import get_scalar_param, pp_int, DeepSpeedConfigModel from deepspeed.utils import logger from .offload_config import DeepSpeedZeroOffloadParamConfig, DeepSpeedZeroOffloadOptimizerConfig...
null
10,297
import sys import torch from torch.cuda import Stream from collections import OrderedDict from deepspeed.runtime.utils import see_memory_usage from deepspeed.runtime.zero.offload_config import OffloadDeviceEnum from deepspeed.runtime.zero.partition_parameters import _init_external_params from deepspeed.runtime.zero.par...
null
10,298
import sys import torch from torch.cuda import Stream from collections import OrderedDict from deepspeed.runtime.utils import see_memory_usage from deepspeed.runtime.zero.offload_config import OffloadDeviceEnum from deepspeed.runtime.zero.partition_parameters import _init_external_params from deepspeed.runtime.zero.par...
null
10,299
import sys import torch from torch.cuda import Stream from collections import OrderedDict from deepspeed.runtime.utils import see_memory_usage from deepspeed.runtime.zero.offload_config import OffloadDeviceEnum from deepspeed.runtime.zero.partition_parameters import _init_external_params from deepspeed.runtime.zero.par...
null
10,300
import math import os import types from typing import Callable, Iterable from enum import Enum import functools import itertools from typing import List import torch from torch import Tensor from deepspeed import comm as dist from torch.nn import Module from torch.nn import Parameter from .linear import zero3_linear_wr...
null
10,301
import math import os import types from typing import Callable, Iterable from enum import Enum import functools import itertools from typing import List import torch from torch import Tensor from deepspeed import comm as dist from torch.nn import Module from torch.nn import Parameter from .linear import zero3_linear_wr...
null
10,302
import math import os import types from typing import Callable, Iterable from enum import Enum import functools import itertools from typing import List import torch from torch import Tensor from deepspeed import comm as dist from torch.nn import Module from torch.nn import Parameter from .linear import zero3_linear_wr...
null
10,303
import math import os import types from typing import Callable, Iterable from enum import Enum import functools import itertools from typing import List import torch from torch import Tensor from deepspeed import comm as dist from torch.nn import Module from torch.nn import Parameter from .linear import zero3_linear_wr...
null
10,304
import math import os import types from typing import Callable, Iterable from enum import Enum import functools import itertools from typing import List import torch from torch import Tensor from deepspeed import comm as dist from torch.nn import Module from torch.nn import Parameter from .linear import zero3_linear_wr...
Instruct DeepSpeed to coordinate ``parameter``'s collection and partitioning in the forward and backward passes of ``module``. This is used when a parameter is accessed outside of its owning module's ``forward()``. DeepSpeed must know to collect it from its partitioned state and when to release the memory. .. note:: Th...
10,305
import math import os import types from typing import Callable, Iterable from enum import Enum import functools import itertools from typing import List import torch from torch import Tensor from deepspeed import comm as dist from torch.nn import Module from torch.nn import Parameter from .linear import zero3_linear_wr...
Reverses the effects of :meth:`register_external_parameter`. Args: module (``torch.nn.Module``): The module to affect. parameter (``torch.nn.Parameter``): The parameter to unregister. Raises: RuntimeError: If ``parameter`` is not of type ``torch.nn.Parameter``. RuntimeError: If ``parameter`` is not a registered externa...
10,306
import math import os import types from typing import Callable, Iterable from enum import Enum import functools import itertools from typing import List import torch from torch import Tensor from deepspeed import comm as dist from torch.nn import Module from torch.nn import Parameter from .linear import zero3_linear_wr...
null
10,307
import math import os import types from typing import Callable, Iterable from enum import Enum import functools import itertools from typing import List import torch from torch import Tensor from deepspeed import comm as dist from torch.nn import Module from torch.nn import Parameter from .linear import zero3_linear_wr...
null
10,308
import math import os import types from typing import Callable, Iterable from enum import Enum import functools import itertools from typing import List import torch from torch import Tensor from deepspeed import comm as dist from torch.nn import Module from torch.nn import Parameter from .linear import zero3_linear_wr...
Free underlying storage of a parameter.
10,309
import math import os import types from typing import Callable, Iterable from enum import Enum import functools import itertools from typing import List import torch from torch import Tensor from deepspeed import comm as dist from torch.nn import Module from torch.nn import Parameter from .linear import zero3_linear_wr...
null
10,310
import torch import deepspeed from deepspeed.runtime.utils import partition_uniform as partition The provided code snippet includes necessary dependencies for implementing the `split_tensor_along_last_dim` function. Write a Python function `def split_tensor_along_last_dim(tensor, partitions, contiguous_split_chunks=Fa...
Split a tensor along its last dimension. Adapted from Megatron-LM. Arguments: tensor: input tensor. partitions: list of partition sizes to supply to torch.split contiguous_split_chunks: If True, make each chunk contiguous in memory.
10,311
import math import torch from torch import Tensor from torch.nn.parameter import Parameter from torch.nn import init from torch.nn.modules.module import Module from deepspeed.runtime.utils import noop_decorator from deepspeed import comm as dist def print_rank_0(message, debug=False, force=False): if dist.get_rank...
null
10,312
import math import torch from torch import Tensor from torch.nn.parameter import Parameter from torch.nn import init from torch.nn.modules.module import Module from deepspeed.runtime.utils import noop_decorator from deepspeed import comm as dist class LinearFunctionForZeroStage3(torch.autograd.Function): def forwa...
null
10,313
def to_python_float(t): if hasattr(t, 'item'): return t.item() return t[0]
null
10,314
import torch from deepspeed.utils.logging import logger from deepspeed import comm as dist def swap_in_tensors(swap_handle, tensor_buffers, swap_paths): for buffer, path in zip(tensor_buffers, swap_paths): assert (swap_handle.async_pread(buffer, path) == 0)
null
10,315
import torch from deepspeed.utils.logging import logger from deepspeed import comm as dist def swap_out_tensors(swap_handle, tensor_buffers, swap_paths): for buffer, path in zip(tensor_buffers, swap_paths): assert (swap_handle.async_pwrite(buffer, path) == 0)
null
10,316
import torch from deepspeed.utils.logging import logger from deepspeed import comm as dist logger = LoggerFactory.create_logger(name="DeepSpeed", level=logging.INFO) def print_object(obj, name, exclude_list=[]): logger.info('{}:'.format(name)) for arg in sorted(vars(obj)): if not arg in exclude_list: ...
null
10,317
import torch from deepspeed.utils.logging import logger from deepspeed import comm as dist def get_sized_buffer(buffer, num_elems): assert num_elems <= buffer.numel(), \ f'num_elems {num_elems} > buffer {buffer.numel()}' return buffer.narrow(0, 0, num_elems) if num_elems < buffer.numel() else buffer de...
null
10,318
from deepspeed.runtime.config_utils import get_scalar_param from deepspeed.runtime.swap_tensor.constants import * AIO_DEFAULT_DICT = { AIO_BLOCK_SIZE: AIO_BLOCK_SIZE_DEFAULT, AIO_QUEUE_DEPTH: AIO_QUEUE_DEPTH_DEFAULT, AIO_THREAD_COUNT: AIO_THREAD_COUNT_DEFAULT, AIO_SINGLE_SUBMIT: AIO_SINGLE_SUBMIT_DEFAUL...
null
10,319
import os import shutil from enum import Enum import torch from deepspeed import comm as dist from deepspeed.ops.aio import AsyncIOBuilder from .constants import * from .utils import swap_in_tensors, swap_out_tensors, MIN_AIO_BYTES, AIO_ALIGNED_BYTES, print_object, SwapBufferPool def print_rank_0(message, debug=False,...
null
10,320
import pickle import typing import torch from deepspeed import comm as dist from packaging.version import Version from deepspeed.git_version_info import torch_info _groups = None _grid = None def can_send_recv() -> bool: torch_version = Version(torch_info['version']) sendrecv_min = Version('1.8') return tor...
null
10,321
import pickle import typing import torch from deepspeed import comm as dist from packaging.version import Version from deepspeed.git_version_info import torch_info _async = [] def wait(): global _async for op in _async: op.wait() _async = [] torch.cuda.synchronize()
null
10,322
import pickle import typing import torch from deepspeed import comm as dist from packaging.version import Version from deepspeed.git_version_info import torch_info def send(tensor, dest_stage, async_op=False): global _groups assert async_op == False, "Doesn't support async_op true" src_stage = _grid.get_sta...
Send an arbitrary python object to ``dest``. Note: ``msg`` must be pickleable. WARN: This incurs a CPU -> GPU transfer and should be used sparingly for performance reasons. Args: msg (typing.Any): The object to send. dest (int): Destination rank.
10,323
import pickle import typing import torch from deepspeed import comm as dist from packaging.version import Version from deepspeed.git_version_info import torch_info def recv(tensor, src_stage, async_op=False): global _groups assert async_op == False, "Doesn't support async_op true" dest_stage = _grid.get_sta...
Receive an arbitrary python object from ``sender``. WARN: This incur a CPU <-> GPU transfers and should be used sparingly for performance reasons. Args: sender (int): The rank sending the message.
10,324
from ..utils import call_to_str from abc import ABC, abstractmethod def _is_even(x): return x % 2 == 0
null
10,325
from ..utils import call_to_str from abc import ABC, abstractmethod def _is_odd(x): return x % 2 != 0
null
10,326
from deepspeed import comm as dist from collections import namedtuple from itertools import product as cartesian_product The provided code snippet includes necessary dependencies for implementing the `_prime_factors` function. Write a Python function `def _prime_factors(N)` to solve the following problem: Returns the ...
Returns the prime factorization of positive integer N.
10,327
from types import MethodType import torch from deepspeed import comm as dist from deepspeed.utils import logger from deepspeed.utils.timer import ThroughputTimer from ..engine import DeepSpeedEngine, MEMORY_OPT_ALLREDUCE_SIZE from ..utils import PartitionedTensor from ..dataloader import RepeatingLoader from .module im...
null
10,328
from types import MethodType import torch from deepspeed import comm as dist from deepspeed.utils import logger from deepspeed.utils.timer import ThroughputTimer from ..engine import DeepSpeedEngine, MEMORY_OPT_ALLREDUCE_SIZE from ..utils import PartitionedTensor from ..dataloader import RepeatingLoader from .module im...
null
10,329
import os import torch import torch_nebula from deepspeed.runtime.checkpoint_engine.checkpoint_engine import \ CheckpointEngine from deepspeed.utils import logger, log_dist from deepspeed.nebula.constants import * def _get_tag_from_path(path): return os.path.basename(os.path.dirname(path))
null
10,330
import copy import torch import contextlib from deepspeed import comm as dist import mmap from torch import _C from torch.cuda import _lazy_call, device as device_ctx_manager from deepspeed.runtime.config import DeepSpeedConfig from deepspeed.utils import logger from deepspeed.runtime.utils import copy_to_device, move_...
null
10,331
import copy import torch import contextlib from deepspeed import comm as dist import mmap from torch import _C from torch.cuda import _lazy_call, device as device_ctx_manager from deepspeed.runtime.config import DeepSpeedConfig from deepspeed.utils import logger from deepspeed.runtime.utils import copy_to_device, move_...
Sets the random number generator state of the current GPU. Arguments: new_state (torch.ByteTensor): The desired state This function is adapted from PyTorch repo (torch.cuda.set_rng_state) with a single change: the input state is not cloned. Cloning caused major performance issues for +4 GPU cases.
10,332
import copy import torch import contextlib from deepspeed import comm as dist import mmap from torch import _C from torch.cuda import _lazy_call, device as device_ctx_manager from deepspeed.runtime.config import DeepSpeedConfig from deepspeed.utils import logger from deepspeed.runtime.utils import copy_to_device, move_...
Get cuda rng tracker.
10,333
import copy import torch import contextlib from deepspeed import comm as dist import mmap from torch import _C from torch.cuda import _lazy_call, device as device_ctx_manager from deepspeed.runtime.config import DeepSpeedConfig from deepspeed.utils import logger from deepspeed.runtime.utils import copy_to_device, move_...
Initialize model parallel cuda seed. This function should be called after the model parallel is initialized. Also, no torch.cuda.manual_seed should be called after this function. Basically, this is replacement for that function. Two set of RNG states are tracked: default state: This is for data parallelism and is the s...
10,334
import copy import torch import contextlib from deepspeed import comm as dist import mmap from torch import _C from torch.cuda import _lazy_call, device as device_ctx_manager from deepspeed.runtime.config import DeepSpeedConfig from deepspeed.utils import logger from deepspeed.runtime.utils import copy_to_device, move_...
null
10,335
import copy import torch import contextlib from deepspeed import comm as dist import mmap from torch import _C from torch.cuda import _lazy_call, device as device_ctx_manager from deepspeed.runtime.config import DeepSpeedConfig from deepspeed.utils import logger from deepspeed.runtime.utils import copy_to_device, move_...
Separate objects in list/tuple into tensors and non-tensors and create a mapping to enable re-aggregation. The order of tensors and non-tensors is preserved in their respective output groups. Parameters: all_objects (list/tuple): Objects containing tensors and non-tensors to be split. Returns: tuple: Containing tensors...
10,336
import copy import torch import contextlib from deepspeed import comm as dist import mmap from torch import _C from torch.cuda import _lazy_call, device as device_ctx_manager from deepspeed.runtime.config import DeepSpeedConfig from deepspeed.utils import logger from deepspeed.runtime.utils import copy_to_device, move_...
Merge two lists (or tuples) of tensors and non-tensors using a mapping of positions in merged list (or tuple). Parameters: tensor_objects (list/tuple): Tensors to merge. non_tensor_objects (list/tuple): Non-tensors to merge. tensor_flags (list/tuple): Indicates whether each position in output is a tensor. Returns: tupl...
10,337
import copy import torch import contextlib from deepspeed import comm as dist import mmap from torch import _C from torch.cuda import _lazy_call, device as device_ctx_manager from deepspeed.runtime.config import DeepSpeedConfig from deepspeed.utils import logger from deepspeed.runtime.utils import copy_to_device, move_...
null
10,338
import copy import torch import contextlib from deepspeed import comm as dist import mmap from torch import _C from torch.cuda import _lazy_call, device as device_ctx_manager from deepspeed.runtime.config import DeepSpeedConfig from deepspeed.utils import logger from deepspeed.runtime.utils import copy_to_device, move_...
null
10,339
import copy import torch import contextlib from deepspeed import comm as dist import mmap from torch import _C from torch.cuda import _lazy_call, device as device_ctx_manager from deepspeed.runtime.config import DeepSpeedConfig from deepspeed.utils import logger from deepspeed.runtime.utils import copy_to_device, move_...
Checkpoint a model or part of the model. This has been directly copied from torch.utils.checkpoint.
10,340
import copy import torch import contextlib from deepspeed import comm as dist import mmap from torch import _C from torch.cuda import _lazy_call, device as device_ctx_manager from deepspeed.runtime.config import DeepSpeedConfig from deepspeed.utils import logger from deepspeed.runtime.utils import copy_to_device, move_...
null
10,341
import copy import torch import contextlib from deepspeed import comm as dist import mmap from torch import _C from torch.cuda import _lazy_call, device as device_ctx_manager from deepspeed.runtime.config import DeepSpeedConfig from deepspeed.utils import logger from deepspeed.runtime.utils import copy_to_device, move_...
null
10,342
import copy import torch import contextlib from deepspeed import comm as dist import mmap from torch import _C from torch.cuda import _lazy_call, device as device_ctx_manager from deepspeed.runtime.config import DeepSpeedConfig from deepspeed.utils import logger from deepspeed.runtime.utils import copy_to_device, move_...
Configure DeepSpeed Activation Checkpointing. Arguments: mpu_: Optional: An object that implements the following methods get_model_parallel_rank/group/world_size, and get_data_parallel_rank/group/world_size deepspeed_config: Optional: DeepSpeed Config json file when provided will be used to configure DeepSpeed Activati...
10,343
import copy import torch import contextlib from deepspeed import comm as dist import mmap from torch import _C from torch.cuda import _lazy_call, device as device_ctx_manager from deepspeed.runtime.config import DeepSpeedConfig from deepspeed.utils import logger from deepspeed.runtime.utils import copy_to_device, move_...
True if deepspeed activation checkpointing has been configured by calling deepspeed.checkpointing.configure, else returns false Arguments: None Return: True of configured, else False
10,344
import os import re import stat import torch import hashlib from collections import defaultdict, OrderedDict from shutil import copyfile from torch.nn.modules import Module from torch.nn.parameter import Parameter from torch.optim import Optimizer from torch.optim.lr_scheduler import _LRScheduler from typing import Cal...
null
10,345
import os import re import stat import torch import hashlib from collections import defaultdict, OrderedDict from shutil import copyfile from torch.nn.modules import Module from torch.nn.parameter import Parameter from torch.optim import Optimizer from torch.optim.lr_scheduler import _LRScheduler from typing import Cal...
null
10,346
import re import collections.abc import os import json from deepspeed.runtime.constants import GRADIENT_ACCUMULATION_STEPS, TRAIN_MICRO_BATCH_SIZE_PER_GPU import itertools import copy from ..utils import logger def search_error(filename): if not os.path.exists(filename): return "stderr.log does not exist" ...
null
10,347
import re import collections.abc import os import json from deepspeed.runtime.constants import GRADIENT_ACCUMULATION_STEPS, TRAIN_MICRO_BATCH_SIZE_PER_GPU import itertools import copy from ..utils import logger def was_interruptted(filename): if not os.path.exists(filename): return "stderr.log does not exi...
null
10,348
import re import collections.abc import os import json from deepspeed.runtime.constants import GRADIENT_ACCUMULATION_STEPS, TRAIN_MICRO_BATCH_SIZE_PER_GPU import itertools import copy from ..utils import logger def find_replace_str(value, replace_dict): if not isinstance(value, str): return str(value) m...
null
10,349
import re import collections.abc import os import json from deepspeed.runtime.constants import GRADIENT_ACCUMULATION_STEPS, TRAIN_MICRO_BATCH_SIZE_PER_GPU import itertools import copy from ..utils import logger def get_list(val): if not isinstance(val, list): return [val] else: return val def c...
null
10,350
import re import collections.abc import os import json from deepspeed.runtime.constants import GRADIENT_ACCUMULATION_STEPS, TRAIN_MICRO_BATCH_SIZE_PER_GPU import itertools import copy from ..utils import logger def get_val_by_key(d: dict, k): if k in d: return d[k] for v in d.values(): if isins...
null
10,351
import re import collections.abc import os import json from deepspeed.runtime.constants import GRADIENT_ACCUMULATION_STEPS, TRAIN_MICRO_BATCH_SIZE_PER_GPU import itertools import copy from ..utils import logger def set_val_by_key(d: dict, k, vv): if k in d: d[k] = vv for v in d.values(): if isi...
null
10,352
import re import collections.abc import os import json from deepspeed.runtime.constants import GRADIENT_ACCUMULATION_STEPS, TRAIN_MICRO_BATCH_SIZE_PER_GPU import itertools import copy from ..utils import logger def fetch_hostfile(hostfile_path): if not os.path.isfile(hostfile_path): logger.warning("Unable ...
null
10,353
import re import collections.abc import os import json from deepspeed.runtime.constants import GRADIENT_ACCUMULATION_STEPS, TRAIN_MICRO_BATCH_SIZE_PER_GPU import itertools import copy from ..utils import logger def validate_ds_config(config: dict): def is_False(config: dict, key): if config is None: ...
null