python_code
stringlengths
0
992k
repo_name
stringlengths
8
46
file_path
stringlengths
5
162
import importlib import numbers import torch from torch.nn.parameter import Parameter from torch.nn import init from torch.nn import functional as F from apex._autocast_utils import _cast_if_autocast_enabled global fused_layer_norm_cuda fused_layer_norm_cuda = None # Reference implementation from Huggingface def m...
GeneSplice-main
GeneSplice/apex/apex/normalization/fused_layer_norm.py
from .fused_layer_norm import FusedLayerNorm, MixedFusedLayerNorm, FusedRMSNorm, MixedFusedRMSNorm
GeneSplice-main
GeneSplice/apex/apex/normalization/__init__.py
from .fused_dense import *
GeneSplice-main
GeneSplice/apex/apex/fused_dense/__init__.py
import torch from torch import nn import fused_dense_cuda from apex._autocast_utils import _cast_if_autocast_enabled #implements fused GEMM+bias in forward pass using mlp_cuda from apex class FusedDenseFunc(torch.autograd.Function): @staticmethod def forward(ctx, input, weight, bias): ctx.save_for_back...
GeneSplice-main
GeneSplice/apex/apex/fused_dense/fused_dense.py
# coding=utf-8 # Copyright (c) 2021, NVIDIA CORPORATION. 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 re...
GeneSplice-main
GeneSplice/apex/apex/transformer/enums.py
# coding=utf-8 # Copyright (c) 2021, NVIDIA CORPORATION. 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 re...
GeneSplice-main
GeneSplice/apex/apex/transformer/parallel_state.py
import logging import os def get_transformer_logger(name: str) -> logging.Logger: name_wo_ext = os.path.splitext(name)[0] return logging.getLogger(name_wo_ext) def set_logging_level(verbosity) -> None: """Change logging severity. Args: verbosity """ from apex import _library_root_lo...
GeneSplice-main
GeneSplice/apex/apex/transformer/log_util.py
from apex.transformer import amp from apex.transformer import functional from apex.transformer import parallel_state from apex.transformer import pipeline_parallel from apex.transformer import tensor_parallel from apex.transformer import utils from apex.transformer.enums import LayerType from apex.transformer.enums imp...
GeneSplice-main
GeneSplice/apex/apex/transformer/__init__.py
from torch import distributed as dist HAS_UCC = hasattr(dist, "is_ucc_available") and dist.is_ucc_available() if not HAS_UCC: try: import torch_ucc HAS_UCC = True except ImportError: HAS_UCC = False
GeneSplice-main
GeneSplice/apex/apex/transformer/_ucc_util.py
"""Utility functions used by both `pipeline_parallel` and `tensor_parallel`""" import torch from apex.transformer import parallel_state # `all_gather_into_tensor` is new placeholders for `_all_gather_base`. # It requires the most recent version of PyTorch. # The following 4 lines are for backward comparability with...
GeneSplice-main
GeneSplice/apex/apex/transformer/utils.py
# coding=utf-8 # Copyright (c) 2021, NVIDIA CORPORATION. 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 re...
GeneSplice-main
GeneSplice/apex/apex/transformer/microbatches.py
# coding=utf-8 # Copyright (c) 2021, NVIDIA CORPORATION. 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 re...
GeneSplice-main
GeneSplice/apex/apex/transformer/tensor_parallel/cross_entropy.py
# coding=utf-8 # Copyright (c) 2021, NVIDIA CORPORATION. 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 r...
GeneSplice-main
GeneSplice/apex/apex/transformer/tensor_parallel/memory.py
# Copyright (c) 2021, NVIDIA CORPORATION. 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 required by appli...
GeneSplice-main
GeneSplice/apex/apex/transformer/tensor_parallel/__init__.py
# coding=utf-8 # Copyright (c) 2021-22, NVIDIA CORPORATION. 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...
GeneSplice-main
GeneSplice/apex/apex/transformer/tensor_parallel/random.py
# coding=utf-8 # Copyright (c) 2021, NVIDIA CORPORATION. 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 re...
GeneSplice-main
GeneSplice/apex/apex/transformer/tensor_parallel/utils.py
# coding=utf-8 # Copyright (c) 2021-22, NVIDIA CORPORATION. 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...
GeneSplice-main
GeneSplice/apex/apex/transformer/tensor_parallel/layers.py
# coding=utf-8 # Copyright (c) 2021, NVIDIA CORPORATION. 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 re...
GeneSplice-main
GeneSplice/apex/apex/transformer/tensor_parallel/data.py
# coding=utf-8 # Copyright (c) 2021-22, NVIDIA CORPORATION. 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...
GeneSplice-main
GeneSplice/apex/apex/transformer/tensor_parallel/mappings.py
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. from apex.transformer.layers.layer_norm import FastLayerNorm from apex.transformer.layers.layer_norm import FusedLayerNorm from apex.transformer.layers.layer_norm import MixedFusedLayerNorm __all__ = [ "FastLayerNorm", "FusedLayerNorm", "Mixed...
GeneSplice-main
GeneSplice/apex/apex/transformer/layers/__init__.py
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. # NOTE(mkozuki): This file defines two LayerNorm that are compatible with Megatron-LM. # while avoiding introducing the breaking change of `"sequence_parallel_enabled"` attribute into apex.normalization.FusedLayerNorm # and apex.contrib.layer_norm.FastLaye...
GeneSplice-main
GeneSplice/apex/apex/transformer/layers/layer_norm.py
import time import torch class _Timer: """Timer.""" def __init__(self, name): self.name_ = name self.elapsed_ = 0.0 self.started_ = False self.start_time = time.time() def start(self): """Start the timer.""" assert not self.started_, "timer has already be...
GeneSplice-main
GeneSplice/apex/apex/transformer/pipeline_parallel/_timers.py
from apex.transformer.pipeline_parallel.schedules import get_forward_backward_func from apex.transformer.pipeline_parallel.schedules.common import build_model __all__ = [ "get_forward_backward_func", "build_model", ]
GeneSplice-main
GeneSplice/apex/apex/transformer/pipeline_parallel/__init__.py
# coding=utf-8 # Copyright (c) 2021, NVIDIA CORPORATION. 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 re...
GeneSplice-main
GeneSplice/apex/apex/transformer/pipeline_parallel/utils.py
# coding=utf-8 # Copyright (c) 2021-22, NVIDIA CORPORATION. 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...
GeneSplice-main
GeneSplice/apex/apex/transformer/pipeline_parallel/p2p_communication.py
import contextlib from typing import Any, List, Optional, Sequence, Union import warnings import torch from apex.transformer import parallel_state from apex.transformer.enums import ModelType from apex.transformer.pipeline_parallel import p2p_communication from apex.transformer.pipeline_parallel.p2p_communication imp...
GeneSplice-main
GeneSplice/apex/apex/transformer/pipeline_parallel/schedules/fwd_bwd_pipelining_without_interleaving.py
import contextlib from typing import List, Union, Optional import torch from apex.transformer.pipeline_parallel.utils import listify_model from apex.transformer.pipeline_parallel.utils import get_num_microbatches from apex.transformer.pipeline_parallel.utils import get_kth_microbatch from apex.transformer.pipeline_pa...
GeneSplice-main
GeneSplice/apex/apex/transformer/pipeline_parallel/schedules/fwd_bwd_no_pipelining.py
from apex.transformer import parallel_state from apex.transformer.pipeline_parallel.utils import get_num_microbatches from apex.transformer.pipeline_parallel.schedules.fwd_bwd_no_pipelining import ( forward_backward_no_pipelining, ) from apex.transformer.pipeline_parallel.schedules.fwd_bwd_pipelining_with_interleav...
GeneSplice-main
GeneSplice/apex/apex/transformer/pipeline_parallel/schedules/__init__.py
from typing import Any, Callable, Dict, List, Tuple, Union, Optional, Sequence import torch from torch.autograd.variable import Variable from apex.normalization.fused_layer_norm import FusedLayerNorm from apex.transformer import parallel_state from apex.transformer.enums import ModelType from apex.transformer.pipelin...
GeneSplice-main
GeneSplice/apex/apex/transformer/pipeline_parallel/schedules/common.py
import contextlib from typing import Any, Callable, List, Optional, Sequence, Union import warnings import torch from apex.transformer import parallel_state from apex.transformer.pipeline_parallel import p2p_communication from apex.transformer.pipeline_parallel.schedules.common import Batch from apex.transformer.pipe...
GeneSplice-main
GeneSplice/apex/apex/transformer/pipeline_parallel/schedules/fwd_bwd_pipelining_with_interleaving.py
# coding=utf-8 # Copyright (c) 2021, NVIDIA CORPORATION. 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 re...
GeneSplice-main
GeneSplice/apex/apex/transformer/testing/arguments.py
GeneSplice-main
GeneSplice/apex/apex/transformer/testing/__init__.py
# coding=utf-8 # Copyright (c) 2021, NVIDIA CORPORATION. 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 re...
GeneSplice-main
GeneSplice/apex/apex/transformer/testing/commons.py
import contextlib import torch from apex.transformer import tensor_parallel from apex.transformer.enums import AttnMaskType from apex.transformer.enums import ModelType from apex.transformer.layers import FusedLayerNorm as LayerNorm from apex.transformer.testing.global_vars import get_args from apex.transformer.testi...
GeneSplice-main
GeneSplice/apex/apex/transformer/testing/standalone_bert.py
import os import sys import unittest from packaging.version import Version, parse import torch from torch import distributed as dist from torch.utils import collect_env from torch.testing._internal import common_utils from torch.testing._internal import common_distributed from apex.transformer._ucc_util import HAS_UC...
GeneSplice-main
GeneSplice/apex/apex/transformer/testing/distributed_test_base.py
# Copyright (c) 2021-22, NVIDIA CORPORATION. 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 required by ap...
GeneSplice-main
GeneSplice/apex/apex/transformer/testing/standalone_gpt.py
# coding=utf-8 # Copyright (c) 2021-22, NVIDIA CORPORATION. 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...
GeneSplice-main
GeneSplice/apex/apex/transformer/testing/standalone_transformer_lm.py
# coding=utf-8 # Copyright (c) 2021, NVIDIA CORPORATION. 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 re...
GeneSplice-main
GeneSplice/apex/apex/transformer/testing/global_vars.py
# Copyright (c) 2022, NVIDIA CORPORATION. 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 required by appli...
GeneSplice-main
GeneSplice/apex/apex/transformer/amp/grad_scaler.py
from apex.transformer.amp.grad_scaler import GradScaler __all__ = [ "GradScaler", ]
GeneSplice-main
GeneSplice/apex/apex/transformer/amp/__init__.py
from apex.transformer._data._batchsampler import MegatronPretrainingRandomSampler from apex.transformer._data._batchsampler import MegatronPretrainingSampler __all__ = [ "MegatronPretrainingRandomSampler", "MegatronPretrainingSampler", ]
GeneSplice-main
GeneSplice/apex/apex/transformer/_data/__init__.py
"""BatchSampler implementations for POC of dynamic batch size or rampup_batch_size support. Implementations are based on https://github.com/NVIDIA/Megatron-LM/blob/bcd605f8570ebeeb0436c115ebbfafc3c5a40ae5/megatron/data/data_samplers.py. """ # NOQA import abc import torch __all__ = [ "MegatronPretrainingSampler...
GeneSplice-main
GeneSplice/apex/apex/transformer/_data/_batchsampler.py
# coding=utf-8 # Copyright (c) 2021, NVIDIA CORPORATION. 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 re...
GeneSplice-main
GeneSplice/apex/apex/transformer/functional/fused_softmax.py
from apex.transformer.functional.fused_softmax import FusedScaleMaskSoftmax __all__ = [ "FusedScaleMaskSoftmax", ]
GeneSplice-main
GeneSplice/apex/apex/transformer/functional/__init__.py
from .fp16util import ( BN_convert_float, network_to_half, prep_param_lists, model_grads_to_master_grads, master_params_to_model_params, tofp16, to_python_float, clip_grad_norm, convert_module, convert_network, FP16Model, ) from .fp16_optimizer import FP16_Optimizer from .lo...
GeneSplice-main
GeneSplice/apex/apex/fp16_utils/__init__.py
import torch import torch.nn as nn from torch.autograd import Variable from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors class tofp16(nn.Module): """ Utility module that implements:: def forward(self, input): return input.half() """ def __init__(self): ...
GeneSplice-main
GeneSplice/apex/apex/fp16_utils/fp16util.py
import torch from torch import nn from torch.autograd import Variable from torch.nn.parameter import Parameter from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors from ..amp._amp_state import _amp_state, maybe_print from ..amp.scaler import LossScaler from ..multi_tensor_apply import multi_tensor...
GeneSplice-main
GeneSplice/apex/apex/fp16_utils/fp16_optimizer.py
import torch # item() is a recent addition, so this helps with backward compatibility. def to_python_float(t): if hasattr(t, 'item'): return t.item() else: return t[0] class LossScaler: """ Class that manages a static loss scale. This class is intended to interact with :class:`FP1...
GeneSplice-main
GeneSplice/apex/apex/fp16_utils/loss_scaler.py
from .multi_tensor_apply import MultiTensorApply multi_tensor_applier = MultiTensorApply(2048*32)
GeneSplice-main
GeneSplice/apex/apex/multi_tensor_apply/__init__.py
import torch class MultiTensorApply(object): available = False warned = False def __init__(self, chunk_size): try: import amp_C MultiTensorApply.available = True self.chunk_size = chunk_size except ImportError as err: MultiTensorApply.availab...
GeneSplice-main
GeneSplice/apex/apex/multi_tensor_apply/multi_tensor_apply.py
GeneSplice-main
GeneSplice/apex/apex/contrib/__init__.py
import torch import fused_index_mul_2d class IndexMul2d_(torch.autograd.Function): ''' Currently only support index in dimension 0 with a 2-dimension tensor. The shape of indexed in1 must be same with in2. Now this kernel does not support broadcast. The datatype must be float32 or float16. ''' ...
GeneSplice-main
GeneSplice/apex/apex/contrib/index_mul_2d/index_mul_2d.py
from .index_mul_2d import index_mul_2d
GeneSplice-main
GeneSplice/apex/apex/contrib/index_mul_2d/__init__.py
from .sparse_masklib import create_mask from .asp import ASP
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/__init__.py
import types import torch from .sparse_masklib import create_mask from .permutation_lib import Permutation torchvision_imported=True try: import torchvision except ImportError: print("[ASP][Warning] torchvision cannot be imported.") torchvision_imported=False import json import os import string import tim...
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/asp.py
import os import torch import json import string import time import numpy as np import sys import builtins as __builtin__ import io try: from .permutation_search_kernels import accelerated_search_for_good_permutation, sum_after_2_to_4 print("[ASP][Info] permutation_search_kernels can be imported.") except Impor...
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/permutation_lib.py
import sys import torch import numpy as np import collections from itertools import permutations """ compute density (helper fn to compute % NNZs in a tensor) """ def fill(x): return float(x.nonzero().size(0))/torch.numel(x) """ reshape matrix into m-dimensional vectors: (h,w) -> (hw/m, m) """ def reshape_1d(mat...
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/sparse_masklib.py
from .permutation_utilities import * ################################################################################################################ # Exhaustive # Try them all # - order of columns within a group doesn't matter # - order of groups doesn't matter # - we can eliminate effective duplicates by de...
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/permutation_search_kernels/exhaustive_search.py
from .permutation_utilities import * ################################################################################################################ # Greedy Channel Swaps - iterative, deterministic, can be parallelized # 1. Build a map of the magnitude improvement of involved stripes for all pairs of channel swaps...
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/permutation_search_kernels/channel_swap.py
import numpy as np from .permutation_utilities import * from .exhaustive_search import Exhaustive_Search def accelerated_search_for_good_permutation(matrix_group, options=None, verbosity=0): """This function is used to call the permutation search CUDA kernels. users can provide prefer search strategy by provid...
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/permutation_search_kernels/call_permutation_search_kernels.py
from .call_permutation_search_kernels import accelerated_search_for_good_permutation from .permutation_utilities import sum_after_2_to_4
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/permutation_search_kernels/__init__.py
import numpy as np import time import subprocess import math gpus_tested = False gpus_found = 0 kernels_found = True try: import permutation_search_cuda as permutation_search_cuda_kernels print(f"Found permutation search CUDA kernels") except ImportError: try: from . import permutation_search_...
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/permutation_search_kernels/permutation_utilities.py
from collections import OrderedDict import torch from apex.optimizers import FusedAdam from apex.contrib.sparsity import ASP def build_model(args): od = OrderedDict() for i in range(args.num_layers): if i == 0: od['linear_layer_%d' % (i+1)] = torch.nn.Linear(args.input_features, args.hidde...
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/test/toy_problem.py
import torch import torch.onnx from apex.contrib.sparsity.permutation_lib import Permutation """ Functional and behavioral correctness checking for network permutations Each test class is a torch.nn.Module with three required members: - self.input_shape is used to populate a dummy input - self.expected_C_params indica...
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/test/test_permutation_application.py
from collections import OrderedDict import torch from apex.optimizers import FusedAdam from apex.contrib.sparsity import ASP def build_model(args): od = OrderedDict() for i in range(args.num_layers): if i == 0: od['linear_layer_%d' % (i+1)] = torch.nn.Linear(args.input_features, args.hidde...
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/test/checkpointing_test_part2.py
from collections import OrderedDict import torch from apex.optimizers import FusedAdam from apex.contrib.sparsity import ASP def build_model(args): od = OrderedDict() for i in range(args.num_layers): if i == 0: od['linear_layer_%d' % (i+1)] = torch.nn.Linear(args.input_features, args.hidde...
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/test/checkpointing_test_part1.py
from collections import OrderedDict import torch from apex.optimizers import FusedAdam from apex.contrib.sparsity import ASP # # Reference run for checkpointing test (part1 + part2) # def build_model(args): od = OrderedDict() for i in range(args.num_layers): if i == 0: od['linear_layer_%d...
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/test/checkpointing_test_reference.py
import numpy as np import time import sys # permutation-specifics sys.path.append("../") from permutation_search_kernels.permutation_utilities import * from permutation_search_kernels.exhaustive_search import Exhaustive_Search from permutation_search_kernels.channel_swap import Channel_Swap # Arguments import argpars...
GeneSplice-main
GeneSplice/apex/apex/contrib/sparsity/permutation_tests/permutation_test.py
try: import torch import bnp from .batch_norm import BatchNorm2d_NHWC del torch del bnp del batch_norm except ImportError as err: print("apex was installed without --bnp flag, contrib.groupbn is not available")
GeneSplice-main
GeneSplice/apex/apex/contrib/groupbn/__init__.py
import torch import numpy as np from torch.nn.modules.batchnorm import _BatchNorm import bnp class bn_NHWC_impl(torch.autograd.Function): @staticmethod def forward(ctx, x, s, b, rm, riv, mini_m, mini_riv, ret_cta, mom, epsilon, fuse_relu, is_train, bn_group, my_data, pair_data, magic, pair_data2, pair_data3, ...
GeneSplice-main
GeneSplice/apex/apex/contrib/groupbn/batch_norm.py
from .batch_norm import GroupBatchNorm2d
GeneSplice-main
GeneSplice/apex/apex/contrib/cudnn_gbn/__init__.py
import torch from torch.nn.modules.batchnorm import _BatchNorm from torch.nn import functional as F from torch import Tensor import peer_memory_cuda as pm import cudnn_gbn_lib from torch.cuda.amp import custom_fwd, custom_bwd class _GroupBatchNorm2d(torch.autograd.Function): @staticmethod @custom_fwd def ...
GeneSplice-main
GeneSplice/apex/apex/contrib/cudnn_gbn/batch_norm.py
GeneSplice-main
GeneSplice/apex/apex/contrib/test/__init__.py
GeneSplice-main
GeneSplice/apex/apex/contrib/test/index_mul_2d/__init__.py
import random import unittest import torch HAS_INDEX_MUL_2D_RELU = None try: from apex.contrib.index_mul_2d import index_mul_2d except ImportError as e: HAS_INDEX_MUL_2D_RELU = False else: HAS_INDEX_MUL_2D_RELU = True @unittest.skipIf(not HAS_INDEX_MUL_2D_RELU, "`apex.contrib.index_mul_2d` is not found....
GeneSplice-main
GeneSplice/apex/apex/contrib/test/index_mul_2d/test_index_mul_2d.py
import copy import typing import unittest import torch import torch.nn as nn from torch.testing._internal import common_utils SKIP_TEST = None from apex.transformer.testing.distributed_test_base import NcclDistributedTestBase try: from apex.contrib.cudnn_gbn import GroupBatchNorm2d as GBN except ImportError as e:...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/cudnn_gbn/test_cudnn_gbn_with_two_gpus.py
GeneSplice-main
GeneSplice/apex/apex/contrib/test/cudnn_gbn/__init__.py
import unittest import torch import torch.nn.functional as F reference_available = True try: from torchvision.ops.focal_loss import sigmoid_focal_loss except ImportError: reference_available = False SKIP_TEST = None try: from apex.contrib.focal_loss import focal_loss except ImportError as e: SKIP_TES...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/focal_loss/test_focal_loss.py
GeneSplice-main
GeneSplice/apex/apex/contrib/test/focal_loss/__init__.py
GeneSplice-main
GeneSplice/apex/apex/contrib/test/xentropy/__init__.py
import unittest import random import time import numpy as np import torch SKIP_TEST = None try: from apex.contrib import xentropy as label_smoothing except ImportError as e: SKIP_TEST = e def label_smoothing_raw(x, target, padding_idx, smoothing): logprobs = torch.nn.functional.log_softmax(x, dim=-1, d...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/xentropy/test_label_smoothing.py
import unittest import os import torch from torch.testing._internal import common_utils from torch.testing._internal.common_device_type import instantiate_device_type_tests SKIP_TEST = None try: from apex import fused_dense except ImportError as e: SKIP_TEST = e @unittest.skipIf(SKIP_TEST, f"{SKIP_TEST}") c...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/fused_dense/test_fused_dense.py
GeneSplice-main
GeneSplice/apex/apex/contrib/test/layer_norm/__init__.py
import unittest import torch SKIP_TEST = None try: from apex.contrib.layer_norm.layer_norm import FastLayerNorm import fast_layer_norm as fln except ImportError as e: SKIP_TEST = e class GPUTimer: def __init__(self, stream): self.start_ = torch.cuda.Event(enable_timing=True) self.sto...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/layer_norm/test_fast_layer_norm.py
import os import inspect import torch from torch.cuda.amp import GradScaler from torch.testing._internal import common_utils from apex.parallel.distributed import flat_dist_call from apex.contrib.optimizers.distributed_fused_lamb import DistributedFusedLAMB from apex.transformer.testing.distributed_test_base import Ncc...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/optimizers/test_distributed_fused_lamb.py
GeneSplice-main
GeneSplice/apex/apex/contrib/test/optimizers/__init__.py
from contextlib import contextmanager import io import unittest import torch from torch.testing._internal import common_utils SKIP_TEST = None try: from apex.contrib.optimizers.distributed_fused_adam import DistributedFusedAdam except ImportError as e: SKIP_TEST = e from apex.transformer.testing.distributed_t...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/optimizers/test_dist_adam.py
import unittest import torch from torch.testing._internal import common_utils from apex.transformer.testing.distributed_test_base import NcclDistributedTestBase SKIP_TEST = None try: from apex.contrib.bottleneck import Bottleneck, SpatialBottleneck from apex.contrib.bottleneck import HaloExchangerPeer fro...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/bottleneck/test_bottleneck_module.py
GeneSplice-main
GeneSplice/apex/apex/contrib/test/bottleneck/__init__.py
GeneSplice-main
GeneSplice/apex/apex/contrib/test/conv_bias_relu/__init__.py
import copy import math import random import unittest import torch import torch.nn.functional as F HAS_CONV_BIAS_RELU = None try: from apex.contrib.conv_bias_relu import ConvBiasReLU, ConvBias, ConvBiasMaskReLU, ConvFrozenScaleBiasReLU except ImportError as e: HAS_CONV_BIAS_RELU = False else: HAS_CONV_BIA...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/conv_bias_relu/test_conv_bias_relu.py
import unittest import torch SKIP_TEST = None try: from apex.contrib.multihead_attn import SelfMultiheadAttn except ImportError as e: SKIP_TEST = e @unittest.skipIf(SKIP_TEST, f"{SKIP_TEST}") class SelfMultiheadAttnNormAddTest(unittest.TestCase): def setUp(self, seed=1234): torch.manual_seed(see...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/multihead_attn/test_self_multihead_attn_norm_add.py
GeneSplice-main
GeneSplice/apex/apex/contrib/test/multihead_attn/__init__.py
import unittest import torch import torch.nn.functional as F SKIP_TEST = None try: from apex.contrib.multihead_attn import fast_mask_softmax_dropout_func except ImportError as e: SKIP_TEST = e @unittest.skipIf(SKIP_TEST, f"{SKIP_TEST}") class FusedSoftmaxTest(unittest.TestCase): def setUp(self, seed=123...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/multihead_attn/test_mha_fused_softmax.py
import unittest import torch SKIP_TEST = None try: from apex.contrib.multihead_attn import EncdecMultiheadAttn except ImportError as e: SKIP_TEST = e @unittest.skipIf(SKIP_TEST, f"{SKIP_TEST}") class EncdecMultiheadAttnTest(unittest.TestCase): def setUp(self, seed=1234): torch.manual_seed(seed) ...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/multihead_attn/test_encdec_multihead_attn.py
import unittest import torch SKIP_TEST = None try: from apex.contrib.multihead_attn import SelfMultiheadAttn except ImportError as e: SKIP_TEST = e @unittest.skipIf(SKIP_TEST, f"{SKIP_TEST}") class SelfMultiheadAttnTest(unittest.TestCase): def setUp(self, seed=1234): torch.manual_seed(seed) ...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/multihead_attn/test_fast_self_multihead_attn_bias.py
import unittest import torch SKIP_TEST = None try: from apex.contrib.multihead_attn import EncdecMultiheadAttn except ImportError as e: SKIP_TEST = e @unittest.skipIf(SKIP_TEST, f"{SKIP_TEST}") class EncdecMultiheadAttnNormAddTest(unittest.TestCase): def setUp(self, seed=1234): torch.manual_seed...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/multihead_attn/test_encdec_multihead_attn_norm_add.py
import unittest import torch SKIP_TEST = None try: from apex.contrib.multihead_attn import SelfMultiheadAttn except ImportError as e: SKIP_TEST = e @unittest.skipIf(SKIP_TEST, f"{SKIP_TEST}") class SelfMultiheadAttnTest(unittest.TestCase): def setUp(self, seed=1234): torch.manual_seed(seed) ...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/multihead_attn/test_self_multihead_attn.py
import random import unittest import torch SKIP_TEST = None try: from apex.contrib.clip_grad import clip_grad_norm_ except ImportError as e: SKIP_TEST = e def make_params( num_params, sizes=[1,2,3,4,5], num_dims=[1,2,3], dtypes=[torch.float32], devices=['cuda'], ...
GeneSplice-main
GeneSplice/apex/apex/contrib/test/clip_grad/test_clip_grad.py
GeneSplice-main
GeneSplice/apex/apex/contrib/test/clip_grad/__init__.py