Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into linalg-kron
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanYashchuk committed Nov 2, 2020
2 parents 719a687 + 1cc1da5 commit a1b3255
Show file tree
Hide file tree
Showing 399 changed files with 11,419 additions and 3,077 deletions.
6 changes: 5 additions & 1 deletion .circleci/cimodel/data/pytorch_build_data.py
Expand Up @@ -84,7 +84,11 @@
("gcc", [
("9", [
("3.8", [
("coverage", [XImportant(True)]),
("coverage", [
(True, [
("shard_test", [XImportant(True)]),
]),
]),
]),
]),
]),
Expand Down
9 changes: 5 additions & 4 deletions .circleci/cimodel/data/pytorch_build_definitions.py
Expand Up @@ -272,6 +272,7 @@ def instantiate_configs():
compiler_version = fc.find_prop("compiler_version")
is_xla = fc.find_prop("is_xla") or False
is_asan = fc.find_prop("is_asan") or False
is_coverage = fc.find_prop("is_coverage") or False
is_onnx = fc.find_prop("is_onnx") or False
is_pure_torch = fc.find_prop("is_pure_torch") or False
is_vulkan = fc.find_prop("is_vulkan") or False
Expand Down Expand Up @@ -311,6 +312,10 @@ def instantiate_configs():
python_version = fc.find_prop("pyver")
parms_list[0] = fc.find_prop("abbreviated_pyver")

if is_coverage:
parms_list_ignored_for_docker_image.append("coverage")
python_version = fc.find_prop("pyver")

if is_onnx:
parms_list.append("onnx")
python_version = fc.find_prop("pyver")
Expand All @@ -325,17 +330,13 @@ def instantiate_configs():
is_important = fc.find_prop("is_important") or False
parallel_backend = fc.find_prop("parallel_backend") or None
build_only = fc.find_prop("build_only") or False
is_coverage = fc.find_prop("is_coverage") or False
shard_test = fc.find_prop("shard_test") or False
# TODO: fix pure_torch python test packaging issue.
if shard_test:
restrict_phases = ["build"] if restrict_phases is None else restrict_phases
restrict_phases.extend(["test1", "test2"])
if build_only or is_pure_torch:
restrict_phases = ["build"]
if is_coverage and restrict_phases is None:
restrict_phases = ["build", "coverage_test"]


gpu_resource = None
if cuda_version and cuda_version != "10":
Expand Down
23 changes: 16 additions & 7 deletions .circleci/config.yml
Expand Up @@ -655,9 +655,11 @@ jobs:
echo "Retrieving test reports"
docker cp $id:/var/lib/jenkins/workspace/test/test-reports ./ || echo 'No test reports found!'
if [[ ${BUILD_ENVIRONMENT} == *"coverage"* ]]; then
echo "Retrieving coverage report"
echo "Retrieving Python coverage report"
docker cp $id:/var/lib/jenkins/workspace/test/.coverage ./test
docker cp $id:/var/lib/jenkins/workspace/test/coverage.xml ./test
echo "Retrieving C++ coverage report"
docker cp $id:/var/lib/jenkins/workspace/build/coverage.info ./test
python3 -mpip install codecov
python3 -mcodecov
fi
Expand Down Expand Up @@ -969,7 +971,7 @@ jobs:

- run:
name: Build
no_output_timeout: "1h"
no_output_timeout: "90m"
command: |
# Do not set -u here; there is some problem with CircleCI
# variable expansion with PROMPT_COMMAND
Expand Down Expand Up @@ -6877,16 +6879,23 @@ workflows:
docker_image: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-bionic-py3.6-clang9"
resource_class: large
- pytorch_linux_build:
name: pytorch_linux_bionic_py3_8_gcc9_build
name: pytorch_linux_bionic_py3_8_gcc9_coverage_build
requires:
- "docker-pytorch-linux-bionic-py3.8-gcc9"
build_environment: "pytorch-linux-bionic-py3.8-gcc9-build"
build_environment: "pytorch-linux-bionic-py3.8-gcc9-coverage-build"
docker_image: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-bionic-py3.8-gcc9"
- pytorch_linux_test:
name: pytorch_linux_bionic_py3_8_gcc9_coverage_test1
requires:
- pytorch_linux_bionic_py3_8_gcc9_coverage_build
build_environment: "pytorch-linux-bionic-py3.8-gcc9-coverage-test1"
docker_image: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-bionic-py3.8-gcc9"
resource_class: large
- pytorch_linux_test:
name: pytorch_linux_bionic_py3_8_gcc9_coverage_test
name: pytorch_linux_bionic_py3_8_gcc9_coverage_test2
requires:
- pytorch_linux_bionic_py3_8_gcc9_build
build_environment: "pytorch-linux-bionic-py3.8-gcc9-coverage_test"
- pytorch_linux_bionic_py3_8_gcc9_coverage_build
build_environment: "pytorch-linux-bionic-py3.8-gcc9-coverage-test2"
docker_image: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-bionic-py3.8-gcc9"
resource_class: large
- pytorch_linux_build:
Expand Down
2 changes: 1 addition & 1 deletion .circleci/docker/centos-rocm/Dockerfile
Expand Up @@ -27,7 +27,7 @@ RUN rm install_glibc.sh
ADD ./common/install_user.sh install_user.sh
RUN bash ./install_user.sh && rm install_user.sh

# Install conda
# Install conda and other packages (e.g., numpy, coverage, pytest)
ENV PATH /opt/conda/bin:$PATH
ARG ANACONDA_PYTHON_VERSION
ADD ./common/install_conda.sh install_conda.sh
Expand Down
38 changes: 34 additions & 4 deletions .circleci/docker/common/install_cache.sh
Expand Up @@ -2,6 +2,28 @@

set -ex

install_ubuntu() {
echo "Preparing to build sccache from source"
apt-get update
apt-get install -y cargo pkg-config libssl-dev
echo "Checking out sccache repo"
git clone https://github.com/pytorch/sccache
cd sccache
echo "Building sccache"
cargo build --release
cp target/release/sccache /opt/cache/bin
echo "Cleaning up"
cd ..
rm -rf sccache
apt-get remove -y cargo rustc
apt-get autoclean && apt-get clean
}

install_binary() {
echo "Downloading sccache binary from S3 repo"
curl --retry 3 https://s3.amazonaws.com/ossci-linux/sccache -o /opt/cache/bin/sccache
}

mkdir -p /opt/cache/bin
mkdir -p /opt/cache/lib
sed -e 's|PATH="\(.*\)"|PATH="/opt/cache/bin:\1"|g' -i /etc/environment
Expand All @@ -11,12 +33,20 @@ export PATH="/opt/cache/bin:$PATH"
if [ -n "$ROCM_VERSION" ]; then
curl --retry 3 http://repo.radeon.com/misc/.sccache_amd/sccache -o /opt/cache/bin/sccache
else
curl --retry 3 https://s3.amazonaws.com/ossci-linux/sccache -o /opt/cache/bin/sccache
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
case "$ID" in
ubuntu)
install_ubuntu
;;
*)
install_binary
;;
esac
fi
chmod a+x /opt/cache/bin/sccache

function write_sccache_stub() {
printf "#!/bin/sh\nexec sccache $(which $1) \"\$@\"" > "/opt/cache/bin/$1"
printf "#!/bin/sh\nif [ \$(ps -p \$PPID -o comm=) != sccache ]; then\n exec sccache $(which $1) \"\$@\"\nelse\n exec $(which $1) \"\$@\"\nfi" > "/opt/cache/bin/$1"
chmod a+x "/opt/cache/bin/$1"
}

Expand All @@ -38,8 +68,8 @@ if [ -n "$CUDA_VERSION" ]; then
# where CUDA is installed. Instead, we install an nvcc symlink outside
# of the PATH, and set CUDA_NVCC_EXECUTABLE so that we make use of it.

printf "#!/bin/sh\nexec sccache $(which nvcc) \"\$@\"" > /opt/cache/lib/nvcc
chmod a+x /opt/cache/lib/nvcc
write_sccache_stub nvcc
mv /opt/cache/bin/nvcc /opt/cache/lib/
fi

if [ -n "$ROCM_VERSION" ]; then
Expand Down
4 changes: 2 additions & 2 deletions .circleci/docker/common/install_conda.sh
Expand Up @@ -96,13 +96,13 @@ if [ -n "$ANACONDA_PYTHON_VERSION" ]; then
# TODO: This isn't working atm
conda_install nnpack -c killeent

# Install some other packages
# Install some other packages, including those needed for Python test reporting
# TODO: Why is scipy pinned
# numba & llvmlite is pinned because of https://github.com/numba/numba/issues/4368
# scikit-learn is pinned because of
# https://github.com/scikit-learn/scikit-learn/issues/14485 (affects gcc 5.5
# only)
as_jenkins pip install --progress-bar off pytest scipy==1.1.0 scikit-learn==0.20.3 scikit-image librosa>=0.6.2 psutil numba==0.46.0 llvmlite==0.30.0
as_jenkins pip install --progress-bar off pytest scipy==1.1.0 scikit-learn==0.20.3 scikit-image librosa>=0.6.2 psutil numba==0.46.0 llvmlite==0.30.0 unittest-xml-reporting coverage

popd
fi
1 change: 1 addition & 0 deletions .circleci/docker/common/install_gcc.sh
Expand Up @@ -15,6 +15,7 @@ if [ -n "$GCC_VERSION" ]; then

update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-"$GCC_VERSION" 50
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-"$GCC_VERSION" 50
update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-"$GCC_VERSION" 50

# Cleanup package manager
apt-get autoclean && apt-get clean
Expand Down
6 changes: 4 additions & 2 deletions .circleci/docker/common/install_lcov.sh
Expand Up @@ -2,5 +2,7 @@

set -ex

sudo apt-get -qq update
sudo apt-get -qq install lcov
git clone --branch v1.15 https://github.com/linux-test-project/lcov.git
pushd lcov
sudo make install # will be installed in /usr/local/bin/lcov
popd
2 changes: 1 addition & 1 deletion .circleci/docker/ubuntu-cuda/Dockerfile
Expand Up @@ -24,7 +24,7 @@ ARG KATEX
ADD ./common/install_katex.sh install_katex.sh
RUN bash ./install_katex.sh && rm install_katex.sh

# Install conda
# Install conda and other packages (e.g., numpy, coverage, pytest)
ENV PATH /opt/conda/bin:$PATH
ARG ANACONDA_PYTHON_VERSION
ADD ./common/install_conda.sh install_conda.sh
Expand Down
2 changes: 1 addition & 1 deletion .circleci/docker/ubuntu-rocm/Dockerfile
Expand Up @@ -21,7 +21,7 @@ RUN bash ./install_clang.sh && rm install_clang.sh
ADD ./common/install_user.sh install_user.sh
RUN bash ./install_user.sh && rm install_user.sh

# Install conda
# Install conda and other packages (e.g., numpy, coverage, pytest)
ENV PATH /opt/conda/bin:$PATH
ARG ANACONDA_PYTHON_VERSION
ADD ./common/install_conda.sh install_conda.sh
Expand Down
2 changes: 1 addition & 1 deletion .circleci/docker/ubuntu/Dockerfile
Expand Up @@ -33,7 +33,7 @@ ARG KATEX
ADD ./common/install_katex.sh install_katex.sh
RUN bash ./install_katex.sh && rm install_katex.sh

# Install conda
# Install conda and other packages (e.g., numpy, coverage, pytest)
ENV PATH /opt/conda/bin:$PATH
ARG ANACONDA_PYTHON_VERSION
ADD ./common/install_conda.sh install_conda.sh
Expand Down
2 changes: 1 addition & 1 deletion .circleci/verbatim-sources/job-specs/binary-job-specs.yml
Expand Up @@ -174,7 +174,7 @@

- run:
name: Build
no_output_timeout: "1h"
no_output_timeout: "90m"
command: |
# Do not set -u here; there is some problem with CircleCI
# variable expansion with PROMPT_COMMAND
Expand Down
4 changes: 3 additions & 1 deletion .circleci/verbatim-sources/job-specs/pytorch-job-specs.yml
Expand Up @@ -217,9 +217,11 @@ jobs:
echo "Retrieving test reports"
docker cp $id:/var/lib/jenkins/workspace/test/test-reports ./ || echo 'No test reports found!'
if [[ ${BUILD_ENVIRONMENT} == *"coverage"* ]]; then
echo "Retrieving coverage report"
echo "Retrieving Python coverage report"
docker cp $id:/var/lib/jenkins/workspace/test/.coverage ./test
docker cp $id:/var/lib/jenkins/workspace/test/coverage.xml ./test
echo "Retrieving C++ coverage report"
docker cp $id:/var/lib/jenkins/workspace/build/coverage.info ./test
python3 -mpip install codecov
python3 -mcodecov
fi
Expand Down
2 changes: 1 addition & 1 deletion .flake8
Expand Up @@ -12,5 +12,5 @@ ignore =
B007,B008,
# these ignores are from flake8-comprehensions; please fix!
C400,C401,C402,C403,C404,C405,C407,C411,C413,C414,C415
per-file-ignores = __init__.py: F401
per-file-ignores = __init__.py: F401 torch/utils/cpp_extension.py: B950
exclude = docs/src,venv,third_party,caffe2,scripts,docs/caffe2,torch/lib/include,torch/lib/tmp_install,build,torch/include,*.pyi,.git,build,build_test_custom_build,build_code_analyzer
9 changes: 6 additions & 3 deletions .github/workflows/lint.yml
Expand Up @@ -42,6 +42,10 @@ jobs:
run: |
sudo apt-get install -y doxygen && pip install -r requirements.txt
cd docs/cpp/source && ./check-doxygen.sh
- name: CUDA kernel launch check
run: |
set -eux
python torch/testing/check_kernel_launches.py |& tee ${GITHUB_WORKSPACE}/cuda_kernel_launch_checks.txt
flake8-py3:
runs-on: ubuntu-latest
Expand All @@ -65,11 +69,10 @@ jobs:
id: get_pr_tip
- name: Run flake8
run: |
set -eux
set -eux -o pipefail
pip install flake8==3.8.2 flake8-bugbear flake8-comprehensions flake8-executable flake8-pyi==20.5.0 mccabe pycodestyle==2.6.0 pyflakes==2.2.0
flake8 --version
flake8 > ${GITHUB_WORKSPACE}/flake8-output.txt
cat ${GITHUB_WORKSPACE}/flake8-output.txt
flake8 | tee ${GITHUB_WORKSPACE}/flake8-output.txt
- name: Add annotations
uses: pytorch/add-annotations-github-action@master
with:
Expand Down
2 changes: 1 addition & 1 deletion .jenkins/caffe2/test.sh
Expand Up @@ -171,7 +171,7 @@ if [[ "$BUILD_ENVIRONMENT" == *onnx* ]]; then
# default pip version is too old(9.0.2), unable to support tag `manylinux2010`.
# Fix the pip error: Couldn't find a version that satisfies the requirement
pip install --upgrade pip
pip install -q --user ort-nightly==1.5.0.dev202009182
pip install -q --user onnxruntime==1.5.2
fi
"$ROOT_DIR/scripts/onnx/test.sh"
fi
5 changes: 5 additions & 0 deletions .jenkins/pytorch/build.sh
Expand Up @@ -42,6 +42,11 @@ if [[ "$BUILD_ENVIRONMENT" == *cuda* ]]; then
nvcc --version
fi

if [[ "$BUILD_ENVIRONMENT" == *coverage* ]]; then
# enable build option in CMake
export USE_CPP_CODE_COVERAGE=ON
fi

# TODO: Don't run this...
pip_install -r requirements.txt || true

Expand Down
60 changes: 60 additions & 0 deletions .jenkins/pytorch/codegen-test.sh
@@ -0,0 +1,60 @@
#!/usr/bin/env bash

# This script can also be used to test whether your diff changes any codegen output.
#
# Run it before and after your change:
# .jenkins/pytorch/codegen-test.sh <baseline_output_dir>
# .jenkins/pytorch/codegen-test.sh <test_output_dir>
#
# Then run diff to compare the generated files:
# diff -Naur <baseline_output_dir> <test_output_dir>

set -eu -o pipefail

if [ "$#" -eq 0 ]; then
COMPACT_JOB_NAME="${BUILD_ENVIRONMENT}"
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
OUT="$(dirname "${BASH_SOURCE[0]}")/../../codegen_result"
else
OUT=$1
fi

set -x

rm -rf "$OUT"

# aten codegen
python -m tools.codegen.gen \
-d "$OUT"/torch/share/ATen

# torch codegen
python -m tools.setup_helpers.generate_code \
--declarations-path "$OUT"/torch/share/ATen/Declarations.yaml \
--install_dir "$OUT"

# pyi codegen
mkdir -p "$OUT"/pyi/torch/_C
mkdir -p "$OUT"/pyi/torch/nn
python -m tools.pyi.gen_pyi \
--declarations-path "$OUT"/torch/share/ATen/Declarations.yaml \
--out "$OUT"/pyi

# autograd codegen (called by torch codegen but can run independently)
python -m tools.autograd.gen_autograd \
"$OUT"/torch/share/ATen/Declarations.yaml \
"$OUT"/autograd \
tools/autograd

# unboxing_wrappers codegen (called by torch codegen but can run independently)
mkdir -p "$OUT"/unboxing_wrappers
python -m tools.jit.gen_unboxing_wrappers \
"$OUT"/torch/share/ATen/Declarations.yaml \
"$OUT"/unboxing_wrappers \
tools/jit/templates

# annotated_fn_args codegen (called by torch codegen but can run independently)
mkdir -p "$OUT"/annotated_fn_args
python -m tools.autograd.gen_annotated_fn_args \
"$OUT"/torch/share/ATen/Declarations.yaml \
"$OUT"/annotated_fn_args \
tools/autograd

0 comments on commit a1b3255

Please sign in to comment.