From 51946b0f0144c7365d6859af40d650f3b86d8c88 Mon Sep 17 00:00:00 2001 From: Andrey Talman Date: Thu, 27 Jun 2024 11:28:04 -0400 Subject: [PATCH 1/8] Add validations to torchao (#453) --- .github/scripts/validate_binaries.sh | 2 ++ .github/workflows/validate-binaries.yml | 47 +++++++++++++++++++++++++ test/smoke_tests/smoke_tests.py | 6 ++++ 3 files changed, 55 insertions(+) create mode 100644 .github/scripts/validate_binaries.sh create mode 100644 .github/workflows/validate-binaries.yml create mode 100644 test/smoke_tests/smoke_tests.py diff --git a/.github/scripts/validate_binaries.sh b/.github/scripts/validate_binaries.sh new file mode 100644 index 0000000000..8984a6b599 --- /dev/null +++ b/.github/scripts/validate_binaries.sh @@ -0,0 +1,2 @@ +pip install ${PYTORCH_PIP_PREFIX} torchao --index-url ${PYTORCH_PIP_DOWNLOAD_URL} +python ./test/smoke_tests/smoke_tests.py diff --git a/.github/workflows/validate-binaries.yml b/.github/workflows/validate-binaries.yml new file mode 100644 index 0000000000..087f3130f4 --- /dev/null +++ b/.github/workflows/validate-binaries.yml @@ -0,0 +1,47 @@ +name: Validate binaries + +on: + workflow_call: + inputs: + channel: + description: "Channel to use (nightly, test, release, all)" + required: false + type: string + default: release + ref: + description: "Reference to checkout, defaults to empty" + default: "" + required: false + type: string + workflow_dispatch: + inputs: + channel: + description: "Channel to use (nightly, test, release, all)" + required: true + type: choice + options: + - release + - nightly + - test + - all + ref: + description: "Reference to checkout, defaults to empty" + default: "" + required: false + type: string + pytorch_version: + description: "PyTorch version to validate (ie. 2.0, 2.2.2, etc.) - optional" + default: "" + required: false + type: string +jobs: + validate-binaries: + uses: pytorch/test-infra/.github/workflows/validate-domain-library.yml@main + with: + package_type: "wheel" + version: ${{ inputs.version }} + os: "linux" + channel: ${{ inputs.channel }} + repository: "pytorch/ao" + smoke_test: "source ./.github/scripts/validate_binaries.sh" + install_torch: true diff --git a/test/smoke_tests/smoke_tests.py b/test/smoke_tests/smoke_tests.py new file mode 100644 index 0000000000..21537359f7 --- /dev/null +++ b/test/smoke_tests/smoke_tests.py @@ -0,0 +1,6 @@ +"""Run smoke tests""" + +import torchao + + +print("torchao version is ", torchao.__version__) From 642e65557ed47d977319e95740273ddf24a4066d Mon Sep 17 00:00:00 2001 From: Andrey Talman Date: Thu, 27 Jun 2024 11:50:15 -0400 Subject: [PATCH 2/8] Validations followup, enable cuda and disable rocm (#454) --- .github/workflows/validate-binaries.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/validate-binaries.yml b/.github/workflows/validate-binaries.yml index 087f3130f4..c08e673064 100644 --- a/.github/workflows/validate-binaries.yml +++ b/.github/workflows/validate-binaries.yml @@ -43,5 +43,7 @@ jobs: os: "linux" channel: ${{ inputs.channel }} repository: "pytorch/ao" + with_cuda: "enable" + with-rocm: "disable" smoke_test: "source ./.github/scripts/validate_binaries.sh" install_torch: true From 60ea23ebd54f9e9786c5b394422a7d3c72ec57d7 Mon Sep 17 00:00:00 2001 From: Andrey Talman Date: Thu, 27 Jun 2024 11:57:42 -0400 Subject: [PATCH 3/8] Validations followup, enable cuda and disable rocm --- .github/workflows/validate-binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-binaries.yml b/.github/workflows/validate-binaries.yml index c08e673064..838ae2078a 100644 --- a/.github/workflows/validate-binaries.yml +++ b/.github/workflows/validate-binaries.yml @@ -44,6 +44,6 @@ jobs: channel: ${{ inputs.channel }} repository: "pytorch/ao" with_cuda: "enable" - with-rocm: "disable" + with_rocm: "disable" smoke_test: "source ./.github/scripts/validate_binaries.sh" install_torch: true From 6cab4c8748a0d7f53ea541eadb308757f4c91d63 Mon Sep 17 00:00:00 2001 From: Mark Saroufim Date: Thu, 27 Jun 2024 09:43:59 -0700 Subject: [PATCH 4/8] remove torch dependency (#449) * remove torch dependency * push * push * push * push * push * push * Update pre_build_script.sh * Update version.txt * push --- packaging/pre_build_script.sh | 8 ++++++++ setup.py | 10 ---------- torchao/prototype/mx_formats/custom_cast.py | 2 +- version.txt | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/packaging/pre_build_script.sh b/packaging/pre_build_script.sh index 4bbd09694a..1690c62750 100644 --- a/packaging/pre_build_script.sh +++ b/packaging/pre_build_script.sh @@ -9,4 +9,12 @@ set -eux echo "This script is run before building torchao binaries" +python -m pip install --upgrade pip +if [ -z "$PYTORCH_VERSION" ]; then + PYTORCH_DEP="torch" +else + PYTORCH_DEP="torch==$PYTORCH_VERSION" +fi +pip install $PYTORCH_DEP + pip install setuptools wheel twine auditwheel diff --git a/setup.py b/setup.py index a6a2da8a75..fc85dcea9c 100644 --- a/setup.py +++ b/setup.py @@ -110,15 +110,6 @@ def get_extensions(): return ext_modules -# Mimic code from torchvision https://github.com/pytorch/vision/blob/143d078b28f00471156a4e562dd3836370acc9ee/setup.py#L58 -pytorch_dep = "torch" -if os.getenv("PYTORCH_VERSION"): - pytorch_dep += "==" + os.getenv("PYTORCH_VERSION") - -requirements = [ - pytorch_dep, -] - setup( name=package_name, version=version+version_suffix, @@ -128,7 +119,6 @@ def get_extensions(): "torchao.kernel.configs": ["*.pkl"], }, ext_modules=get_extensions() if use_cpp != "0" else None, - install_requires=requirements, extras_require={"dev": read_requirements("dev-requirements.txt")}, description="Package for applying ao techniques to GPU models", long_description=open("README.md").read(), diff --git a/torchao/prototype/mx_formats/custom_cast.py b/torchao/prototype/mx_formats/custom_cast.py index 00082acad9..381f91c4a6 100644 --- a/torchao/prototype/mx_formats/custom_cast.py +++ b/torchao/prototype/mx_formats/custom_cast.py @@ -15,7 +15,7 @@ # TODO(future): if needed, make the below work on previous PyTorch versions, # just need to hunt down the previous location of `libdevice`. An assert # at the callsite prevents usage of this on unsupported versions. -if TORCH_VERSION_AFTER_2_4: +if TORCH_VERSION_AFTER_2_4 and has_triton(): from torch._inductor.runtime.triton_helpers import libdevice from torchao.prototype.mx_formats.constants import ( diff --git a/version.txt b/version.txt index 0d91a54c7d..9e11b32fca 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.3.0 +0.3.1 From 1c7c3908dae71717e2a4c8127c67dcbfb2c327c6 Mon Sep 17 00:00:00 2001 From: Andrey Talman Date: Thu, 27 Jun 2024 13:14:35 -0400 Subject: [PATCH 5/8] Fix crash when PYTORCH_VERSION is not defined (#455) --- packaging/pre_build_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/pre_build_script.sh b/packaging/pre_build_script.sh index 1690c62750..cbc065bf11 100644 --- a/packaging/pre_build_script.sh +++ b/packaging/pre_build_script.sh @@ -10,7 +10,7 @@ set -eux echo "This script is run before building torchao binaries" python -m pip install --upgrade pip -if [ -z "$PYTORCH_VERSION" ]; then +if [ -z ${PYTORCH_VERSION:-} ]; then PYTORCH_DEP="torch" else PYTORCH_DEP="torch==$PYTORCH_VERSION" From c2f9b84604536a72804787001c1b63daae792ee9 Mon Sep 17 00:00:00 2001 From: Jerry Zhang Date: Wed, 26 Jun 2024 10:56:21 -0700 Subject: [PATCH 6/8] ghstack flow test - 3 (#443) Summary: att Test Plan: testing flow Reviewers: Subscribers: Tasks: Tags: Pull Request resolved: https://github.com/pytorch/ao/pull/443 Approved by: https://github.com/clee2000, https://github.com/huydhn --- torchao/__init__.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/torchao/__init__.py b/torchao/__init__.py index 895b30b9ad..0d252f5668 100644 --- a/torchao/__init__.py +++ b/torchao/__init__.py @@ -39,6 +39,3 @@ "autoquant", "quantize", ] - -# test ghstack flow -# test ghtstack flow 2 From e2263ffebfa52858341ce10177179134ff7fef29 Mon Sep 17 00:00:00 2001 From: Mark Saroufim Date: Fri, 28 Jun 2024 11:58:02 -0700 Subject: [PATCH 7/8] Update installation Docs (#459) * Update installation * Update README.md * Update README.md * Update README.md --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7b03d402ed..d4b4ca3bbc 100644 --- a/README.md +++ b/README.md @@ -81,9 +81,26 @@ A key design principle for us is composability as in any new dtype or layout we ### Installation + `torchao` makes liberal use of several new features in Pytorch, it's recommended to use it with the current nightly or latest stable version of PyTorch. -Stable release from Pypi which will default to PyTorch 2.3.1 and CUDA 12.1 +#### Install torch + +Install torch stable + +``` +pip install torch +``` + +Or torch nightlies + +``` +pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu121 +``` + +#### Install torchao + +Stable release from Pypi which will default to CUDA 12.1 ```Shell pip install torchao @@ -91,7 +108,7 @@ pip install torchao Stable Release from the PyTorch index ```Shell -pip install torchao --extra-index-url https://download.pytorch.org/whl/test/cu121 # full options are cpu/cu118/cu121/cu124 +pip install torchao --extra-index-url https://download.pytorch.org/whl/cu121 # full options are cpu/cu118/cu121/cu124 ``` Nightly Release From dee13e1336cff4f7a5d1fd1db8d629aca8b75e9b Mon Sep 17 00:00:00 2001 From: Mark Saroufim Date: Fri, 28 Jun 2024 12:15:20 -0700 Subject: [PATCH 8/8] Add Blogs and Videos section (#460) * Add Blogs and Videos section Good way for us to flex more * Update README.md * Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index d4b4ca3bbc..e99f565900 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,13 @@ python setup.py install * [vayuda](https://github.com/vayuda) with generic bitpacking kernels that were code generated using pure PyTorch [prototype/common](torchao/prototype/common) * [andreaskopf](https://github.com/andreaskoepf) and [melvinebenezer](https://github.com/melvinebenezer) with [1 bit LLMs](torchao/prototype/dtypes) Bitnet 1.58 bitpacked into uint2 and fully code-generated with torch.compile +## Blogs and Videos +* [Accelerating Neural Network Training with Semi-Structured (2:4) Sparsity](https://pytorch.org/blog/accelerating-neural-network-training/) +* [https://mobiusml.github.io/whisper-static-cache-blog/](https://mobiusml.github.io/whisper-static-cache-blog/) +* [Slaying OOMs at the Mastering LLM's course](https://x.com/HamelHusain/status/1800315287574847701) +* [Advanced Quantization at CUDA MODE](https://youtu.be/1u9xUK3G4VM?si=4JcPlw2w8chPXW8J) +* [Chip Huyen's GPU Optimization Workshop](https://www.youtube.com/live/v_q2JTIqE20?si=mf7HeZ63rS-uYpS6) + ## How to contribute This repository is currently under heavy development