Skip to content

Commit 612ad14

Browse files
authored
Merge branch 'main' into rocm_enablement_staging
2 parents 279f4b3 + 6234116 commit 612ad14

File tree

377 files changed

+30338
-9522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

377 files changed

+30338
-9522
lines changed

.github/scripts/validate_binaries.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
pip install ${PYTORCH_PIP_PREFIX} torchao --index-url ${PYTORCH_PIP_DOWNLOAD_URL}
2+
# Intial smoke test, tries importing torchao
23
python ./test/smoke_tests/smoke_tests.py
4+
# Now we install dev-requirments and try to run the tests
5+
pip install -r dev-requirements.txt
6+
pytest test --verbose -s

.github/workflows/build_wheels_linux.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ jobs:
2828
os: linux
2929
with-cpu: enable
3030
with-cuda: enable
31-
with-rocm: disable
31+
with-rocm: enable
32+
with-xpu: enable
3233

3334
build:
3435
needs: generate-matrix
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build Windows Wheels
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- build/packaging/**
7+
- .github/workflows/build_wheels_windows.yml
8+
- setup.py
9+
push:
10+
branches:
11+
- nightly
12+
- main
13+
- release/*
14+
tags:
15+
# NOTE: Binary build pipelines should only get triggered on release candidate builds
16+
# Release candidate tags look like: v1.11.0-rc1
17+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
18+
schedule:
19+
- cron: '0 0 * * *' # Runs at midnight UTC every day
20+
workflow_dispatch:
21+
22+
permissions:
23+
id-token: write
24+
contents: read
25+
26+
jobs:
27+
generate-matrix:
28+
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
29+
with:
30+
package-type: wheel
31+
os: windows
32+
test-infra-repository: pytorch/test-infra
33+
test-infra-ref: main
34+
with-xpu: enable
35+
with-cuda: disable
36+
37+
build:
38+
needs: generate-matrix
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
include:
43+
- repository: pytorch/ao
44+
pre-script: packaging/pre_build_script.sh
45+
env-script: packaging/vc_env_helper.bat
46+
# post-script: "python packaging/wheel/relocate.py"
47+
smoke-test-script: packaging/smoke_test.py
48+
package-name: torchao
49+
name: ${{ matrix.repository }}
50+
uses: pytorch/test-infra/.github/workflows/build_wheels_windows.yml@main
51+
with:
52+
repository: ${{ matrix.repository }}
53+
ref: ""
54+
test-infra-repository: pytorch/test-infra
55+
test-infra-ref: main
56+
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
57+
pre-script: ${{ matrix.pre-script }}
58+
env-script: ${{ matrix.env-script }}
59+
post-script: ${{ matrix.post-script }}
60+
package-name: ${{ matrix.package-name }}
61+
smoke-test-script: ${{ matrix.smoke-test-script }}
62+
trigger-event: ${{ github.event_name }}

.github/workflows/float8_test.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
gpu-arch-type: "cuda"
3030
gpu-arch-version: "12.1"
3131

32-
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
32+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
3333
with:
3434
timeout: 60
3535
runner: ${{ matrix.runs-on }}
@@ -38,8 +38,6 @@ jobs:
3838
script: |
3939
conda create -n venv python=3.9 -y
4040
conda activate venv
41-
echo "::group::Install newer objcopy that supports --set-section-alignment"
42-
yum install -y devtoolset-10-binutils
4341
export PATH=/opt/rh/devtoolset-10/root/usr/bin/:$PATH
4442
python -m pip install --upgrade pip
4543
pip install ${{ matrix.torch-spec }}

.github/workflows/nightly_smoke_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
gpu-arch-version: "12.1"
2727

2828

29-
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
29+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
3030
with:
3131
runner: ${{ matrix.runs-on }}
3232
gpu-arch-type: ${{ matrix.gpu-arch-type }}

.github/workflows/pr-label-check.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: PR Label Check
2+
on:
3+
pull_request:
4+
types: [opened, labeled, unlabeled, synchronize]
5+
6+
jobs:
7+
check-labels:
8+
name: Check PR Labels
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check for Topic label
12+
run: |
13+
# Get the labels using GitHub API
14+
LABELS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
15+
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" \
16+
| jq -r '.labels[].name')
17+
18+
# Check if there are any labels
19+
if [ -z "$LABELS" ]; then
20+
echo "::error::This PR requires at least one topic label. Please add a topic from: https://github.com/pytorch/ao/labels?q=topic"
21+
exit 1
22+
fi
23+
24+
# Check for Topic label
25+
if ! echo "$LABELS" | grep -i "topic:" > /dev/null; then
26+
echo "::error::This PR requires at least one label starting with 'topic:'. Available topics can be found at: https://github.com/pytorch/ao/labels?q=topic"
27+
exit 1
28+
fi
29+
30+
echo "PR has required topic label"

.github/workflows/regression_test.yml

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,43 @@ env:
1818
HF_TOKEN: ${{ secrets.HF_TOKEN }}
1919

2020
jobs:
21-
test:
21+
test-nightly:
2222
strategy:
2323
fail-fast: false
2424
matrix:
2525
include:
26-
- name: CUDA 2.2.2
26+
- name: CUDA Nightly
2727
runs-on: linux.g5.12xlarge.nvidia.gpu
28-
torch-spec: 'torch==2.2.2 "numpy<2" '
28+
torch-spec: '--pre torch==2.6.0.dev20241101 --index-url https://download.pytorch.org/whl/nightly/cu121'
2929
gpu-arch-type: "cuda"
3030
gpu-arch-version: "12.1"
31+
- name: CPU Nightly
32+
runs-on: linux.4xlarge
33+
torch-spec: '--pre torch==2.6.0.dev20241101 --index-url https://download.pytorch.org/whl/nightly/cpu'
34+
gpu-arch-type: "cpu"
35+
gpu-arch-version: ""
36+
37+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
38+
with:
39+
timeout: 120
40+
runner: ${{ matrix.runs-on }}
41+
gpu-arch-type: ${{ matrix.gpu-arch-type }}
42+
gpu-arch-version: ${{ matrix.gpu-arch-version }}
43+
script: |
44+
conda create -n venv python=3.9 -y
45+
conda activate venv
46+
python -m pip install --upgrade pip
47+
pip install ${{ matrix.torch-spec }}
48+
pip install -r dev-requirements.txt
49+
pip install .
50+
export CONDA=$(dirname $(dirname $(which conda)))
51+
export LD_LIBRARY_PATH=$CONDA/lib/:$LD_LIBRARY_PATH
52+
pytest test --verbose -s
53+
test:
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
include:
3158
- name: CUDA 2.3
3259
runs-on: linux.g5.12xlarge.nvidia.gpu
3360
torch-spec: 'torch==2.3.0'
@@ -38,17 +65,11 @@ jobs:
3865
torch-spec: 'torch==2.4.0'
3966
gpu-arch-type: "cuda"
4067
gpu-arch-version: "12.1"
41-
- name: CUDA Nightly
68+
- name: CUDA 2.5.1
4269
runs-on: linux.g5.12xlarge.nvidia.gpu
43-
torch-spec: '--pre torch --index-url https://download.pytorch.org/whl/nightly/cu121'
70+
torch-spec: 'torch==2.5.1 --index-url https://download.pytorch.org/whl/cu121'
4471
gpu-arch-type: "cuda"
4572
gpu-arch-version: "12.1"
46-
47-
- name: CPU 2.2.2
48-
runs-on: linux.4xlarge
49-
torch-spec: 'torch==2.2.2 --index-url https://download.pytorch.org/whl/cpu "numpy<2" '
50-
gpu-arch-type: "cpu"
51-
gpu-arch-version: ""
5273
- name: CPU 2.3
5374
runs-on: linux.4xlarge
5475
torch-spec: 'torch==2.3.0 --index-url https://download.pytorch.org/whl/cpu'
@@ -59,9 +80,9 @@ jobs:
5980
torch-spec: 'torch==2.4.0 --index-url https://download.pytorch.org/whl/cpu'
6081
gpu-arch-type: "cpu"
6182
gpu-arch-version: ""
62-
- name: CPU Nightly
83+
- name: CPU 2.5.1
6384
runs-on: linux.4xlarge
64-
torch-spec: '--pre torch --index-url https://download.pytorch.org/whl/nightly/cpu'
85+
torch-spec: 'torch==2.5.1 --index-url https://download.pytorch.org/whl/cpu'
6586
gpu-arch-type: "cpu"
6687
gpu-arch-version: ""
6788

.github/workflows/ruff_linter.yml

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: Code Analysis with Ruff
22

33
on:
4+
workflow_dispatch:
5+
inputs:
6+
pr_url:
7+
description: 'URL of the PR to fix'
8+
required: true
9+
type: string
410
push:
511
branches:
612
- main
@@ -13,30 +19,74 @@ on:
1319
jobs:
1420
build:
1521
runs-on: ubuntu-latest
22+
permissions:
23+
contents: write
24+
pull-requests: write
25+
1626
strategy:
1727
matrix:
1828
python-version: ["3.9"]
1929
steps:
30+
- name: Extract PR info
31+
if: github.event_name == 'workflow_dispatch'
32+
run: |
33+
PR_URL=${{ github.event.inputs.pr_url }}
34+
PR_NUMBER=$(echo $PR_URL | grep -oE '[0-9]+$')
35+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
36+
2037
- uses: actions/checkout@v3
38+
if: github.event_name == 'workflow_dispatch'
39+
with:
40+
fetch-depth: 0
41+
token: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Checkout PR branch
44+
if: github.event_name == 'workflow_dispatch'
45+
run: |
46+
gh pr checkout ${{ env.PR_NUMBER }}
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- uses: actions/checkout@v3
51+
if: github.event_name != 'workflow_dispatch'
52+
with:
53+
fetch-depth: 0
54+
2155
- name: Set up Python ${{ matrix.python-version }}
2256
uses: actions/setup-python@v3
2357
with:
2458
python-version: ${{ matrix.python-version }}
59+
2560
- name: Install dependencies
2661
run: |
2762
python -m pip install --upgrade pip
2863
pip install ruff==0.6.8
29-
- name: Analyzing the code with ruff
64+
65+
- name: Regular lint check
66+
if: github.event_name != 'workflow_dispatch'
3067
run: |
3168
ruff check .
32-
- name: Check *all* Python files for F821, F823, and W191
33-
run: |
3469
# --isolated is used to skip the allowlist at all so this applies to all files
3570
# please be careful when using this large changes means everyone needs to rebase
3671
ruff check --isolated --select F821,F823,W191
37-
- name: Check the allow-listed files for F,I
38-
run: |
3972
ruff check --select F,I
40-
- name: Check the allow-listed files for well formatted code
41-
run: |
4273
ruff format --check
74+
75+
- name: Apply fixes to PR
76+
if: github.event_name == 'workflow_dispatch'
77+
run: |
78+
git config --global user.name 'github-actions[bot]'
79+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
80+
81+
# Apply fixes
82+
ruff check --select F,I --fix
83+
ruff format .
84+
85+
# Commit and push if there are changes
86+
if [[ -n "$(git status --porcelain)" ]]; then
87+
git add .
88+
git commit -m "Apply automatic Ruff fixes"
89+
git push
90+
else
91+
echo "No fixes needed!"
92+
fi

.pre-commit-config.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ repos:
1515
hooks:
1616
# Run the linter.
1717
- id: ruff
18-
args: [--fix]
18+
args:
19+
- --fix
20+
- --select
21+
- F,I
1922
# Run the formatter.
2023
- id: ruff-format

CITATION.cff

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cff-version: 1.2.0
2+
title: "torchao: PyTorch native quantization and sparsity for training and inference"
3+
message: "If you use this software, please cite it as below."
4+
type: software
5+
authors:
6+
- given-names: "torchao maintainers and contributors"
7+
url: "https//github.com/pytorch/torchao"
8+
license: "BSD-3-Clause"
9+
date-released: "2024-10-25"

0 commit comments

Comments
 (0)