Skip to content

Commit 8440ea7

Browse files
committed
Update on "[Quant][core][improvements] Combined dispatch registration for max_pool2d & quantized_max_pool2d and implemented max_pool2d_with_indices_out_quantized_cpu"
Summary: This PR is part of a series of PRs addressing #54150, related to using dispatcher for calls to quantized backends as opposed to if/else conditionals. This particular PR removes the is_quantized check from max_pool2d, and implements a quantized kernel for max_pool2d_with_indices. This PR also introduces isnan() support for vectorized int tensors. This PR relies on #74560, which introduces structured kernel support for quantized tensors. Test plan: ``` python test/test_quantization.py -k test_max_pool2d ``` Differential Revision: [D35420901](https://our.internmc.facebook.com/intern/diff/D35420901) [ghstack-poisoned]
2 parents 93424fb + 24ea82a commit 8440ea7

File tree

149 files changed

+6429
-16254
lines changed

Some content is hidden

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

149 files changed

+6429
-16254
lines changed

.github/actions/checkout-pytorch/action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ inputs:
66
no-sudo:
77
description: If set to any value, don't use sudo to clean the workspace
88
required: false
9+
submodules:
10+
description: Works as stated in actions/checkout, but the default value is recursive
11+
required: false
12+
default: recursive
913

1014
runs:
1115
using: composite
@@ -29,4 +33,4 @@ runs:
2933
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
3034
# deep clone, to allow use of git merge-base
3135
fetch-depth: 0
32-
submodules: recursive
36+
submodules: ${{ inputs.submodules }}

.github/scripts/generate_binary_build_matrix.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from typing import Dict, List, Tuple, Optional
1414

1515

16-
CUDA_ARCHES = ["10.2", "11.3", "11.5", "11.6"]
16+
CUDA_ARCHES = ["10.2", "11.3", "11.6"]
1717

1818

1919
ROCM_ARCHES = ["4.5.2", "5.0"]
@@ -148,6 +148,9 @@ def generate_libtorch_matrix(os: str, abi_version: str,
148148
# matter
149149
gpu_arch_type = arch_type(arch_version)
150150
gpu_arch_version = "" if arch_version == "cpu" else arch_version
151+
# ROCm builds without-deps failed even in ROCm runners; skip for now
152+
if gpu_arch_type == "rocm" and "without-deps" in libtorch_variant:
153+
continue
151154
ret.append(
152155
{
153156
"gpu_arch_type": gpu_arch_type,

.github/scripts/trymerge.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python3
22

3+
import base64
34
import json
45
import os
56
import re
@@ -603,22 +604,33 @@ class MergeRule:
603604
mandatory_checks_name: Optional[List[str]]
604605

605606

606-
def read_merge_rules(repo: GitRepo) -> List[MergeRule]:
607+
def read_merge_rules(repo: Optional[GitRepo], org: str, project: str) -> List[MergeRule]:
607608
from pathlib import Path
608-
rules_path = Path(repo.repo_dir) / ".github" / "merge_rules.json"
609-
if not rules_path.exists():
610-
print(f"{rules_path} does not exist, returning empty rules")
611-
return []
612-
with open(rules_path) as fp:
613-
rc = json.load(fp, object_hook=lambda x: MergeRule(**x))
614-
return cast(List[MergeRule], rc)
609+
610+
repo_relative_rules_path = Path(".github") / "merge_rules.json"
611+
if repo is None:
612+
json_data = _fetch_url(
613+
f"https://api.github.com/repos/{org}/{project}/contents/{repo_relative_rules_path}",
614+
headers={'Accept': 'application/vnd.github.v3+json'},
615+
reader=json.load,
616+
)
617+
content = base64.b64decode(json_data["content"])
618+
return cast(List[MergeRule], json.loads(content, object_hook=lambda x: MergeRule(**x)))
619+
else:
620+
rules_path = Path(repo.repo_dir) / repo_relative_rules_path
621+
if not rules_path.exists():
622+
print(f"{rules_path} does not exist, returning empty rules")
623+
return []
624+
with open(rules_path) as fp:
625+
rc = json.load(fp, object_hook=lambda x: MergeRule(**x))
626+
return cast(List[MergeRule], rc)
615627

616628

617-
def find_matching_merge_rule(pr: GitHubPR, repo: GitRepo, force: bool = False) -> MergeRule:
629+
def find_matching_merge_rule(pr: GitHubPR, repo: Optional[GitRepo] = None, force: bool = False) -> MergeRule:
618630
"""Returns merge rule matching to this pr or raises an exception"""
619631
changed_files = pr.get_changed_files()
620632
approved_by = set(pr.get_approved_by())
621-
rules = read_merge_rules(repo)
633+
rules = read_merge_rules(repo, pr.org, pr.project)
622634
reject_reason = f"PR {pr.pr_num} does not match merge rules"
623635
# Used to determine best rejection reason
624636
# Score 0 to 10K - how many files rule matched

.github/templates/linux_binary_build_workflow.yml.j2

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,33 @@ jobs:
110110
!{{ config["build_name"] }}-test: # Testing
111111
if: ${{ github.repository_owner == 'pytorch' }}
112112
needs: !{{ config["build_name"] }}-build
113-
{%- if config["gpu_arch_type"] == "cuda" %}
113+
{%- if config["gpu_arch_type"] == "rocm" %}
114+
runs-on: linux.rocm.gpu
115+
{%- elif config["gpu_arch_type"] == "cuda" %}
114116
runs-on: linux.4xlarge.nvidia.gpu
115117
{%- else %}
116118
runs-on: linux.4xlarge
117119
{%- endif %}
118120
timeout-minutes: !{{ common.timeout_minutes }}
119121
!{{ upload.binary_env(config) }}
120122
steps:
123+
{%- if config["gpu_arch_type"] == "rocm" %}
124+
!{{ common.setup_rocm_linux() }}
125+
{%- else %}
121126
!{{ common.setup_ec2_linux() }}
127+
{%- endif %}
122128
- uses: seemethere/download-artifact-s3@v3
123129
name: Download Build Artifacts
124130
with:
125131
name: !{{ config["build_name"] }}
126132
path: "${{ runner.temp }}/artifacts/"
127133
!{{ common.checkout(deep_clone=False, directory="pytorch") }}
128134
!{{ common.checkout(deep_clone=False, directory="builder", repository="pytorch/builder", branch=common.builder_branch) }}
129-
{%- if config["gpu_arch_type"] == "cuda" %}
135+
{%- if config["gpu_arch_type"] == "rocm" %}
136+
- name: ROCm set GPU_FLAG
137+
run: |
138+
echo "GPU_FLAG=--device=/dev/mem --device=/dev/kfd --device=/dev/dri --group-add video --group-add daemon" >> "${GITHUB_ENV}"
139+
{%- elif config["gpu_arch_type"] == "cuda" %}
130140
- uses: nick-fields/retry@71062288b76e2b6214ebde0e673ce0de1755740a
131141
name: Install nvidia driver, nvidia-docker runtime, set GPU_FLAG
132142
with:
@@ -176,7 +186,11 @@ jobs:
176186
# Generate test script
177187
docker exec -t -w "${PYTORCH_ROOT}" -e OUTPUT_SCRIPT="/run.sh" "${container_name}" bash -c "bash .circleci/scripts/binary_linux_test.sh"
178188
docker exec -t "${container_name}" bash -c "source ${BINARY_ENV_FILE} && bash -x /run.sh"
189+
{%- if config["gpu_arch_type"] == "rocm" %}
190+
!{{ common.teardown_rocm_linux() }}
191+
{%- else %}
179192
!{{ common.teardown_ec2_linux("pytorch/") }}
193+
{%- endif %}
180194
{%- if branches == "nightly" %}
181195
!{{ upload.upload_binaries(config) }}
182196
{%- endif %}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: buck
2+
3+
on:
4+
push:
5+
tags:
6+
# Trigger on release candidate builds
7+
# Release candidate tags look like: v1.11.0-rc1
8+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
9+
- 'ciflow/trunk/*'
10+
branches:
11+
- master
12+
- main
13+
- release/*
14+
workflow_dispatch:
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
18+
cancel-in-progress: true
19+
20+
defaults:
21+
run:
22+
shell: bash -e -l {0}
23+
24+
jobs:
25+
26+
buck-build-test:
27+
runs-on: ubuntu-latest
28+
env:
29+
JOB_BASE_NAME: ubuntu-latest-buck
30+
steps:
31+
- name: Checkout PyTorch
32+
uses: pytorch/pytorch/.github/actions/checkout-pytorch@master
33+
34+
- name: Set up JDK 8
35+
uses: actions/setup-java@v3
36+
with:
37+
java-version: '8'
38+
distribution: 'temurin'
39+
40+
- name: Setup miniconda
41+
uses: conda-incubator/setup-miniconda@v2
42+
with:
43+
auto-update-conda: true
44+
python-version: 3.8
45+
activate-environment: build
46+
47+
- name: Install dependencies
48+
run: |
49+
conda install -y \
50+
cffi \
51+
cmake \
52+
mkl \
53+
mkl-include \
54+
ninja \
55+
numpy \
56+
pyyaml \
57+
requests \
58+
setuptools \
59+
typing_extensions
60+
61+
- name: Install Buck
62+
run: |
63+
wget https://github.com/facebook/buck/releases/download/v2021.01.12.01/buck.2021.01.12.01_all.deb
64+
sudo apt install ./buck.2021.01.12.01_all.deb
65+
66+
- name: Build Buck target
67+
run: |
68+
touch .buckconfig
69+
buck build --keep-going //third_party:

.github/workflows/docker-builds.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jobs:
2626
include:
2727
- docker-image-name: pytorch-linux-bionic-cuda10.2-cudnn7-py3.9-gcc7
2828
- docker-image-name: pytorch-linux-bionic-cuda11.3-cudnn8-py3-clang9
29-
- docker-image-name: pytorch-linux-bionic-cuda11.5-cudnn8-py3-gcc7
3029
- docker-image-name: pytorch-linux-bionic-cuda11.6-cudnn8-py3-gcc7
3130
- docker-image-name: pytorch-linux-bionic-py3.7-clang9
3231
- docker-image-name: pytorch-linux-bionic-rocm4.5-py3.7

0 commit comments

Comments
 (0)