repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
pytorch
pytorch-main/torch/_dynamo/debug_utils.py
import copy import functools import getpass import itertools import logging import os import subprocess import tempfile import textwrap from collections import Counter from importlib import import_module from typing import Callable, Optional, Sequence, TypeVar import torch import torch._prims_common as utils import to...
23,502
33.062319
115
py
pytorch
pytorch-main/torch/_dynamo/output_graph.py
import collections import contextlib import copy import functools import itertools import logging import operator import re import sys import traceback import weakref from dataclasses import dataclass from typing import Any, Dict, List, NamedTuple, Optional, OrderedDict, Set, Union import sympy import torch._guards ...
52,207
38.313253
120
py
pytorch
pytorch-main/torch/_dynamo/side_effects.py
import collections import inspect from typing import Any, Dict, List, Optional import torch.nn from . import utils, variables from .bytecode_transformation import ( create_call_function, create_call_method, create_instruction, ) from .codegen import PyCodegen from .exc import unimplemented from .source im...
17,094
36.654185
97
py
pytorch
pytorch-main/torch/_dynamo/decorators.py
from typing import TYPE_CHECKING import torch from . import allowed_functions from .eval_frame import DisableContext, innermost_fn, RunOnlyContext from .exc import IncorrectUsage if TYPE_CHECKING: from torch._C._dynamo.eval_frame import ( # noqa: F401 reset_code, set_eval_frame, set_guard...
8,559
30.470588
110
py
pytorch
pytorch-main/torch/_dynamo/test_case.py
import contextlib import importlib import sys import torch import torch.testing from torch.testing._internal.common_utils import ( IS_WINDOWS, TEST_WITH_CROSSREF, TEST_WITH_TORCHDYNAMO, TestCase as TorchTestCase, ) from . import config, reset, utils def run_tests(needs=()): from torch.testing._i...
1,503
21.787879
81
py
pytorch
pytorch-main/torch/_dynamo/backends/torchxla.py
import logging from ..backends.common import aot_autograd from ..backends.registry import register_experimental_backend as register_backend log = logging.getLogger(__name__) @register_backend def torchxla_trivial(gm, fake_tensor_inputs): return gm @register_backend def torchxla_trace_once(model, fake_tensor_i...
1,008
24.225
85
py
pytorch
pytorch-main/torch/_dynamo/backends/onnxrt.py
import importlib import logging import os import tempfile import torch from .common import device_from_inputs, fake_tensor_unsupported from .registry import register_backend try: import numpy as np _np_dtype = { torch.float16: np.float16, torch.float32: np.float32, torch.float64: np.f...
3,768
27.55303
88
py
pytorch
pytorch-main/torch/_dynamo/backends/cudagraphs.py
import logging import operator from collections import defaultdict from typing import Set import torch from torch.fx import GraphModule from torch.fx.passes.backends.cudagraphs import partition_cudagraphs from torch.multiprocessing.reductions import StorageWeakRef from torch.nn import Module from torch.utils._pytree ...
6,136
32.172973
83
py
pytorch
pytorch-main/torch/_dynamo/backends/tensorrt.py
# import torch # type: ignore[import] # from .common import device_from_inputs, fake_tensor_unsupported # type: ignore[import] # from .registry import register_backend # type: ignore[import] """ Placeholder for TensorRT backend for dynamo via torch-tensorrt """ # @register_backend # def tensorrt(gm, example_inputs...
383
28.538462
89
py
pytorch
pytorch-main/torch/_dynamo/backends/tvm.py
import functools import importlib import logging import os import tempfile import torch from .common import device_from_inputs, fake_tensor_unsupported from .registry import register_backend log = logging.getLogger(__name__) @register_backend @fake_tensor_unsupported def tvm(gm, example_inputs, *, scheduler=None, ...
6,360
36.19883
99
py
pytorch
pytorch-main/torch/_dynamo/backends/debugging.py
import dataclasses import functools from importlib import import_module from typing import Any, List, Optional from functorch.compile import min_cut_rematerialization_partition import torch from torch import _guards from torch._functorch.compilers import ts_compile from .common import aot_autograd from .registry impo...
9,376
31.559028
97
py
pytorch
pytorch-main/torch/_dynamo/backends/registry.py
import functools import sys from typing import Callable, Dict, List, Optional, Protocol, Sequence, Tuple import torch from torch import fx class CompiledFn(Protocol): def __call__(self, *args: torch.Tensor) -> Tuple[torch.Tensor, ...]: ... CompilerFn = Callable[[fx.GraphModule, List[torch.Tensor]], Com...
3,429
29.087719
87
py
pytorch
pytorch-main/torch/_dynamo/backends/inductor.py
from torch._dynamo import register_backend @register_backend def inductor(*args, **kwargs): # do import here to avoid loading inductor into memory when it is not used from torch._inductor.compile_fx import compile_fx return compile_fx(*args, **kwargs)
267
25.8
78
py
pytorch
pytorch-main/torch/_dynamo/backends/nvfuser.py
import logging from functools import partial import torch from ..backends.common import aot_autograd, mem_efficient_fusion_kwargs from .registry import register_backend, register_debug_backend log = logging.getLogger(__name__) def prims_executor(gm, inputs, *, executor): from functorch.compile import make_boxed...
3,933
39.979167
88
py
pytorch
pytorch-main/torch/_dynamo/backends/common.py
import contextlib import functools import logging from unittest.mock import patch import torch from torch._dynamo import disable from torch._dynamo.utils import counters, defake from torch._functorch.aot_autograd import aot_module_simplified from torch.utils._python_dispatch import _disable_current_modes log = loggin...
3,342
29.390909
85
py
pytorch
pytorch-main/torch/_dynamo/backends/distributed.py
import logging import traceback from dataclasses import dataclass, field from typing import Any, List, Optional import torch from torch import fx from torch._dynamo.output_graph import GraphCompileReason from torch._dynamo.utils import deepcopy_to_fake_tensor, detect_fake_mode from torch.fx.node import Node log = log...
21,281
47.040632
120
py
pytorch
pytorch-main/torch/_dynamo/variables/builtin.py
import functools import inspect import itertools import logging import math import operator import types from typing import Dict, List import torch from torch import sym_float, sym_int from .. import config, variables from ..allowed_functions import is_allowed from ..exc import ( AttributeMutationError, unimp...
51,603
35.992115
98
py
pytorch
pytorch-main/torch/_dynamo/variables/torch.py
import collections import inspect import logging import math import re import types from typing import Dict, List import torch._C import torch.fx import torch.nn import torch.onnx.operators from torch._dynamo.variables import UserFunctionVariable from torch._dynamo.variables.user_defined import ProcessGroupVariable ...
30,719
37.836915
117
py
pytorch
pytorch-main/torch/_dynamo/variables/constant.py
import operator from typing import Dict, List import torch from .. import variables from ..exc import unimplemented from ..utils import HAS_NUMPY, istype, np from .base import typestr, VariableTracker class ConstantVariable(VariableTracker): def __init__(self, value, **kwargs): super().__init__(**kwargs...
5,617
33.048485
88
py
pytorch
pytorch-main/torch/_dynamo/variables/higher_order_ops.py
import contextlib import logging from typing import Dict, List, Optional import torch._C import torch.fx import torch.nn import torch.onnx.operators from torch._dynamo.utils import deepcopy_to_fake_tensor, get_fake_value, get_real_value from torch._dynamo.variables.base import VariableTracker from torch._dynamo.varia...
32,709
34.748634
108
py
pytorch
pytorch-main/torch/_dynamo/variables/functions.py
import abc import dataclasses import enum import functools import inspect import itertools import types from typing import Dict, List import torch from .. import variables from ..allowed_functions import is_allowed, is_builtin_callable from ..bytecode_transformation import create_call_function, create_rot_n from ..ex...
22,284
35.713344
106
py
pytorch
pytorch-main/torch/_dynamo/variables/misc.py
import collections import functools import inspect import itertools import sys import types from typing import Dict, List import torch._C from .. import config, variables from ..bytecode_transformation import create_call_function, create_instruction from ..exc import unimplemented from ..source import AttrSource, ODic...
33,918
36.856027
119
py
pytorch
pytorch-main/torch/_dynamo/variables/lists.py
import collections import dataclasses import functools import inspect import operator from typing import Any, Dict, List, Optional, Tuple import torch import torch.fx from torch.utils import _pytree as pytree from .. import variables from ..bytecode_transformation import create_call_function, create_instruction from ...
30,268
33.553653
105
py
pytorch
pytorch-main/torch/_dynamo/variables/nn_module.py
import functools import inspect import itertools import types from contextlib import contextmanager from typing import Dict, List import torch.nn from .. import skipfiles, variables from ..allowed_functions import is_allowed from ..exc import RestartAnalysis, unimplemented, Unsupported from ..guards import GuardBuild...
31,835
38.498759
123
py
pytorch
pytorch-main/torch/_dynamo/variables/dicts.py
import collections import dataclasses import functools import inspect from typing import Any, Dict, List, Tuple import torch from torch.utils import _pytree as pytree from .. import variables from ..bytecode_transformation import create_call_function, create_instruction from ..eval_frame import skip_code from ..exc ...
17,767
34.822581
111
py
pytorch
pytorch-main/torch/_dynamo/variables/__init__.py
from .base import VariableTracker from .builtin import BuiltinVariable from .constant import ConstantVariable, EnumVariable from .ctx_manager import ( ContextWrappingVariable, CUDAStreamContextVariable, CUDAStreamVariable, DeterministicAlgorithmsVariable, GradModeVariable, WithExitFunctionVariab...
2,569
24.7
77
py
pytorch
pytorch-main/torch/_dynamo/variables/user_defined.py
import collections import contextlib import functools import importlib import inspect import itertools import random import threading import types from typing import Dict, List import torch.nn from .. import variables from ..allowed_functions import is_allowed from ..exc import unimplemented from ..guards import Guar...
23,822
37.486268
97
py
pytorch
pytorch-main/torch/_dynamo/variables/ctx_manager.py
import inspect from typing import Dict, List import torch._C from torch._guards import Guard, GuardSource from .. import variables from ..bytecode_transformation import create_call_function, create_instruction from ..exc import unimplemented from ..guards import GuardBuilder from ..source import AttrSource from .base...
14,090
32.155294
96
py
pytorch
pytorch-main/torch/_dynamo/variables/builder.py
import collections import contextlib import dataclasses import enum import functools import inspect import logging import operator import re import types from typing import List, NamedTuple, Optional, Union import torch from torch import SymInt from torch._guards import GuardSource, TracingContext from torch._ops imp...
60,752
39.074538
130
py
pytorch
pytorch-main/torch/_dynamo/variables/tensor.py
import inspect import operator import types from typing import Dict, List import sympy import torch.fx import torch.random from torch.fx.experimental.symbolic_shapes import free_symbols, guard_scalar, SymTypes from .. import config, variables from ..exc import unimplemented from ..guards import GuardBuilder from ....
37,073
36.600406
119
py
pytorch
pytorch-main/torch/_dynamo/variables/optimizer.py
from typing import Dict, List import torch from ..guards import GuardBuilder from ..source import AttrSource, GetItemSource, GlobalWeakRefSource from ..utils import global_key_name from .base import MutableLocal, VariableTracker from .constant import ConstantVariable from .dicts import ConstDictVariable from .lists ...
6,066
36.450617
99
py
pytorch
pytorch-main/torch/_dynamo/repro/after_dynamo.py
import argparse import copy import functools import logging import os import shutil import sys import textwrap from importlib import import_module from typing import Union import torch import torch.fx as fx from torch._dynamo.debug_utils import ( AccuracyError, backend_accuracy_fails, BUCK_CMD_PREFIX, ...
18,933
32.393298
118
py
pytorch
pytorch-main/torch/_dynamo/repro/after_aot.py
import argparse import copy import functools import io import logging import os import shutil import subprocess import sys import textwrap import uuid from importlib import import_module from tempfile import TemporaryFile from typing import Any, Callable, Dict, Union import torch import torch.fx as fx import torch.nn ...
31,864
33.337284
105
py
pytorch
pytorch-main/torch/distributed/collective_utils.py
#!/usr/bin/env python3 """ A set of primitive functions for performing collective ops. Each should also handle single rank scenario. """ from __future__ import annotations from dataclasses import dataclass from typing import Any, Callable, cast, Generic, List, Optional, Tuple, TypeVar, Union import torch.distribu...
7,250
33.20283
93
py
pytorch
pytorch-main/torch/distributed/constants.py
from torch._C._distributed_c10d import _DEFAULT_PG_TIMEOUT # Default process group wide timeout, if applicable. # This only applies to the gloo and nccl backends # (only if NCCL_BLOCKING_WAIT or NCCL_ASYNC_ERROR_HANDLING is set to 1). # To make an attempt at backwards compatibility with THD, we use an # extraordinarily...
422
51.875
77
py
pytorch
pytorch-main/torch/distributed/_functional_collectives.py
import warnings import sys import torch import torch.distributed as dist import torch.distributed.distributed_c10d as c10d from typing import Tuple, Union, List, cast, TYPE_CHECKING from torch.utils._pytree import tree_map_only from . import _functional_collectives_impl as fun_col_impl from ._functional_collectives_imp...
23,264
41.531993
149
py
pytorch
pytorch-main/torch/distributed/utils.py
import dataclasses import traceback from typing import Any, Callable, Container, Dict, List, Optional, OrderedDict, Tuple, TypeVar, overload import torch import torch.distributed as dist from torch import nn from torch.nn.parallel._functions import _get_stream from torch.nn.parallel.scatter_gather import _is_namedtupl...
12,036
35.147147
118
py
pytorch
pytorch-main/torch/distributed/run.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ ``torchrun`` provides a superset of the functionality as ``torch.distributed.launch``...
29,646
35.966334
119
py
pytorch
pytorch-main/torch/distributed/rendezvous.py
try: from urllib.parse import urlparse, urlunparse except ImportError as e: raise ImportError( "urllib cannot be found, urlparse from python2 is no longer supported." ) from e import numbers import os import sys from datetime import timedelta from typing import Dict, Optional from torch.distribute...
9,105
34.570313
102
py
pytorch
pytorch-main/torch/distributed/launch.py
r""" ``torch.distributed.launch`` is a module that spawns up multiple distributed training processes on each of the training nodes. .. warning:: This module is going to be deprecated in favor of :ref:`torchrun <launcher-api>`. The utility can be used for single-node distributed training, in which one or more pro...
6,871
33.883249
88
py
pytorch
pytorch-main/torch/distributed/_functional_collectives_impl.py
import warnings import weakref import torch import torch.distributed as dist import torch.distributed.distributed_c10d as c10d from typing import List, cast """ Moved eager kernel implementations to a separate file partly for readability and partly as it is currently easier in dynamo to set tracing policy on a file-by...
8,899
34.6
115
py
pytorch
pytorch-main/torch/distributed/c10d_logger.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import functools import logging import time from typing import List, Tuple from torch.di...
3,145
31.102041
107
py
pytorch
pytorch-main/torch/distributed/__init__.py
import os import sys from enum import Enum import torch def is_available() -> bool: """ Returns ``True`` if the distributed package is available. Otherwise, ``torch.distributed`` does not expose any other APIs. Currently, ``torch.distributed`` is available on Linux, MacOS and Windows. Set ``USE_DI...
2,685
27.574468
99
py
pytorch
pytorch-main/torch/distributed/_composable_state.py
from typing import cast, Dict, Optional import torch.nn as nn class _State: pass _module_state_mapping: Dict[nn.Module, _State] = {} def _insert_module_state(module: nn.Module, state: _State) -> None: global _module_state_mapping assert module not in _module_state_mapping, f"Inserting {module} more t...
949
27.787879
85
py
pytorch
pytorch-main/torch/distributed/distributed_c10d.py
import itertools import collections.abc import contextlib import hashlib import io import logging import os import pickle import time import warnings from collections import namedtuple from datetime import timedelta from typing import Any, Callable, Dict, Optional, Tuple, Union, List import torch from torch._C._distri...
169,730
38.842958
131
py
pytorch
pytorch-main/torch/distributed/remote_device.py
from typing import Optional, Union import torch class _remote_device: """ Represents a device on a remote worker. Args: remote_device (str or torch.device): Represents a device on a remote worker. The string format should be one of the following: 1. "<workername>/<de...
4,734
34.335821
102
py
pytorch
pytorch-main/torch/distributed/nn/functional.py
import torch import torch.distributed as dist from torch.autograd import Function # The two imports below are not always available depending on the # USE_DISTRIBUTED compile flag. Make sure they raise import error # if we're trying to use them. from torch.distributed import group, ReduceOp def broadcast(tensor, src, g...
15,044
32.961625
110
py
pytorch
pytorch-main/torch/distributed/nn/__init__.py
import torch if torch.distributed.rpc.is_available(): from .api.remote_module import RemoteModule from .functional import * # noqa: F403
142
27.6
47
py
pytorch
pytorch-main/torch/distributed/nn/api/remote_module.py
#!/usr/bin/python3 import collections import io import sys import types from typing import ( Any, Callable, Dict, Iterator, List, Mapping, Optional, Set, Tuple, Type, TypeVar, Union, ) import torch import torch.distributed.rpc as rpc from torch import Tensor, device, dty...
31,435
39.458172
132
py
pytorch
pytorch-main/torch/distributed/nn/jit/instantiator.py
#!/usr/bin/python3 import importlib import logging import os import sys import tempfile from typing import Optional import torch from torch.distributed.nn.jit.templates.remote_module_template import ( get_remote_module_template, ) logger = logging.getLogger(__name__) _FILE_PREFIX = "_remote_module_" _TEMP_DIR ...
5,546
34.107595
94
py
pytorch
pytorch-main/torch/distributed/nn/jit/templates/remote_module_template.py
#!/usr/bin/python3 def get_remote_module_template(enable_moving_cpu_tensors_to_cuda: bool): return _TEMPLATE_PREFIX + ( _REMOTE_FORWARD_TEMPLATE_ENABLE_MOVING_CPU_TENSORS_TO_CUDA if enable_moving_cpu_tensors_to_cuda else _REMOTE_FORWARD_TEMPLATE ) _TEMPLATE_PREFIX = """from typing im...
3,436
30.824074
119
py
pytorch
pytorch-main/torch/distributed/elastic/__init__.py
#!/usr/bin/env/python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ Torchelastic agent and user worker failover contract: **TL;DR;**: * TE(torchelasti...
3,654
45.858974
99
py
pytorch
pytorch-main/torch/distributed/elastic/events/api.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import json from dataclasses import asdict, dataclass, field from enum import Enum from t...
3,172
26.353448
79
py
pytorch
pytorch-main/torch/distributed/elastic/events/__init__.py
#!/usr/bin/env/python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ Module contains events processing mechanisms that are integrated with the standard py...
3,933
28.358209
98
py
pytorch
pytorch-main/torch/distributed/elastic/multiprocessing/api.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import abc import logging import os import re import signal import subprocess import sys ...
25,859
34.619835
113
py
pytorch
pytorch-main/torch/distributed/elastic/multiprocessing/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ Library that launches and manages ``n`` copies of worker subprocesses either specifie...
9,470
32.704626
97
py
pytorch
pytorch-main/torch/distributed/elastic/multiprocessing/errors/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ Each host in a distributed PyTorch job runs with a single TorchElastic agent, and mul...
13,741
36.342391
109
py
pytorch
pytorch-main/torch/distributed/elastic/multiprocessing/errors/handlers.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. # Multiprocessing error-reporting module from torch.distributed.elastic.multiprocessing....
446
25.294118
87
py
pytorch
pytorch-main/torch/distributed/elastic/metrics/api.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import abc import time import warnings from collections import namedtuple from functools ...
5,618
25.630332
110
py
pytorch
pytorch-main/torch/distributed/elastic/metrics/__init__.py
#!/usr/bin/env/python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """Metrics API **Overview**: The metrics API in torchelastic is used to publish telemet...
4,852
28.591463
105
py
pytorch
pytorch-main/torch/distributed/elastic/timer/file_based_local_timer.py
# Copyright (c) Meta Platforms, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import io import json import logging import os import select import signal import sys import threading impo...
13,482
39.368263
116
py
pytorch
pytorch-main/torch/distributed/elastic/timer/api.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import abc import logging import threading import time from contextlib import contextmanager from inspect import g...
9,628
33.14539
96
py
pytorch
pytorch-main/torch/distributed/elastic/timer/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ Expiration timers are set up on the same process as the agent and used from your script to deal with stuck wo...
1,708
36.977778
100
py
pytorch
pytorch-main/torch/distributed/elastic/utils/log_level.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. def get_log_level() -> str: """ Return default log level for pytorch. """ ...
339
21.666667
71
py
pytorch
pytorch-main/torch/distributed/elastic/utils/logging.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import inspect import logging import os import warnings from typing import Optional from...
2,226
30.814286
99
py
pytorch
pytorch-main/torch/distributed/elastic/utils/api.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import os import socket from string import Template from typing import List, Any def ge...
1,716
26.253968
85
py
pytorch
pytorch-main/torch/distributed/elastic/utils/distributed.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import datetime import socket from contextlib import closing import torch.distributed as ...
4,639
31
120
py
pytorch
pytorch-main/torch/distributed/elastic/utils/store.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from datetime import timedelta from typing import List def get_all(store, rank: int, pr...
2,511
30.797468
90
py
pytorch
pytorch-main/torch/distributed/elastic/utils/data/elastic_distributed_sampler.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import math import torch from torch.utils.data.distributed import DistributedSampler c...
2,504
33.315068
112
py
pytorch
pytorch-main/torch/distributed/elastic/agent/server/local_elastic_agent.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import json import os import shutil import signal import socket import tempfile import u...
13,446
39.625378
116
py
pytorch
pytorch-main/torch/distributed/elastic/agent/server/api.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import abc import functools import json import os import signal import socket import time...
36,467
37.226415
115
py
pytorch
pytorch-main/torch/distributed/elastic/agent/server/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ The elastic agent is the control plane of torchelastic. It is a process that launches...
1,400
33.170732
88
py
pytorch
pytorch-main/torch/distributed/elastic/rendezvous/c10d_rendezvous_backend.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import binascii import logging import os import tempfile from base64 import b64decode, b64encode from datetime im...
10,657
39.218868
99
py
pytorch
pytorch-main/torch/distributed/elastic/rendezvous/static_tcp_rendezvous.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import datetime import logging from typing import Tuple, cast, Op...
3,310
29.376147
88
py
pytorch
pytorch-main/torch/distributed/elastic/rendezvous/etcd_rendezvous_backend.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import binascii from base64 import b64decode, b64encode from typing import Optional, Tuple, cast import urllib3....
7,412
33.47907
98
py
pytorch
pytorch-main/torch/distributed/elastic/rendezvous/registry.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from .api import RendezvousHandler, RendezvousParameters from .api import rendezvous_handler_registry as handler_...
2,255
33.181818
92
py
pytorch
pytorch-main/torch/distributed/elastic/rendezvous/api.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from abc import ABC, abstractmethod from typing import Any, Callable, Dict, Optional, Tuple from torch.distribut...
9,181
32.6337
100
py
pytorch
pytorch-main/torch/distributed/elastic/rendezvous/etcd_store.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import datetime import random import time from base64 import b64decode, b64encode from typing import Optional im...
6,943
33.039216
110
py
pytorch
pytorch-main/torch/distributed/elastic/rendezvous/dynamic_rendezvous.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import inspect import logging import os import pickle import socket import threading import time import weakref f...
41,089
31.767145
120
py
pytorch
pytorch-main/torch/distributed/elastic/rendezvous/etcd_rendezvous.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import json import logging import sys import threading import tim...
42,854
39.014006
108
py
pytorch
pytorch-main/torch/distributed/elastic/rendezvous/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ In the context of Torch Distributed Elastic we use the term *rendezvous* to refer to a particular functionali...
5,816
37.78
80
py
pytorch
pytorch-main/torch/distributed/elastic/rendezvous/etcd_server.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import atexit import logging import os import shlex import shutil import socket import sub...
8,520
31.276515
87
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/copy.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """Autograd functions for stream-aware CUDA copy. It is used to overlap copy and computatio...
3,741
33.648148
108
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/checkpoint.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """Checkpointing with preceding recomputation. PyTorch already provides the official check...
11,573
31.15
116
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/stream.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """Utilities for eliminating boilerplate code to handle abstract streams with CPU device. "...
4,019
32.22314
95
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/batchnorm.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """Tracks the running statistics per mini-batch instead of micro-batch.""" from typing impo...
5,583
33.257669
118
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/dependency.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """Arbitrary dependency between two autograd lanes.""" from typing import List, Tuple impo...
1,724
30.363636
105
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/pipe.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """The Pipe interface.""" from collections import OrderedDict from typing import TYPE_CHECK...
18,105
35.875764
114
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/utils.py
from torch import nn from typing import List, Optional __all__ = ["partition_model"] def partition_model( module: nn.Sequential, balance: List[int], devices: Optional[List[int]] = None): """ Given an :class:`nn.Sequential <torch.nn.Sequential>` module, partitions the model across m...
1,198
31.405405
77
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/microbatch.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """Manipulation of micro-batches.""" import typing from typing import Any, Callable, List, ...
7,481
30.838298
124
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/pipeline.py
# -*- coding: utf-8 -*- # Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """The pipeline parallelism of Pipe.""" from queue import Queue fro...
9,210
34.563707
117
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/worker.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """Multithreading in pipeline parallelism.""" from contextlib import contextmanager from qu...
4,335
31.601504
117
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/phony.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """Provides phony for arbitrary dependency in a autograd graph.""" from typing import Dict,...
1,547
29.96
80
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/_balance/profile.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """Per-layer profilers.""" import copy import time from typing import Any, Generator, List,...
3,641
30.128205
127
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/_balance/__init__.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """A helper to roughly balance a sequential module. Usage:: import torch from tor...
5,316
31.224242
83
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/skip/tracker.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """Tracks skip tensors on a thread.""" from contextlib import contextmanager import threadi...
6,164
33.060773
111
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/skip/namespace.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """Provides isolated namespace of skip tensors.""" import abc from functools import total_o...
1,462
27.686275
78
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/skip/portal.py
# -*- coding: utf-8 -*- # Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """Portal keeps a tensor in the pocket plane. The tensor becomes hi...
7,249
30.11588
110
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/skip/layout.py
# Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """Static skip connection layout of ``@skippable`` modules.""" from typing import Dict, Ite...
3,350
35.032258
112
py
pytorch
pytorch-main/torch/distributed/pipeline/sync/skip/skippable.py
# -*- coding: utf-8 -*- # Copyright 2019 Kakao Brain # # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. """The user interface to define skip connections.""" from typing im...
13,833
31.172093
112
py