Skip to content

Collect coverage data. #9107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,16 @@ build -c opt

build --config=short_logs

# PyTorch/XLA uses exceptions to communicate with Python.
build --copt=-fexceptions

# Force GCC because clang/bazel has issues.
build --action_env=CC=gcc
build --action_env=CXX=g++
build --spawn_strategy=standalone

###########################################################################

build:clang --action_env=CC=/usr/bin/clang-17
build:clang --action_env=CXX=/usr/bin/clang++-17
build:gcc --action_env=CC=gcc
build:gcc --action_env=CXX=g++

build:clang --action_env=CC=/usr/lib/llvm-17/bin/clang
build:clang --action_env=CXX=/usr/lib/llvm-17/bin/clang++

# clang requires the sandbox mode. Without this, `bazel build` generates an
# error like:
Expand Down Expand Up @@ -251,7 +249,9 @@ build:linux --copt="-Werror=unused-result"
build:linux --copt="-Wswitch"
build:linux --copt="-Werror=switch"
# Required for building with clang
build:linux --copt="-Wno-error=unused-but-set-variable"
# build:linux --copt="-Wno-error=unused-but-set-variable"
build:linux --copt="-Wno-gnu-offsetof-extensions"
build:linux --copt="-Wno-unused-command-line-argument"

# Only include debug info for files not under XLA.
build:dbg -c dbg
Expand Down
19 changes: 7 additions & 12 deletions .github/scripts/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
set -ex


function run_torch_xla_python_tests() {
XLA_DIR=$1
USE_COVERAGE="${2:-0}"

pushd $XLA_DIR
echo "Running Python Tests"
./test/run_tests.sh
if [ "$USE_COVERAGE" != "0" ]; then
pip install coverage==6.5.0 --upgrade
pip install coverage-lcov
pip install toml
./test/run_tests.sh
coverage combine
mkdir lcov && cp .coverage lcov/
coverage-lcov --data_file_path lcov/.coverage
coverage html
cp lcov.info htmlcov/
mv htmlcov ~/
chmod -R 755 ~/htmlcov
else
./test/run_tests.sh
coverage lcov --omit="/tmp/*" --ignore-errors -o $COVERAGE_FILE.info
fi
popd
}
Expand Down Expand Up @@ -81,6 +72,10 @@ function run_torch_xla_benchmark_tests() {
echo "Running Torchbench Tests"
test/benchmarks/run_torchbench_tests.sh "${TORCHBENCH_MODELS[@]}"
popd
if [ "$USE_COVERAGE" != "0" ]; then
coverage combine
coverage lcov --omit="/tmp/*" --ignore-errors -o $COVERAGE_FILE.info
fi
}

PYTORCH_DIR=$1
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/_build_plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ on:
type: number
description: Timeout in minutes for the build job
default: 120
has_code_changes:
required: false
type: string
description: Whether to run full workflow or not
default: 'true'
secrets:
gcloud-service-key:
required: true
Expand All @@ -37,31 +32,23 @@ jobs:
BAZEL_REMOTE_CACHE: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
steps:
- name: Checkout actions
if: inputs.has_code_changes == 'true'
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/workflows/setup
path: .actions
- name: Setup
if: inputs.has_code_changes == 'true'
uses: ./.actions/.github/workflows/setup
with:
torch-commit: ${{ inputs.torch-commit }}
cuda: true
- name: Build
if: inputs.has_code_changes == 'true'
shell: bash
run: |
cd pytorch/xla/infra/ansible
ansible-playbook playbook.yaml -vvv -e "stage=build_plugin arch=amd64 accelerator=cuda cuda_compute_capabilities=5.2,7.5,8.6 src_root=${GITHUB_WORKSPACE} cache_suffix=-ci" --skip-tags=fetch_srcs,install_deps
- name: Upload wheel
if: inputs.has_code_changes == 'true'
uses: actions/upload-artifact@v4
with:
name: cuda-plugin
path: /dist/*.whl
- name: Report no code changes
if: inputs.has_code_changes == 'false'
run: |
echo "No code changes were detected that require running the full test suite."
13 changes: 0 additions & 13 deletions .github/workflows/_build_torch_with_cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ on:
type: number
description: Timeout in minutes for the build job
default: 120
has_code_changes:
required: false
type: string
description: Whether to run full workflow or not
default: 'true'
jobs:
build:
runs-on: ${{ inputs.runner }}
Expand All @@ -38,31 +33,23 @@ jobs:
MAX_JOBS: 24
steps:
- name: Checkout actions
if: inputs.has_code_changes == 'true'
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/workflows/setup
path: .actions
- name: Setup
if: inputs.has_code_changes == 'true'
uses: ./.actions/.github/workflows/setup
with:
torch-commit: ${{ inputs.torch-commit }}
cuda: true
- name: Build PyTorch with CUDA enabled
if: inputs.has_code_changes == 'true'
shell: bash
run: |
cd pytorch
python setup.py bdist_wheel
- name: Upload wheel
if: inputs.has_code_changes == 'true'
uses: actions/upload-artifact@v4
with:
name: torch-with-cuda
path: pytorch/dist/*.whl
- name: Report no code changes
if: inputs.has_code_changes == 'false'
run: |
echo "No code changes were detected that require running the full test suite."
15 changes: 1 addition & 14 deletions .github/workflows/_build_torch_xla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ on:
type: number
description: Timeout in minutes for the build job
default: 120
has_code_changes:
required: false
type: string
description: Whether to run full workflow or not
default: 'true'
secrets:
gcloud-service-key:
required: true
Expand All @@ -40,41 +35,33 @@ jobs:
BAZEL_REMOTE_CACHE: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
BAZEL_JOBS: 16
BUILD_CPP_TESTS: 1
GCNO_OUTPUT_DIR: "/tmp/torch-xla-gcno"
steps:
# Need to check out local composite actions before using them
# https://github.com/orgs/community/discussions/11771
- name: Checkout actions
if: inputs.has_code_changes == 'true'
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/workflows/setup
path: .actions
- name: Setup
if: inputs.has_code_changes == 'true'
uses: ./.actions/.github/workflows/setup
with:
torch-commit: ${{ inputs.torch-commit }}
- name: Build
if: inputs.has_code_changes == 'true'
shell: bash
run: |
cd pytorch/xla/infra/ansible
ansible-playbook playbook.yaml -vvv -e "stage=build arch=amd64 accelerator=tpu src_root=${GITHUB_WORKSPACE} bundle_libtpu=0 build_cpp_tests=1 git_versioned_xla_build=1 cache_suffix=-ci" --skip-tags=fetch_srcs,install_deps
- name: Upload wheel
if: inputs.has_code_changes == 'true'
uses: actions/upload-artifact@v4
with:
name: torch-xla-wheels
path: /dist/*.whl
- name: Upload CPP test binaries
if: inputs.has_code_changes == 'true'
uses: actions/upload-artifact@v4
with:
name: cpp-test-bin
path: /tmp/test/bin
- name: Report no code changes
if: inputs.has_code_changes == 'false'
run: |
echo "No code changes were detected that require running the full test suite."

111 changes: 0 additions & 111 deletions .github/workflows/_check_code_changes.yml

This file was deleted.

Loading
Loading