Search is not available for this dataset
repo stringlengths 2 152 ⌀ | file stringlengths 15 239 | code stringlengths 0 58.4M | file_length int64 0 58.4M | avg_line_length float64 0 1.81M | max_line_length int64 0 12.7M | extension_type stringclasses 364
values |
|---|---|---|---|---|---|---|
psrsalsa | psrsalsa-master/src/slalib/prebn.f | SUBROUTINE sla_PREBN (BEP0, BEP1, RMATP)
*+
* - - - - - -
* P R E B N
* - - - - - -
*
* Generate the matrix of precession between two epochs,
* using the old, pre-IAU1976, Bessel-Newcomb model, using
* Kinoshita's formulation (double precision)
*
* Given:
* BEP0 dp beginning Bessel... | 2,440 | 29.5125 | 73 | f |
psrsalsa | psrsalsa-master/src/slalib/prec.f | SUBROUTINE sla_PREC (EP0, EP1, RMATP)
*+
* - - - - -
* P R E C
* - - - - -
*
* Form the matrix of precession between two epochs (IAU 1976, FK5)
* (double precision)
*
* Given:
* EP0 dp beginning epoch
* EP1 dp ending epoch
*
* Returned:
* RMATP dp(3,3) preces... | 3,192 | 31.917526 | 73 | f |
psrsalsa | psrsalsa-master/src/slalib/prenut.f | SUBROUTINE sla_PRENUT (EPOCH, DATE, RMATPN)
*+
* - - - - - - -
* P R E N U T
* - - - - - - -
*
* Form the matrix of precession and nutation (SF2001)
* (double precision)
*
* Given:
* EPOCH dp Julian Epoch for mean coordinates
* DATE dp Modified Julian Date (JD-2400000.... | 1,846 | 26.567164 | 73 | f |
psrsalsa | psrsalsa-master/src/slalib/sla_wrap.c | /*
Copyright (c) 2015, Patrick Weltevrede
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the follow... | 4,024 | 40.494845 | 755 | c |
psrsalsa | psrsalsa-master/src/slalib/sla_wrap.h | /*
Copyright (c) 2015, Patrick Weltevrede
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the follow... | 2,443 | 75.375 | 755 | h |
null | barlowtwins-main/CODE_OF_CONDUCT.md | # Open Source Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristi... | 3,253 | 68.234043 | 463 | md |
null | barlowtwins-main/CONTRIBUTING.md | # Contributing
In the context of this project, we do not expect pull requests.
If you find a bug, or would like to suggest an improvement, please open an issue.
| 164 | 32 | 81 | md |
null | barlowtwins-main/README.md | Barlow Twins: Self-Supervised Learning via Redundancy Reduction
---------------------------------------------------------------
<p align="center">
<img width="500" alt="Screen Shot 2021-04-29 at 6 26 48 AM" src="https://user-images.githubusercontent.com/14848164/120419539-b0fab900-c330-11eb-8536-126ce6ce7b85.png">
<... | 3,972 | 40.385417 | 349 | md |
null | barlowtwins-main/evaluate.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from pathlib import Path
import argparse
import json
import os
import random
import signal
import sys
import time
import ur... | 10,534 | 39.057034 | 178 | py |
null | barlowtwins-main/hubconf.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torchvision.models.resnet import resnet50 as _resnet50
dependencies = ['torch', 'torchvision']
def res... | 692 | 33.65 | 114 | py |
null | barlowtwins-main/main.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from pathlib import Path
import argparse
import json
import math
import os
import random
import signal
import subprocess
im... | 12,576 | 36.996979 | 97 | py |
dpro | dpro-master/README.md | # Introduction
This project is used to analyze the trace results profiled via [byteprofile](https://github.com/joapolarbear/byteps) a developed version of [BytePS](https://github.com/bytedance/byteps).
# Usage
By choosing different `--option`, this project supports the functionalities as shown below.
## Statistic
Se... | 3,869 | 55.911765 | 291 | md |
dpro | dpro-master/setup.py | #!/usr/bin/env python
import os
import sys
from setuptools import setup, find_packages
name = "dpro"
version = "0.0.1"
description = "A profiling, replay and optimization toolkit for distributed DNN training"
rootdir = os.path.abspath(os.path.dirname(__file__))
long_description = open(os.path.join(rootdir, "README.... | 1,103 | 26.6 | 89 | py |
dpro | dpro-master/setup.sh | #!/bin/bash
PROJECT_PATH=$(realpath ./)
pip3 install wheel
python3 -m pip install --upgrade build
python3 -m build
### install python deps
pip3 install -r requirements.txt
### install
pip3 uninstall -y dpro && pip3 install $PROJECT_PATH
# cd .. && python3 -c "import dpro;print(dpro.__path__)" && cd dpro
### install... | 484 | 22.095238 | 67 | sh |
dpro | dpro-master/sleep.sh | #!/bin/bash
sleep 36000000 | 27 | 8.333333 | 14 | sh |
dpro | dpro-master/data/mx_20200824_resnet50.py | """
Platform: On one V100 GPU, single machine
Framework: Tensorflow 1.14, CUDA 10.2
"""
import matplotlib.pyplot as plt
import numpy as np
import os, sys
from dataloader import DataLoader, MultiDataLoader, init_fig_base, FP32_OR_FP16, FULL_HEADERS, GFLOPS_FP32, GFLOPS_FP16
import seaborn as sns
from amp_cost_model impo... | 37,084 | 36.764766 | 182 | py |
dpro | dpro-master/data/tf_20200720.py | """
Platform: On one V100 GPU, single machine
Framework: Tensorflow 1.14, CUDA 10.2
Model/Dataset: 2conv + 2 dense with MNIST
# ---------
# Variables: name (type shape) [size]
# ---------
# conv_layer1/conv2d/kernel:0 (float32_ref 5x5x1x32) [800, bytes: 3200]
# conv_layer1/conv2d/bias:0 (float32_ref 32) [32, bytes... | 131,853 | 127.763672 | 3,289 | py |
dpro | dpro-master/data/tf_20200731_resnet50.py | """
Platform: On one V100 GPU, single machine
Framework: Tensorflow 1.14, CUDA 10.2
Model/Dataset: 2conv + 2 dense with MNIST
# ---------
# Variables: name (type shape) [size]
# ---------
# conv_layer1/conv2d/kernel:0 (float32_ref 5x5x1x32) [800, bytes: 3200]
# conv_layer1/conv2d/bias:0 (float32_ref... | 37,360 | 35.772638 | 160 | py |
dpro | dpro-master/data/tf_20200811_pred_error.py | import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import (AutoMinorLocator, MultipleLocator)
ax = plt.subplot(111)
# all_data[label id][test error for 100 times of repeated test]
all_data = [
[13.956024, 14.433242, 36.365207, 10.380671, 13.353506, 50.151516, 11.076908, 12.229296, 13.197254, 4... | 11,572 | 250.586957 | 1,097 | py |
dpro | dpro-master/docker/tensorflow.Dockerfile | # Copyright 2019 Bytedance Inc. or its 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 required ... | 11,290 | 41.130597 | 194 | Dockerfile |
dpro | dpro-master/docs/dependency.md |
# 3rdparty version
## Frameworks
* [MXNet](https://github.com/joapolarbear/incubator-mxnet/tree/mlsys2022)
* [TensorFlow](https://github.com/joapolarbear/tensorflow/tree/mlsys2022)
* [BytePS](https://github.com/joapolarbear/byteps/tree/mlsys2022)
* [pslite](https://github.com/joapolarbear/ps-lite/tree/mlsys2022)
* [Z... | 4,872 | 37.070313 | 132 | md |
dpro | dpro-master/docs/format.md | # Format Specification
## Trace Format
```python
### Uniform template
{
"name": op_cat.op_name.sub_op,
"ts": time_in_us,
"dur": time_in_us,
"pid": process_id, # e.g., host0.rank0
"args": {
"name": op_type.op_name.sub_op~>suffix,
...
"cnt": 2, # how many times the op occurs,... | 3,066 | 32.703297 | 206 | md |
dpro | dpro-master/docs/nvprof.md | # Introduction
This tutorial gives an introduction of how to compare ByteProfile Traces and NvProf traces
# How to use
## Traces Collection
Use `nvprof` to collect NvProf traces.
```nvprof -o foo.nvvp your_program```
In the meanwhile, you should customized the source code and enable BPF_related environment variabl... | 989 | 40.25 | 158 | md |
dpro | dpro-master/docs/profile.md | # Profiler
### Horovod + Tensorflow
Please follow the instructions in [docs/dependency.md](./dependency.md) to install our customized Horovod and TensorFlow.
To enable profiling, add the following code to your script for a training job using Horovod.
```
recorder = hvd.Recorder()
@hvd.profile(recorder)
@tf.function
d... | 1,169 | 26.209302 | 155 | md |
dpro | dpro-master/docs/sample_config.yaml | # Normal arguments
platform: TENSORFLOW
comm_backend: NCCL
nccl_algo: RING
optimizer: MCMC
xla_candidate_path: {{path}}/.xla_dump/unsafe_resource_deps.txt
# Stroe true argements
store_true:
pretty: 1
layer_by_layer: 1
# environment variables
env:
DPRO_GRAPHDEF_DFG_PATH: {{path}}/.xla_dump/grap... | 332 | 21.2 | 67 | yaml |
dpro | dpro-master/docs/usage.md |
This script introduces how to analyze the traces of a distributed trianing job using dPRO toolkit.
Suppose `DPRO_PATH` denotes the path where dpro is installed (check by entering `python3 -c "improt dpro; print(dpro.__path__)`), and `GLOBAL_TRACE_PATH` represents the path to store the final traces.
### Basic Usage
Y... | 9,591 | 42.799087 | 353 | md |
dpro | dpro-master/dpro/__init__.py | from . import base
from . import logger_utils
from . import collect
from . import trace_utils
from . import replay | 114 | 22 | 26 | py |
dpro | dpro-master/dpro/analyze.py | from tqdm import tqdm
import os
import ujson as json
import networkx as nx
import sys
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
from dpro.arg_utils import SingleArg
from dpro.logger_utils import SingleLogger
args = SingleArg().args
logger = SingleLogger(args.path.split(',')[0],
args.option, args.logging_level,
... | 24,952 | 45.728464 | 150 | py |
dpro | dpro-master/dpro/arg_utils.py | import argparse
from .base import Singleton
parser = argparse.ArgumentParser(description="dPRO Arguments",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# parser.add_argument("-s", action="store_true", help="sort the output result")
parser.add_argument("--option", type=str,
choices=["statistic", "gra... | 8,210 | 80.29703 | 186 | py |
dpro | dpro-master/dpro/base.py | import os
dpro_dir = os.path.dirname(__file__)
#! define a singleton class
def Singleton(cls):
_instance = {}
def _singleton(*args, **kargs):
if cls not in _instance:
_instance[cls] = cls(*args, **kargs)
return _instance[cls]
return _singleton
class bcolors:
ENDC = '\033... | 890 | 19.25 | 48 | py |
dpro | dpro-master/dpro/collect.py | import os
import re
import ujson as json
import networkx as nx
import time
import numpy as np
import multiprocessing
from .trace_utils import *
from .dag_utils import *
from .parameter import *
from .bps_helper.preprocess import preprocess_comm_timestamp, parse_server_logs
from .base import bcolors
try:
from hv... | 98,923 | 48.26494 | 162 | py |
dpro | dpro-master/dpro/dag_utils.py | from argparse import ArgumentError
import os
import re
import networkx as nx
import matplotlib.pyplot as plt
from .trace_utils import *
try:
from hvd.graph import *
except:
pass
try:
from bps_helper.graph import *
except:
pass
VIRTUAL_SYNC_OP = True
def visualize_gml(graph, layout="circular"):
i... | 58,110 | 56.821891 | 174 | py |
dpro | dpro-master/dpro/debug_utils.py | import ujson as json
import os
import time
from .base import Singleton
@Singleton
class DebugRecorder:
def __init__(self, path_=None, is_enable=True):
self.is_enable = is_enable
self.debug_traces = []
self.path_ = path_
self.base_time = self.get_time()
self.ts_list = []
def get_time(self):
return time.... | 1,501 | 21.41791 | 62 | py |
dpro | dpro-master/dpro/logger_utils.py | import logging
import os, sys
from .base import Singleton
LOG_LEVEL_NAME = ["DEBUG", "INFO", "WARNING", "ERROR", "FATAL"]
## Ref: https://stackoverflow.com/questions/12980512/custom-logger-class-and-correct-line-number-function-name-in-log
# This code is mainly copied from the python logging module, with minor modif... | 4,560 | 36.081301 | 137 | py |
dpro | dpro-master/dpro/mg_generate_dataset.py | ''' Generate Dataset to train the Cost Model
'''
from tqdm import tqdm
import os,sys
from .arg_utils import SingleArg
from .logger_utils import SingleLogger
args = SingleArg().args
logger = SingleLogger(args.path.split(',')[0],
args.option, args.logging_level,
is_clean=args.clean,
show_progress=args.pr... | 696 | 28.041667 | 86 | py |
dpro | dpro-master/dpro/parameter.py | ''' Manage the parameter info of a DNN model
'''
import re
from .trace_utils import *
class ParameterDict:
def __init__(self, _pm, platform, metadata_path=None):
### collect metadata
if metadata_path is None:
metadata_path = os.path.dirname(_pm.search(FileName.METADATA))
if met... | 3,089 | 32.586957 | 86 | py |
dpro | dpro-master/dpro/replay.py | import os
import ujson as json
import networkx as nx
import time
import collections
import re
from tqdm import tqdm
from .dag_utils import QueueType
from .trace_utils import *
from .logger_utils import SingleLogger
from .debug_utils import DebugRecorder
from .bps_helper.graph import PS_COMP_OPS_SETS, PS_COMM_OPS_SETS
... | 35,242 | 40.413631 | 166 | py |
dpro | dpro-master/dpro/trace_utils.py | import os
import ujson as json
import random
import math
import xlsxwriter
import threading
from enum import Enum
import numpy as np
from .logger_utils import Singleton, SingleLogger
from .base import bcolors
QUEUETYPE = {
"NCCL": {
"fine": [
"Sync",
"QUEUE",
"MEMCPY_IN... | 43,273 | 39.979167 | 244 | py |
dpro | dpro-master/dpro/xla_cm_entry.py | import os
import argparse
from .logger_utils import SingleLogger
from .cost_model._xla.xla_module_cost_model import XLAModuleCostModel
from .cost_model._xla.gen_dataset_utils import XlaKernelDataset
try:
import byteps.tensorflow as bps
except:
pass
try:
import horovod.tensorflow as hvd
except:
pass
... | 3,383 | 42.948052 | 130 | py |
dpro | dpro-master/dpro/xla_test_generate_cluster_spec.py | from tqdm import tqdm
import networkx as nx
import pickle
import os
from google.protobuf.json_format import MessageToJson
from google.protobuf.text_format import Parse
import tensorflow as tf
import json
try:
GraphDef = tf.GraphDef
except:
GraphDef = tf.compat.v1.GraphDef
# from collect import Collector
from... | 9,915 | 35.725926 | 169 | py |
dpro | dpro-master/dpro/bps_helper/__init__.py | 0 | 0 | 0 | py | |
dpro | dpro-master/dpro/bps_helper/graph.py | from argparse import ArgumentError
from enum import Enum
import numpy as np
import networkx as nx
from intervaltree import IntervalTree
import hashlib
import json
import pickle
import cvxpy as cp
from ..logger_utils import *
from ..trace_utils import *
class PS_COMM_OPS():
PUSH_REQ = "PUSH_REQ"
PULL_REQ = "PU... | 50,778 | 45.037171 | 247 | py |
dpro | dpro-master/dpro/bps_helper/preprocess.py | import json
import os
from scapy.all import *
from scapy.layers.inet import TCP
from scapy.layers.inet import IP
############################### PACKETS PARSING ################################
def __parse_single_packet(packet):
time = float(packet.time)
data = packet[TCP][Raw].load
index_s = data.find(b"... | 20,980 | 35.616056 | 160 | py |
dpro | dpro-master/dpro/cost_model/__init__.py | 0 | 0 | 0 | py | |
dpro | dpro-master/dpro/cost_model/base.py |
class OptApplyStrategyError(Exception):
pass
class OptNoValidStrategyError(Exception):
pass
class OptQueryCostModelError(Exception):
pass
class _BaseGraphPass:
def __init__(self, opt):
self.opt = opt
self.dag = self.opt.dag
### token is the indendifier of each optimization ... | 1,466 | 27.211538 | 69 | py |
dpro | dpro-master/dpro/cost_model/gpu_models_info.py | import numpy as np
ALL_GPU_MODELS = ["v100", "a100", "p100", "1080ti", "t4"]
CONFIG_NAMES = ["flops_fp32", "flops_fp16"]
ALL_GPU_MODELS_FILTER = [True, True, True, True, True]
### refer to https://www.microway.com/knowledge-center-articles/comparison-of-nvidia-geforce-gpus-and-nvidia-tesla-gpus/
### in tflops
GPU_CONF... | 1,018 | 32.966667 | 120 | py |
dpro | dpro-master/dpro/cost_model/mixed_precision.py | import networkx as nx
import time
import os
import pickle
import numpy as np
import ujson as json
from tqdm import tqdm
from ..arg_utils import SingleArg
from ..trace_utils import *
from ._xla.pk_graph import PKGraph
from .base import _BaseGraphPass
from ._mixed_precision.amp_pred import AMPPredictor
args_ = SingleAr... | 3,599 | 38.56044 | 126 | py |
dpro | dpro-master/dpro/cost_model/op_fusion.py | from multiprocessing import Value
import os, sys
import networkx as nx
from scipy.stats.mstats import gmean
import numpy as np
import pickle
import itertools
import json
from tqdm import tqdm, trange
import subprocess
import re
import time
from ..arg_utils import SingleArg
from ..trace_utils import painted_timeline, p... | 49,718 | 45.904717 | 633 | py |
dpro | dpro-master/dpro/cost_model/tensor_fusion.py | from multiprocessing import Value
import networkx as nx
import os
import pickle
import numpy as np
import math
import random
import ujson as json
import collections
from tqdm import tqdm, trange
from scipy.optimize import curve_fit
import copy
from .base import _BaseGraphPass
from ._xla.pk_graph import PKGraph
from ._... | 91,108 | 50.242407 | 157 | py |
dpro | dpro-master/dpro/cost_model/trace_clct.sh | #!/bin/bash
### MXNet env
MXNET_CUDNN_AUTOTUNE_DEFAULT=0
MXNET_GPU_WORKER_NTHREADS=1
MXNET_EXEC_BULK_EXEC_TRAIN=0
##############################################################################
### Configuration
# MODEL="ResNet50"
MODEL="BertBase"
# MODEL="InceptionV3"
# MODEL="VGG16"
# MODEL="Bert256"
PLATFORM='TF'... | 4,503 | 38.508772 | 468 | sh |
dpro | dpro-master/dpro/cost_model/trace_filter.py | ''' This module is used to filter operators that we focus on for AMP
And write them in avg.txt file
write corresponding names in name.txt
'''
import sys, os
class TraceFilter:
def __init__(self, save_names=None, model=None, platform=None, showall=None):
self.save_names = save_names
self.pla... | 2,350 | 33.072464 | 172 | py |
dpro | dpro-master/dpro/cost_model/_gpu_predict/__init__.py | 0 | 0 | 0 | py | |
dpro | dpro-master/dpro/cost_model/_gpu_predict/dataloader.py | import os
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import math
from ...logger_utils import SingleLogger
from ...trace_utils import parse_op_name
from ...arg_utils import SingleArg
args_ = SingleArg().args
if args_.platform == "MXNET":
from ml_platform.mxnet.metadata import MetaInfo... | 25,706 | 43.55286 | 157 | py |
dpro | dpro-master/dpro/cost_model/_gpu_predict/dim_reduce.py | import numpy as np
import math
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.ticker import NullFormatter
from sklearn import manifold
from sklearn.utils import check_random_state
def init_fig_base(cnt):
h = math.ceil(math.sqrt(cnt))
w = math.ceil(cnt / h)
fig_base... | 3,511 | 30.079646 | 102 | py |
dpro | dpro-master/dpro/cost_model/_gpu_predict/gpu_cost_model.py | import numpy as np
from ...logger_utils import SingleLogger
def predict_error(_list, _list_pred):
_list_pred = np.array(_list_pred)
_list = np.array(_list)
if len(_list) == 0:
return None, "Original time is too small. Ignore!!!"
diff = np.abs(_list_pred - _list) / _list
return diff, "%f %... | 20,240 | 43.880266 | 155 | py |
dpro | dpro-master/dpro/cost_model/_gpu_predict/gpu_pred.py | import os, sys
import ujson as json
import numpy as np
import pickle
from ...trace_utils import *
from ...logger_utils import Singleton, SingleLogger
from ...arg_utils import SingleArg
args_ = SingleArg().args
if args_.platform == "MXNET":
from ml_platform.mxnet.metadata import MetaInfo, FULL_HEADERS, OP_HYPER_P... | 16,420 | 40.36272 | 134 | py |
dpro | dpro-master/dpro/cost_model/_gpu_predict/grouper.py | import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pickle
import os
import scipy.interpolate as interpolate
from .gpu_cost_model import CurveFiter
from ...logger_utils import SingleLogger
class Delimiter:
def __init__(self, target_dim, td_len=1., fd_len=0., unit_len=1., max_grp_size=... | 12,151 | 42.71223 | 182 | py |
dpro | dpro-master/dpro/cost_model/_mixed_precision/__init__.py | 0 | 0 | 0 | py | |
dpro | dpro-master/dpro/cost_model/_mixed_precision/amp_cost_model.py | import numpy as np
from ...logger_utils import SingleLogger
def predict_error(_list, _list_pred):
_list_pred = np.array(_list_pred)
_list = np.array(_list)
if len(_list) == 0:
return None, "Original time is too small. Ignore!!!"
diff = np.abs(_list_pred - _list) / _list
return diff, "%f %%... | 21,490 | 43.402893 | 155 | py |
dpro | dpro-master/dpro/cost_model/_mixed_precision/amp_pred.py | import os, sys
import ujson as json
import numpy as np
import pickle
from ...trace_utils import *
from ...logger_utils import SingleLogger
from ...arg_utils import SingleArg
args_ = SingleArg().args
if args_.platform == "MXNET":
from ...ml_platform.mxnet.metadata import MetaInfo, FULL_HEADERS, OP_HYPER_PARAMETER... | 14,311 | 41.218289 | 134 | py |
dpro | dpro-master/dpro/cost_model/_mixed_precision/dataloader.py | import os
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import math
from ...logger_utils import SingleLogger
from ...trace_utils import parse_op_name
from ...arg_utils import SingleArg
args_ = SingleArg().args
if args_.platform == "MXNET":
from ...ml_platform.mxnet.metadata import MetaI... | 24,565 | 42.946333 | 157 | py |
dpro | dpro-master/dpro/cost_model/_mixed_precision/dim_reduce.py | import numpy as np
import math
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.ticker import NullFormatter
from sklearn import manifold
from sklearn.utils import check_random_state
def init_fig_base(cnt):
h = math.ceil(math.sqrt(cnt))
w = math.ceil(cnt / h)
fig_base... | 3,511 | 30.079646 | 102 | py |
dpro | dpro-master/dpro/cost_model/_mixed_precision/grouper.py | import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pickle
import os
import scipy.interpolate as interpolate
from .amp_cost_model import CurveFiter
from ...logger_utils import SingleLogger
class Delimiter:
def __init__(self, target_dim, td_len=1., fd_len=0., unit_len=1., max_grp_size=2... | 11,972 | 43.018382 | 182 | py |
dpro | dpro-master/dpro/cost_model/_mixed_precision/test_rst.py | ''' This script is used to collect TF AMP strategy and test the mixed precision search resutls'''
import re
import os
import json
import argparse
parser = argparse.ArgumentParser(description="AMP Parser",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("--option", type=str, required... | 4,851 | 34.676471 | 153 | py |
dpro | dpro-master/dpro/cost_model/_tsfs/__init__.py | 0 | 0 | 0 | py | |
dpro | dpro-master/dpro/cost_model/_tsfs/cost_model.py | import numpy as np
import os
import json
from ...logger_utils import SingleLogger
from ...base import bcolors
def piecewise_linear_3seg(x, x0, y0, x1, y1, k2):
return np.piecewise(x, [x <= x0, x > x1],
[
lambda x: y0,
lambda x: (x - x1) + y1,
lambda x: k2 * (x - x0) + ... | 5,991 | 40.324138 | 128 | py |
dpro | dpro-master/dpro/cost_model/_xla/__init__.py | 0 | 0 | 0 | py | |
dpro | dpro-master/dpro/cost_model/_xla/execute_graph.py | import tensorflow as tf
from tensorflow.python.client import timeline
import numpy as np
import os
import json
from tensorflow.python.client import timeline
def get_shape_from_placeholder(placeholder_op):
dim_protos = placeholder_op.get_attr("shape").dim
return [d.size for d in dim_protos]
def get_dtype_from_... | 2,205 | 39.851852 | 147 | py |
dpro | dpro-master/dpro/cost_model/_xla/gen_dataset_utils.py | import shutil
import re
import os
import subprocess
import json
import traceback
from pathlib import Path
import copy
import tensorflow as tf
try:
GraphDef = tf.GraphDef
except:
GraphDef = tf.compat.v1.GraphDef
try:
NodeDef = tf.NodeDef
except:
NodeDef = tf.compat.v1.NodeDef
try:
convert_variables_t... | 41,847 | 44.046286 | 131 | py |
dpro | dpro-master/dpro/cost_model/_xla/gen_samples.py | from collections import deque
import tensorflow as tf
from google.protobuf import text_format
from google.protobuf.json_format import MessageToJson
import networkx as nx
import random
import traceback
import pickle
import numpy as np
import pickle
import os
import hashlib
import json
from scipy.special import softmax
f... | 33,345 | 47.257598 | 153 | py |
dpro | dpro-master/dpro/cost_model/_xla/p_dispersion.py | import numpy as np
import random
import cvxopt
import os
from scipy.sparse import csr_matrix, eye as speye, vstack
from tqdm import tqdm, trange
from multiprocessing import Pool
MUL_DELTA = 10
# reference: https://stackoverflow.com/a/35566620
def scipy_sparse_to_spmatrix(A):
coo = A.tocoo()
SP = cvxopt.spmat... | 8,622 | 35.383966 | 141 | py |
dpro | dpro-master/dpro/cost_model/_xla/pk_graph.py | import networkx as nx
import random
from ...trace_utils import _parse_tf_layer_names
class PKGraphCycleError(Exception):
pass
def get_all_pred_succ_nx(_dag: nx.DiGraph, nodes_to_contract):
all_nodes = set(nodes_to_contract)
all_predecessors = set()
all_successors = set()
new_node_name = ""
fo... | 21,024 | 41.820774 | 115 | py |
dpro | dpro-master/dpro/cost_model/_xla/process_trace.py | import gzip
import json
import os
import time
TRACE_SUFFIX = "trace.json.gz"
XLA_DUMP_SUFFIX = "after_optimizations.txt"
def search_for_file(profile_dir, suffix):
for dir_path, dir_names, file_names in os.walk(profile_dir):
for fn in file_names:
if fn.endswith(suffix):
return o... | 4,824 | 32.506944 | 128 | py |
dpro | dpro-master/dpro/cost_model/_xla/utils.py | class CMPaths:
DATASET_DIR = "dataset"
DEBUG_DIR = "debug"
HLO_DIR = "hlos"
PROFILE_DIR = "xla_profile"
FEATURE_DIR = "features"
MODULES_DIR = "modules"
RAW_SUBGRAPH_DIR = "generated_subgraph"
LABEL_FILE = "labels.txt"
TF_SUPPORTED_OPS_FILE = "tf_xla_supported_ops.txt"
METADATA... | 2,438 | 33.842857 | 102 | py |
dpro | dpro-master/dpro/cost_model/_xla/xla_module_cost_model.py | import os
import pickle
import json
import math
import shutil
import random
import traceback
import numpy as np
from multiprocessing import Pool
from tqdm import tqdm, trange
import scipy.optimize as scipy_optimize
from collections import defaultdict
import tensorflow as tf
from tensorflow import keras
from tensorflow.... | 55,140 | 47.840567 | 149 | py |
dpro | dpro-master/dpro/cost_model/_xla/xla_run_generate_kernel_dataset.sh | #!/bin/bash
sudo -i
cd ${HOME}/
rm -rf byteprofile-analysis
git clone https://github.com/joapolarbear/byteprofile-analysis.git
cd byteprofile-analysis
### install requirements
pip3 install -r requirements.txt
### Recompile XLA related Part or directly download it
# export PATH=/usr/local/cuda/bin:/usr/local/nvidia/bi... | 2,915 | 32.136364 | 196 | sh |
dpro | dpro-master/dpro/cost_model/_xla/xla_run_test_module_cm.sh | # where the modified tensorflow locates
export BPF_TF_PATH="/root/tensorflow"
# this is the GPU used to compile XLA modules. Cost model will be run on another
# differnt GPU (specify one GPU here only)
export BPF_COST_MODEL_PROFILE_GPU="0"
# modify these
DATASET_DIR="/PATH/TO/DATASET/DIR"
COST_MODEL_DIR="/PATH/TO/COST... | 422 | 37.454545 | 93 | sh |
dpro | dpro-master/dpro/cost_model/_xla/xla_run_train_module_cm.sh | # where the modified tensorflow locates
export BPF_TF_PATH="/root/tensorflow"
# this is the GPU used to compile XLA modules. Cost model will be run on another
# differnt GPU (specify one GPU here only)
export BPF_COST_MODEL_PROFILE_GPU="0"
# modify these
DATASET_DIR="/opt/tiger/xla/kernel_dataset"
OUTPUT_DIR="/opt/tig... | 427 | 34.666667 | 86 | sh |
dpro | dpro-master/dpro/cost_model/_xla/xlatools.py | from pathlib import Path
import subprocess
import os
from .utils import CMEnvs
from ...logger_utils import SingleLogger
from ...base import bcolors
if CMEnvs.TF_PATH in os.environ:
BPF_TF_PREFIX = os.environ[CMEnvs.TF_PATH]
else:
BPF_TF_PREFIX = None
SingleLogger().warn(bcolors.CRED + "Environment {} not ... | 4,879 | 45.47619 | 133 | py |
dpro | dpro-master/dpro/helper/combine_json.py | ''' Combine trace files
* Usage
python3 combine_trace.py files/to/combine path/to/dump/rst pid/names bias
The first item of the command parameter is the path of the json file to be combined, separated by commas;
The second item is the path to store the result;
The third item is the relabel pid for e... | 1,730 | 31.055556 | 109 | py |
dpro | dpro-master/dpro/helper/compare_graph.py | import networkx as nx
from google.protobuf.json_format import MessageToJson
from google.protobuf.text_format import Parse
import tensorflow as tf
import json
try:
GraphDef = tf.GraphDef
except:
GraphDef = tf.compat.v1.GraphDef
def tf_relabel_func(_name, update_nodes_in_dag):
for prefix in ["Comm.", "Comp.... | 2,878 | 33.27381 | 108 | py |
dpro | dpro-master/dpro/helper/get_iter_time_from_trace.py | import json
with open("/Users/chenyu/Downloads/20210127_02_hvd_tf_vgg16_rdma_apply_xla_no_tensor_fusion/combined.json", "r") as f:
trace = json.load(f)
# one_pid = -1
pids = set()
for ev in trace["traceEvents"]:
# if ev["ph"] == "M":
# if ev["name"] == "process_name" and "name" in ev["args"]:
# ... | 2,281 | 35.222222 | 118 | py |
dpro | dpro-master/dpro/helper/tf_flops_profile.py |
'''
Refer to: https://gist.github.com/shinseung428/752f284d1c065870d7f5a7e4208f0583
'''
import json
import os, sys
import tensorflow as tf
from google.protobuf.json_format import Parse as ParseJSON
from google.protobuf.text_format import Parse as ParseText
from google.protobuf.json_format import MessageToJson
try... | 2,680 | 33.371795 | 83 | py |
dpro | dpro-master/dpro/helper/tf_helper.py | from google.protobuf.json_format import MessageToJson
from google.protobuf.json_format import Parse as parse_protobuf_json
import tensorflow as tf
import os
import threading
# Try to support both tf2 and tf1
try:
GraphDef = tf.GraphDef
except:
GraphDef = tf.compat.v1.GraphDef
from tensorflow.python.client impo... | 23,052 | 46.531959 | 152 | py |
dpro | dpro-master/dpro/helper/visualize.py | import json
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import os, sys
import math
from ..arg_utils import SingleArg
args = SingleArg().args
''' visualize the number of operators being queued on each device for replayer
'''
def init_fig_base(cnt):
h = math.ceil(math.sqrt(cnt))
w ... | 1,591 | 24.677419 | 97 | py |
dpro | dpro-master/dpro/hvd/__init__.py | 0 | 0 | 0 | py | |
dpro | dpro-master/dpro/hvd/graph.py | from enum import Enum
import re
class NCCL_ALGO(Enum):
TREE=0
RING=1
class ncclGraph:
''' Store the graph information accross multiple GPUs and machines
'''
def __init__(self, algo=NCCL_ALGO.RING):
'''
One example of the graph is shown below
Algorithm: Tree
Chan... | 20,324 | 41.34375 | 186 | py |
dpro | dpro-master/dpro/memory/README.md | # Memory Estimation
Usage:
```python
from memory import MemoryEstimator
memory_estimator = MemoryEstimator("TENSORFLOW")
estimated_memory_usage = memory_estimator.estimate(dag, param_dict)
```
default unit: MB
## TODO
- [ ] workload specific. need to know the model.
e.g. select forward nodes
```py
def _is_forwa... | 444 | 16.115385 | 71 | md |
dpro | dpro-master/dpro/memory/__init__.py | from .estimator import MemoryEstimator
__all__ = [
"MemoryEstimator"
] | 76 | 11.833333 | 38 | py |
dpro | dpro-master/dpro/memory/cost_model.py | from functools import partial
from copy import deepcopy
from .gradient_accumulation import get_gradient_accumulation_edited_graph
from ..logger_utils import SingleLogger
from ..cost_model.base import _BaseGraphPass
from .recomputation import get_recomputation_edited_graph
from ..replay import Replayer
from .utils impo... | 6,074 | 36.042683 | 120 | py |
dpro | dpro-master/dpro/memory/estimator.py | from .node import Node
from .schedule import Schedule
from .utils import *
import networkx as nx
class MemoryEstimator:
def __init__(self, platform):
self.platform = platform
self.default_batch_size = 32 # TODO(yuchen): should read from graph
self.batch_size = self.default_batch_size
... | 4,567 | 33.870229 | 88 | py |
dpro | dpro-master/dpro/memory/gradient_accumulation.py | from .utils import *
def get_gradient_accumulation_edited_graph(dag, verbose=False):
_apply_gradient_accumulation(dag, verbose)
return True
def _apply_gradient_accumulation(dag, verbose):
_update_dag(dag, verbose)
def _update_dag(dag, verbose):
computation_nodes = filter_out_comm_nodes(dag)
up... | 722 | 25.777778 | 63 | py |
dpro | dpro-master/dpro/memory/node.py | import numpy as np
class Node:
def __init__(self, name, op, input, dtype, shape, time):
self._name = name
self._op = op
self._input = input
self._dtype = dtype
self._shape = shape
self._requires_grad = True
self._inplace = False
self._time = time
... | 4,957 | 21.639269 | 72 | py |
dpro | dpro-master/dpro/memory/recomputation.py | import re
import networkx as nx
from itertools import islice
from .utils import *
from ..logger_utils import SingleLogger
class CheckpointsSelector:
@classmethod
def get_checkpoint_selector(cls, mode):
if mode == "speed":
return SpeedCheckpointsSelector()
elif mode == "memory":
... | 5,112 | 33.086667 | 89 | py |
dpro | dpro-master/dpro/memory/schedule.py | from .node import Node
class Schedule:
def __init__(self, platform):
self._parameters = []
self._operators = []
self._node_collection = {}
self.lists = self._get_platform_memory_lists(platform)
def add(self, node):
"""add node into schedule and determine whether it run... | 2,323 | 26.341176 | 73 | py |
dpro | dpro-master/dpro/memory/utils.py | from functools import partial
import networkx as nx
DEL = "->"
RANK0_PREFIX = "host0.rank0"
FORWARD_CAT = "FW."
BACKWARD_CAT = "BW."
def remove_prefix(text, prefix):
if text.startswith(prefix):
return text[len(prefix):]
return text
def remove_nodes_prefix(nodes, prefix):
func = partial(remove_p... | 2,701 | 23.788991 | 81 | py |
dpro | dpro-master/dpro/ml_platform/__init__.py | 0 | 0 | 0 | py | |
dpro | dpro-master/dpro/ml_platform/mxnet/__init__.py | 0 | 0 | 0 | py | |
dpro | dpro-master/dpro/ml_platform/mxnet/metadata.py | import json
import numpy as np
import os, sys
import re
import networkx as nx
# (TODO): delete, 20201026
# FULL_HEADERS = {
# "base": ["avg", "G", "S_mul", "S_add", "S_in", "S_out", "S_wei"],
# "conv": ["avg", "G", "S_mul", "S_add", "S_in", "S_out", "S_wei", "H", "W", "C", "R", "S", "P", "Q", "K", "B", "use_bi... | 17,771 | 39.117381 | 146 | py |
dpro | dpro-master/dpro/ml_platform/tensorflow/__init__.py | from . import memory_lists | 26 | 26 | 26 | py |