python_code
stringlengths
0
679k
repo_name
stringlengths
9
41
file_path
stringlengths
6
149
import torch from torch.optim.optimizer import Optimizer, required from apex.multi_tensor_apply import multi_tensor_applier class FusedSGD(Optimizer): r"""Implements stochastic gradient descent (optionally with momentum). Currently GPU-only. Requires Apex to be installed via ``pip install -v --no-cache-...
apex-master
apex/optimizers/fused_sgd.py
import types from ..fp16_utils import master_params_to_model_params from ..multi_tensor_apply import multi_tensor_applier from ._amp_state import maybe_print import torch from ..optimizers import FusedSGD class AmpOptimizerState(object): def __init__(self): pass def _master_params_to_model_params(self):...
apex-master
apex/amp/_process_optimizer.py
import torch # True for post-0.4, when Variables/Tensors merged. def variable_is_tensor(): v = torch.autograd.Variable() return isinstance(v, torch.Tensor) def tensor_is_variable(): x = torch.Tensor() return type(x) == torch.autograd.Variable # False for post-0.4 def tensor_is_float_tensor(): x =...
apex-master
apex/amp/compat.py
import contextlib import warnings import sys import torch from . import utils from .opt import OptimWrapper from .scaler import LossScaler from ._amp_state import _amp_state, master_params, maybe_print if torch.distributed.is_available(): from ..parallel.LARC import LARC # There's no reason to expose the notion...
apex-master
apex/amp/handle.py
import collections.abc as container_abcs from types import MethodType import functools import sys import warnings import numpy as np import torch from ._amp_state import _amp_state, warn_or_err from .handle import disable_casts from .scaler import LossScaler from ._process_optimizer import _process_optimizer from ape...
apex-master
apex/amp/_initialize.py
import functools import itertools import torch from . import compat, rnn_compat, utils, wrap from .handle import AmpHandle, NoOpHandle from .lists import functional_overrides, torch_overrides, tensor_overrides from ._amp_state import _amp_state from .frontend import * _DECORATOR_HANDLE = None _USER_CAST_REGISTRY = ...
apex-master
apex/amp/amp.py
from collections import OrderedDict import torch from ._initialize import _initialize from ._amp_state import _amp_state, warn_or_err, maybe_print class Properties(object): """ This class has two purposes: to establish a set of default properties, and to route setting of these attributes through __setat...
apex-master
apex/amp/frontend.py
from .amp import init, half_function, float_function, promote_function,\ register_half_function, register_float_function, register_promote_function from .handle import scale_loss, disable_casts from .frontend import initialize, state_dict, load_state_dict from ._amp_state import master_params, _amp_state
apex-master
apex/amp/__init__.py
import torch from ..multi_tensor_apply import multi_tensor_applier from ._amp_state import _amp_state, master_params, maybe_print from itertools import product def scale_check_overflow_python(model_grad, master_grad, scale, check_overflow=False): # Exception handling for 18.04 compatibility if check_overflow: ...
apex-master
apex/amp/scaler.py
VERSION = (0, 1, 0) __version__ = '.'.join(map(str, VERSION))
apex-master
apex/amp/__version__.py
import contextlib import warnings from .scaler import LossScaler, master_params from ._amp_state import maybe_print import numpy as np class OptimWrapper(object): def __init__(self, optimizer, amp_handle, num_loss): self._optimizer = optimizer self._amp_handle = amp_handle self._num_loss ...
apex-master
apex/amp/opt.py
# This is a "header object" that allows different amp modules to communicate. # I'm a C++ guy, not a python guy. I decided this approach because it seemed most C++-like. # But apparently it's ok: # http://effbot.org/pyfaq/how-do-i-share-global-variables-across-modules.htm import torch class AmpState(object): def...
apex-master
apex/amp/_amp_state.py
from . import compat import functools import itertools import torch def is_cuda_enabled(): return torch.version.cuda is not None def get_cuda_version(): return tuple(int(x) for x in torch.version.cuda.split('.')) def is_fp_tensor(x): if is_nested(x): # Fast-fail version of all(is_fp_tensor) ...
apex-master
apex/amp/utils.py
from . import compat from . import utils from ._amp_state import _amp_state from . import rnn_compat import functools import torch def make_cast_wrapper(orig_fn, cast_fn, handle, try_caching=False): @functools.wraps(orig_fn) def wrapper(*args, **kwargs): if not handle.is_active(...
apex-master
apex/amp/wrap.py
from . import utils, wrap import torch _VF = torch._C._VariableFunctions RNN_NAMES = ['rnn_relu', 'rnn_tanh', 'gru', 'lstm'] def _gen_VF_wrapper(name): def wrapper(*args, **kwargs): return getattr(_VF, name)(*args, **kwargs) return wrapper # Some python magic to generate an object that has the rnn ce...
apex-master
apex/amp/rnn_compat.py
apex-master
apex/amp/lists/__init__.py
import torch from .. import utils MODULE = torch FP16_FUNCS = [ # Low level functions wrapped by torch.nn layers. # The wrapper layers contain the weights which are then passed in as a parameter # to these functions. 'conv1d', 'conv2d', 'conv3d', 'conv_transpose1d', 'conv_transpose2d'...
apex-master
apex/amp/lists/torch_overrides.py
# TODO: think about the following two. They do weird things. # - torch.nn.utils.clip_grad (but it should always be fp32 anyway) # - torch.nn.utils.weight_norm # Notes: # F.instance_norm uses batch_norm internally. Which correctly handles # fp16 in/out with fp32 weights. So we shouldn't do anything for # either of...
apex-master
apex/amp/lists/functional_overrides.py
from .. import compat from . import torch_overrides import importlib import torch # if compat.variable_is_tensor() and not compat.tensor_is_variable(): MODULE = torch.Tensor # else: # MODULE = torch.autograd.Variable FP16_FUNCS = compat.filter_attrs(MODULE, [ '__matmul__', ]) FP32_FUNCS = compat.filter_at...
apex-master
apex/amp/lists/tensor_overrides.py
import torch import torch.nn as nn from torch.autograd import Variable import torch.nn.functional as F import math def is_iterable(maybe_iterable): return isinstance(maybe_iterable, list) or isinstance(maybe_iterable, tuple) def flatten_list(tens_list): """ flatten_list """ if not is_iterable(...
apex-master
apex/RNN/RNNBackend.py
import torch from torch.nn._functions.rnn import LSTMCell, RNNReLUCell, RNNTanhCell, GRUCell from apex import deprecated_warning from .RNNBackend import bidirectionalRNN, stackedRNN, RNNCell from .cells import mLSTMRNNCell, mLSTMCell def toRNNBackend(inputRNN, num_layers, bidirectional=False, dropout = 0): """ ...
apex-master
apex/RNN/models.py
from .models import LSTM, GRU, ReLU, Tanh, mLSTM __all__ = ['models']
apex-master
apex/RNN/__init__.py
import torch import torch.nn as nn import torch.nn.functional as F from .RNNBackend import RNNCell from torch.nn._functions.thnn import rnnFusedPointwise as fusedBackend import math class mLSTMRNNCell(RNNCell): """ mLSTMRNNCell """ def __init__(self, input_size, hidden_size, bias = False, output_...
apex-master
apex/RNN/cells.py
from .mlp import *
apex-master
apex/mlp/__init__.py
from copy import copy import math import torch from torch import nn from apex._autocast_utils import _cast_if_autocast_enabled import mlp_cuda class MlpFunction(torch.autograd.Function): @staticmethod def forward(ctx, bias, activation, *args): output = mlp_cuda.forward(bias, activation, args) ...
apex-master
apex/mlp/mlp.py
import torch import torch.distributed as dist from torch.nn import Parameter from torch.nn import Module from apex.parallel import DistributedDataParallel as DDP import argparse import os parser = argparse.ArgumentParser(description='allreduce hook example') parser.add_argument("--local_rank", default=0, type=int) ar...
apex-master
tests/distributed/DDP/ddp_race_condition_test.py
import torch import argparse import os from apex import amp # FOR DISTRIBUTED: (can also use torch.nn.parallel.DistributedDataParallel instead) from apex.parallel import DistributedDataParallel parser = argparse.ArgumentParser() # FOR DISTRIBUTED: Parse for the local_rank argument, which will be supplied # automatica...
apex-master
tests/distributed/amp_master_params/amp_master_params.py
import torch model_params_rank0 = torch.load("rank0model.pth", map_location = lambda storage, loc: storage.cuda(0)) model_params_rank1 = torch.load("rank1model.pth", map_location = lambda storage, loc: storage.cuda(0)) master_params_rank0 = torch.load("rank0m...
apex-master
tests/distributed/amp_master_params/compare.py
import torch import apex model = apex.parallel.SyncBatchNorm(4).cuda() model.weight.data.uniform_() model.bias.data.uniform_() data = torch.rand((8,4)).cuda() model_ref = torch.nn.BatchNorm1d(4).cuda() model_ref.load_state_dict(model.state_dict()) data_ref = data.clone() output = model(data) output_ref = model_ref(d...
apex-master
tests/distributed/synced_batchnorm/test_batchnorm1d.py
import torch import numpy as np import apex import syncbn import os import argparse import torch.optim as optim def compare(desc, inp1, inp2, error): a = inp1.clone().detach().cpu().numpy() b = inp2.clone().detach().cpu().numpy() close = np.allclose(a,b, error, error) if not close: print(desc, ...
apex-master
tests/distributed/synced_batchnorm/two_gpu_unit_test.py
import torch import torch.nn as nn from torch.nn.parallel import DistributedDataParallel as DDP from apex.parallel import SyncBatchNorm as ApexSyncBatchNorm import argparse import os import numpy as np var_batch = 16 def compare(desc, inp1, inp2, error= 1e-5): a = inp1.clone().detach().cpu().numpy() b = inp2...
apex-master
tests/distributed/synced_batchnorm/two_gpu_test_different_batch_size.py
import torch import numpy as np import apex if True: print("using setup tools") import syncbn else: print("using jit") from torch.utils.cpp_extension import load syncbn = load(name='syncbn', sources=['../../csrc/syncbn.cpp', '../../csrc/welford.cu']) def compare(desc, inp1, inp2, error): a = in...
apex-master
tests/distributed/synced_batchnorm/single_gpu_unit_test.py
import torch import numpy as np import apex import syncbn import os import argparse import torch.optim as optim def compare(desc, inp1, inp2, error): a = inp1.clone().detach().cpu().numpy() b = inp2.clone().detach().cpu().numpy() close = np.allclose(a,b, error, error) if not close: print(desc, ...
apex-master
tests/distributed/synced_batchnorm/test_groups.py
import torch import numpy as np import apex def compare(desc, inp1, inp2, error): a = inp1.clone().detach().cpu().numpy() b = inp2.clone().detach().cpu().numpy() close = np.allclose(a,b, error, error) if not close: print(desc, close) z = a - b index = (np.abs(z) >= error + error...
apex-master
tests/distributed/synced_batchnorm/python_single_gpu_unit_test.py
"""L0 Tests Runner. How to run this script? 1. Run all the tests: `python /path/to/apex/tests/L0/run_test.py` If you want an xml report, pass `--xml-report`, i.e. `python /path/to/apex/tests/L0/run_test.py --xml-report` and the file is created in `/path/to/apex/tests/L0`. 2. Run one of the tests (e.g. fused l...
apex-master
tests/L0/run_test.py
import torch from apex.normalization import FusedLayerNorm from apex.normalization import FusedRMSNorm from apex.normalization import MixedFusedLayerNorm from apex.normalization import MixedFusedRMSNorm from torch.testing._internal import common_utils from torch.testing._internal.common_device_type import instantiate_...
apex-master
tests/L0/run_fused_layer_norm/test_fused_layer_norm.py
import unittest import os import torch from torch.optim import Optimizer import apex from apex.multi_tensor_apply import multi_tensor_applier from itertools import product class RefLAMB(Optimizer): r"""Implements Lamb algorithm. It has been proposed in `Large Batch Optimization for Deep Learning: Training BE...
apex-master
tests/L0/run_optimizers/test_lamb.py
apex-master
tests/L0/run_optimizers/__init__.py
import copy import math import random import unittest import torch import torch.nn.functional as F from torch import nn try: import apex except ImportError as e: HAS_APEX = False else: HAS_APEX = True class Model(torch.nn.Module): def __init__(self): super(Model, self).__init__() sel...
apex-master
tests/L0/run_optimizers/test_adam.py
from itertools import product import random import unittest import torch import apex class TestFusedOptimizer(unittest.TestCase): def setUp(self, max_abs_diff=1e-3, max_rel_diff=1, iters=7): self.max_abs_diff = max_abs_diff self.max_rel_diff = max_rel_diff self.iters = iters torc...
apex-master
tests/L0/run_optimizers/test_fused_optimizer.py
import torch from torch.optim import Optimizer import math import apex import unittest from test_fused_optimizer import TestFusedOptimizer from itertools import product class Novograd(Optimizer): """ Implements Novograd algorithm. Args: params (iterable): iterable of parameters to optimize or dic...
apex-master
tests/L0/run_optimizers/test_fused_novograd.py
import logging import unittest import torch from torch.testing._internal import common_utils logging.getLogger("torch").setLevel(logging.WARNING) from apex.transformer import parallel_state from apex.transformer.pipeline_parallel import p2p_communication from apex.transformer.testing.distributed_test_base import Ncc...
apex-master
tests/L0/run_transformer/test_p2p_comm.py
import subprocess import os from apex.transformer.testing.commons import TEST_SUCCESS_MESSAGE def run_gpt(cmd): args = list(cmd.split(" ")) p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) outs, errs = p.communicate() outs = list(str((outs).decode("utf-8")).splitlines()) ...
apex-master
tests/L0/run_transformer/gpt_scaling_test.py
from typing import Tuple, List import torch import unittest from apex.transformer import parallel_state from apex.transformer.pipeline_parallel.utils import get_num_microbatches from apex.transformer.pipeline_parallel.schedules.common import ( _get_params_for_weight_decay_optimization, build_model ) from apex.tra...
apex-master
tests/L0/run_transformer/test_dynamic_batchsize.py
"""Test for fused softmax functions. Ref: https://github.com/NVIDIA/Megatron-LM/blob/40becfc96c4144985458ac0e0fae45dbb111fbd2/megatron/fused_kernels/tests/test_fused_kernels.py """ # NOQA import itertools import torch from torch.testing._internal import common_utils from apex.transformer import AttnMaskType from ap...
apex-master
tests/L0/run_transformer/test_fused_softmax.py
import logging from typing import Tuple import torch import torch.nn.functional as F from torch.testing._internal import common_utils logging.getLogger("torch").setLevel(logging.WARNING) from apex.transformer import parallel_state from apex.transformer import tensor_parallel from apex.transformer.tensor_parallel imp...
apex-master
tests/L0/run_transformer/test_cross_entropy.py
from functools import partial from typing import List import time import torch import unittest from apex.transformer._ucc_util import HAS_UCC from apex.transformer import parallel_state from apex.transformer.enums import ModelType from apex.transformer.tensor_parallel import model_parallel_cuda_manual_seed from apex...
apex-master
tests/L0/run_transformer/test_gpt_minimal.py
import torch from torch.testing._internal import common_utils from torch.utils.data import Dataset from torch.utils.data import DataLoader from apex.transformer.pipeline_parallel.utils import _split_batch_into_microbatch as split_batch_into_microbatch class MyIterableDataset(Dataset): def __init__(self, start, e...
apex-master
tests/L0/run_transformer/test_batch_sampler.py
import logging import unittest import typing import torch import torch.nn as nn from torch.testing._internal import common_utils from apex.transformer import parallel_state from apex.transformer.tensor_parallel import layers from apex.transformer.testing.commons import set_random_seed from apex.transformer.testing.di...
apex-master
tests/L0/run_transformer/test_layers.py
apex-master
tests/L0/run_transformer/__init__.py
import logging from typing import List, Optional from torch.testing._internal import common_utils logging.getLogger("torch").setLevel(logging.WARNING) from apex.transformer import parallel_state from apex.transformer.pipeline_parallel.utils import ( _reconfigure_microbatch_calculator, get_micro_batch_size, ...
apex-master
tests/L0/run_transformer/test_microbatches.py
import logging import torch.testing from torch.testing._internal import common_utils logging.getLogger("torch").setLevel(logging.WARNING) from apex.transformer import parallel_state from apex.transformer.tensor_parallel import data as data_utils from apex.transformer.testing.distributed_test_base import NcclDistribu...
apex-master
tests/L0/run_transformer/test_data.py
import torch import unittest from apex.transformer.testing import global_vars from apex.transformer.testing.standalone_bert import bert_model_provider from apex.transformer.pipeline_parallel.schedules.common import ( _get_params_for_weight_decay_optimization, build_model ) from apex.transformer.pipeline_parallel.sc...
apex-master
tests/L0/run_transformer/test_bert_minimal.py
import logging import torch from torch.testing._internal import common_utils logging.getLogger("torch").setLevel(logging.WARNING) from apex.transformer import parallel_state from apex.transformer.tensor_parallel import utils from apex.transformer.testing.distributed_test_base import NcclDistributedTestBase logging....
apex-master
tests/L0/run_transformer/test_transformer_utils.py
import logging import os from torch.testing._internal import common_utils logging.getLogger("torch").setLevel(logging.WARNING) from apex.transformer import parallel_state from apex.transformer.testing.distributed_test_base import NcclDistributedTestBase from apex.transformer.testing.distributed_test_base import UccD...
apex-master
tests/L0/run_transformer/test_parallel_state.py
import contextlib import logging import itertools import os from datetime import datetime from packaging.version import parse, Version import re from typing import Optional, Tuple, List import unittest import torch from torch.testing._internal import common_utils from apex._autocast_utils import _get_autocast_dtypes ...
apex-master
tests/L0/run_transformer/test_pipeline_parallel_fwd_bwd.py
import logging import torch from torch.testing._internal import common_utils from apex.transformer import parallel_state from apex.transformer.tensor_parallel import mappings from apex.transformer.testing.distributed_test_base import NcclDistributedTestBase from apex.transformer.testing.distributed_test_base import U...
apex-master
tests/L0/run_transformer/test_mapping.py
import logging import torch from torch.testing._internal import common_utils logging.getLogger("torch").setLevel(logging.WARNING) from apex.transformer import parallel_state from apex.transformer import tensor_parallel from apex.transformer.testing.distributed_test_base import NcclDistributedTestBase from apex.trans...
apex-master
tests/L0/run_transformer/test_random.py
import unittest import functools as ft import itertools as it from apex import amp from apex.amp import _amp_state import torch from torch import nn import torch.nn.functional as F from torch.nn import Parameter from utils import common_init, HALF, FLOAT,\ ALWAYS_HALF, ALWAYS_FLOAT, MATCH_INPUT class MyModel(to...
apex-master
tests/L0/run_amp/test_multiple_models_optimizers_losses.py
import unittest import functools as ft import itertools as it from apex import amp import torch from torch import nn import torch.nn.functional as F from utils import common_init, HALF, FLOAT,\ ALWAYS_HALF, ALWAYS_FLOAT, MATCH_INPUT try: import amp_C from amp_C import multi_tensor_l2norm from apex.multi_t...
apex-master
tests/L0/run_amp/test_multi_tensor_l2norm.py
import unittest import functools as ft import itertools as it from apex import amp from apex.amp import _amp_state import torch from torch import nn import torch.nn.functional as F from torch.nn import Parameter from utils import common_init, HALF, FLOAT,\ ALWAYS_HALF, ALWAYS_FLOAT, MATCH_INPUT try: import a...
apex-master
tests/L0/run_amp/test_fused_sgd.py
import unittest import functools as ft import itertools as it from apex import amp from apex.amp import _amp_state import torch from torch import nn import torch.nn.functional as F from torch.nn import Parameter from utils import common_init, HALF, FLOAT,\ ALWAYS_HALF, ALWAYS_FLOAT, MATCH_INPUT class MyModel(to...
apex-master
tests/L0/run_amp/test_add_param_group.py
apex-master
tests/L0/run_amp/__init__.py
import unittest import itertools as it from apex import amp import torch from torch import nn import torch.nn.functional as F from utils import common_init, HALF, FLOAT, DTYPES class TestPromotion(unittest.TestCase): def setUp(self): self.handle = amp.init(enabled=True) common_init(self) de...
apex-master
tests/L0/run_amp/test_promotion.py
import unittest import functools as ft import itertools as it from apex import amp import torch from torch import nn import torch.nn.functional as F from math import floor from utils import common_init, HALF, FLOAT,\ ALWAYS_HALF, ALWAYS_FLOAT, MATCH_INPUT try: import amp_C from amp_C import multi_tensor_axp...
apex-master
tests/L0/run_amp/test_multi_tensor_axpby.py
import torch HALF = 'torch.cuda.HalfTensor' FLOAT = 'torch.cuda.FloatTensor' DTYPES = [torch.half, torch.float] ALWAYS_HALF = {torch.float: HALF, torch.half: HALF} ALWAYS_FLOAT = {torch.float: FLOAT, torch.half: FLOAT} MATCH_INPUT = {torch.float: FLOAT, torch.half: HALF}...
apex-master
tests/L0/run_amp/utils.py
import unittest from apex import amp import random import torch from torch import nn from utils import common_init, HALF class TestRnnCells(unittest.TestCase): def setUp(self): self.handle = amp.init(enabled=True) common_init(self) def tearDown(self): self.handle._deactivate() d...
apex-master
tests/L0/run_amp/test_rnn.py
import unittest import functools as ft import itertools as it from apex import amp import torch from torch import nn import torch.nn.functional as F from utils import common_init, HALF, FLOAT,\ ALWAYS_HALF, ALWAYS_FLOAT, MATCH_INPUT try: import amp_C from amp_C import multi_tensor_scale from apex.multi_t...
apex-master
tests/L0/run_amp/test_multi_tensor_scale.py
import unittest import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from apex import amp from utils import common_init, FLOAT class MyModel(torch.nn.Module): def __init__(self): super(MyModel, self).__init__() self.conv1 = nn.Conv2d(3, 6, 3, 1, 1) ...
apex-master
tests/L0/run_amp/test_checkpointing.py
import unittest import functools as ft import itertools as it from apex import amp from apex.amp import _amp_state import torch from torch import nn import torch.nn.functional as F from utils import common_init, HALF, FLOAT,\ ALWAYS_HALF, ALWAYS_FLOAT, MATCH_INPUT def get_reference_grad(i, w, ops): # Creati...
apex-master
tests/L0/run_amp/test_cache.py
import unittest import torch from torch import nn from torch.nn import Parameter from apex import amp from apex.parallel.LARC import LARC from utils import common_init class MyModel(torch.nn.Module): def __init__(self, unique): super(MyModel, self).__init__() self.weight0 = Parameter( ...
apex-master
tests/L0/run_amp/test_larc.py
import unittest import functools as ft import itertools as it from apex import amp import torch from torch import nn import torch.nn.functional as F from utils import common_init, HALF, FLOAT,\ ALWAYS_HALF, ALWAYS_FLOAT, MATCH_INPUT def run_layer_test(test_case, fns, expected, input_shape, test_backward=True): ...
apex-master
tests/L0/run_amp/test_basic_casts.py
import unittest import torch import torch.nn as nn from apex.fp16_utils import FP16Model class DummyBlock(nn.Module): def __init__(self): super(DummyBlock, self).__init__() self.conv = nn.Conv2d(10, 10, 2) self.bn = nn.BatchNorm2d(10, affine=True) def forward(self, x): retu...
apex-master
tests/L0/run_fp16util/test_fp16util.py
apex-master
tests/L0/run_fp16util/__init__.py
import unittest import torch import apex from apex.transformer.testing.distributed_test_base import NcclDistributedTestBase def init_model_and_optimizer(): model = torch.nn.Linear(1, 1, bias=False).cuda() optimizer = torch.optim.SGD(model.parameters(), 1.0) return model, optimizer @unittest.skipUnless...
apex-master
tests/L0/run_deprecated/test_deprecated_warning.py
"""Tests for c++ MLP""" from itertools import product from time import time import torch from torch import nn from torch.testing._internal import common_utils from torch.testing._internal.common_device_type import instantiate_device_type_tests from torch.testing._internal.common_device_type import onlyCUDA from apex....
apex-master
tests/L0/run_mlp/test_mlp.py
import os import logging import itertools from typing import Optional, Tuple, List import unittest import torch from torch.testing._internal import common_utils from torch.testing._internal import common_cuda from torch.testing._internal import common_distributed from apex._autocast_utils import _get_autocast_dtypes ...
apex-master
tests/L1/transformer/pipeline_parallel_fwd_bwd_ucc_async.py
import argparse import os import shutil import time import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.distributed as dist import torch.optim import torch.utils.data import torch.utils.data.distributed import torchvision.transforms as transforms import torchvi...
apex-master
tests/L1/common/main_amp.py
import argparse import torch parser = argparse.ArgumentParser(description='Compare') parser.add_argument('--opt-level', type=str) parser.add_argument('--keep-batchnorm-fp32', type=str, default=None) parser.add_argument('--loss-scale', type=str, default=None) parser.add_argument('--fused-adam', action='store_true') par...
apex-master
tests/L1/common/compare.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # PyTorch documentation build configuration file, created by # sphinx-quickstart on Fri Dec 23 13:31:47 2016. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # au...
apex-master
docs/source/conf.py
from __future__ import print_function import argparse import os import random import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.optim as optim import torch.utils.data import torchvision.datasets as dset import torchvision.transforms as transforms import torchv...
apex-master
examples/dcgan/main_amp.py
import torch import argparse import os from apex import amp # FOR DISTRIBUTED: (can also use torch.nn.parallel.DistributedDataParallel instead) from apex.parallel import DistributedDataParallel parser = argparse.ArgumentParser() # FOR DISTRIBUTED: Parse for the local_rank argument, which will be supplied # automatica...
apex-master
examples/simple/distributed/distributed_data_parallel.py
import argparse import os import shutil import time import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.distributed as dist import torch.optim import torch.utils.data import torch.utils.data.distributed import torchvision.transforms as transforms import torchvi...
apex-master
examples/imagenet/main_amp.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
setup.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/constants.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/__init__.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/metrics/__init__.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/metrics/general/mse.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/metrics/general/reduction.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/metrics/general/histogram.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/metrics/general/__init__.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/metrics/general/ensemble_metrics.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/metrics/general/wasserstein.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/metrics/general/crps.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/metrics/general/entropy.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/metrics/general/calibration.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/metrics/climate/efi.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/metrics/climate/reduction.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/metrics/climate/__init__.py
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
modulus-main
modulus/metrics/climate/acc.py