From 53a1fb0ecbdd869516483288f8ff4fcb52a2f717 Mon Sep 17 00:00:00 2001 From: atalman Date: Thu, 16 Nov 2023 08:41:13 -0800 Subject: [PATCH 1/4] test --- .../validate-aarch64-linux-binaries.yml | 18 ++++++++-- .github/workflows/validate-binaries.yml | 11 +++++++ .github/workflows/validate-linux-binaries.yml | 15 +++++++-- .../validate-macos-arm64-binaries.yml | 18 +++++++++- .github/workflows/validate-macos-binaries.yml | 18 +++++++++- .../workflows/validate-windows-binaries.yml | 20 +++++++++-- test/smoke_test/smoke_test.py | 33 ++++++++----------- 7 files changed, 104 insertions(+), 29 deletions(-) diff --git a/.github/workflows/validate-aarch64-linux-binaries.yml b/.github/workflows/validate-aarch64-linux-binaries.yml index d3e57fd5c..3d07ef1d8 100644 --- a/.github/workflows/validate-aarch64-linux-binaries.yml +++ b/.github/workflows/validate-aarch64-linux-binaries.yml @@ -17,6 +17,11 @@ on: default: false required: false type: boolean + version: + description: 'Version to validate - optional' + default: "" + required: false + type: string workflow_dispatch: inputs: channel: @@ -38,6 +43,11 @@ on: default: false required: false type: boolean + version: + description: 'Version to validate - optional' + default: "" + required: false + type: string jobs: generate-aarch64-linux-matrix: @@ -46,8 +56,10 @@ jobs: package-type: wheel os: linux-aarch64 channel: ${{ inputs.channel }} - with-cuda: disable - + generate-release-matrix: + uses: pytorch/test-infra/.github/workflows/generate_release_matrix.yml@main + with: + version: ${{ inputs.version }} linux-aarch64: needs: generate-aarch64-linux-matrix strategy: @@ -72,6 +84,8 @@ jobs: export ENV_NAME="conda-env-${{ github.run_id }}" export TARGET_OS="linux-aarch64" export TORCH_ONLY=${{ inputs.torchonly }} + export RELEASE_VERSION=${{ inputs.version }} + printf '%s\n' ${{ toJson(needs.generate-release-matrix.outputs.matrix) }} > release_matrix.json eval "$(conda shell.bash hook)" # Standart case: Validate binaries diff --git a/.github/workflows/validate-binaries.yml b/.github/workflows/validate-binaries.yml index 9c877f4ed..e122f7e57 100644 --- a/.github/workflows/validate-binaries.yml +++ b/.github/workflows/validate-binaries.yml @@ -60,6 +60,12 @@ on: default: false required: false type: boolean + version: + description: 'Version to validate - optional' + default: "" + required: false + type: string + jobs: win: @@ -69,6 +75,7 @@ jobs: channel: ${{ inputs.channel }} ref: ${{ inputs.ref || github.ref }} torchonly: ${{ inputs.torchonly }} + version: ${{ inputs.version }} linux: if: inputs.os == 'linux' || inputs.os == 'all' @@ -77,6 +84,7 @@ jobs: channel: ${{ inputs.channel }} ref: ${{ inputs.ref || github.ref }} torchonly: ${{ inputs.torchonly }} + version: ${{ inputs.version }} linux-aarch64: if: inputs.os == 'linux-aarch64' @@ -85,6 +93,7 @@ jobs: channel: ${{ inputs.channel }} ref: ${{ inputs.ref || github.ref }} torchonly: ${{ inputs.torchonly }} + version: ${{ inputs.version }} mac: if: inputs.os == 'macos' || inputs.os == 'all' @@ -93,6 +102,7 @@ jobs: channel: ${{ inputs.channel }} ref: ${{ inputs.ref || github.ref }} torchonly: ${{ inputs.torchonly }} + version: ${{ inputs.version }} mac-arm64: if: inputs.os == 'macos' || inputs.os == 'all' @@ -101,3 +111,4 @@ jobs: channel: ${{ inputs.channel }} ref: ${{ inputs.ref || github.ref }} torchonly: ${{ inputs.torchonly }} + version: ${{ inputs.version }} diff --git a/.github/workflows/validate-linux-binaries.yml b/.github/workflows/validate-linux-binaries.yml index 5e1a00698..9078fbb26 100644 --- a/.github/workflows/validate-linux-binaries.yml +++ b/.github/workflows/validate-linux-binaries.yml @@ -17,6 +17,11 @@ on: default: false required: false type: boolean + version: + description: 'Version to validate - optional' + default: "" + required: false + type: string workflow_dispatch: inputs: channel: @@ -38,6 +43,12 @@ on: default: false required: false type: boolean + version: + description: 'Version to validate - optional' + default: "" + required: false + type: string + jobs: generate-linux-matrix: @@ -47,10 +58,9 @@ jobs: os: linux channel: ${{ inputs.channel }} generate-release-matrix: - needs: generate-linux-matrix uses: pytorch/test-infra/.github/workflows/generate_release_matrix.yml@main with: - version: "2.1.1" + version: ${{ inputs.version }} linux: needs: [generate-linux-matrix, generate-release-matrix] @@ -69,6 +79,7 @@ jobs: set -ex export ENV_NAME="conda-env-${{ github.run_id }}" export TORCH_ONLY=${{ inputs.torchonly }} + export RELEASE_VERSION=${{ inputs.version }} export TARGET_OS="linux" eval "$(conda shell.bash hook)" printf '%s\n' ${{ toJson(needs.generate-release-matrix.outputs.matrix) }} > release_matrix.json diff --git a/.github/workflows/validate-macos-arm64-binaries.yml b/.github/workflows/validate-macos-arm64-binaries.yml index f23dec3f6..ebe38e619 100644 --- a/.github/workflows/validate-macos-arm64-binaries.yml +++ b/.github/workflows/validate-macos-arm64-binaries.yml @@ -17,6 +17,11 @@ on: default: false required: false type: boolean + version: + description: 'Version to validate - optional' + default: "" + required: false + type: string workflow_dispatch: inputs: channel: @@ -38,6 +43,11 @@ on: default: false required: false type: boolean + version: + description: 'Version to validate - optional' + default: "" + required: false + type: string jobs: generate-macos-arm64-matrix: @@ -46,8 +56,12 @@ jobs: package-type: all os: macos-arm64 channel: ${{ inputs.channel }} + generate-release-matrix: + uses: pytorch/test-infra/.github/workflows/generate_release_matrix.yml@main + with: + version: ${{ inputs.version }} macos-arm64: - needs: generate-macos-arm64-matrix + needs: [generate-macos-arm64-matrix, generate-release-matrix] strategy: matrix: ${{ fromJson(needs.generate-macos-arm64-matrix.outputs.matrix) }} fail-fast: false @@ -64,4 +78,6 @@ jobs: export ENV_NAME="conda-env-${{ github.run_id }}" export TARGET_OS="macos-arm64" export TORCH_ONLY=${{ inputs.torchonly }} + export RELEASE_VERSION=${{ inputs.version }} + printf '%s\n' ${{ toJson(needs.generate-release-matrix.outputs.matrix) }} > release_matrix.json source ./.github/scripts/validate_binaries.sh diff --git a/.github/workflows/validate-macos-binaries.yml b/.github/workflows/validate-macos-binaries.yml index 0926dbe93..e1a4f5d45 100644 --- a/.github/workflows/validate-macos-binaries.yml +++ b/.github/workflows/validate-macos-binaries.yml @@ -17,6 +17,11 @@ on: default: false required: false type: boolean + version: + description: 'Version to validate - optional' + default: "" + required: false + type: string workflow_dispatch: inputs: channel: @@ -38,6 +43,11 @@ on: default: false required: false type: boolean + version: + description: 'Version to validate - optional' + default: "" + required: false + type: string jobs: generate-macos-matrix: @@ -46,8 +56,12 @@ jobs: package-type: all os: macos channel: ${{ inputs.channel }} + generate-release-matrix: + uses: pytorch/test-infra/.github/workflows/generate_release_matrix.yml@main + with: + version: ${{ inputs.version }} macos: - needs: generate-macos-matrix + needs: [generate-macos-matrix, generate-release-matrix] strategy: matrix: ${{ fromJson(needs.generate-macos-matrix.outputs.matrix) }} fail-fast: false @@ -64,4 +78,6 @@ jobs: export ENV_NAME="conda-env-${{ github.run_id }}" export TARGET_OS="macos" export TORCH_ONLY=${{ inputs.torchonly }} + export RELEASE_VERSION=${{ inputs.version }} + printf '%s\n' ${{ toJson(needs.generate-release-matrix.outputs.matrix) }} > release_matrix.json source ./.github/scripts/validate_binaries.sh diff --git a/.github/workflows/validate-windows-binaries.yml b/.github/workflows/validate-windows-binaries.yml index 96d2b281e..cd0ed1886 100644 --- a/.github/workflows/validate-windows-binaries.yml +++ b/.github/workflows/validate-windows-binaries.yml @@ -17,6 +17,11 @@ on: default: false required: false type: boolean + version: + description: 'Version to validate - optional' + default: "" + required: false + type: string workflow_dispatch: inputs: channel: @@ -38,6 +43,11 @@ on: default: false required: false type: boolean + version: + description: 'Version to validate - optional' + default: "" + required: false + type: string jobs: generate-windows-matrix: @@ -46,9 +56,12 @@ jobs: package-type: all os: windows channel: ${{ inputs.channel }} - + generate-release-matrix: + uses: pytorch/test-infra/.github/workflows/generate_release_matrix.yml@main + with: + version: ${{ inputs.version }} win: - needs: generate-windows-matrix + needs: [generate-windows-matrix, generate-release-matrix] strategy: matrix: ${{ fromJson(needs.generate-windows-matrix.outputs.matrix) }} fail-fast: false @@ -66,9 +79,10 @@ jobs: export ENV_NAME="conda-env-${{ github.run_id }}" export TARGET_OS="windows" export TORCH_ONLY=${{ inputs.torchonly }} + export RELEASE_VERSION=${{ inputs.version }} + printf '%s\n' ${{ toJson(needs.generate-release-matrix.outputs.matrix) }} > release_matrix.json source /c/Jenkins/Miniconda3/etc/profile.d/conda.sh if [[ ${MATRIX_GPU_ARCH_VERSION} == "12.1" ]]; then ./windows/internal/driver_update.bat fi - source ./.github/scripts/validate_binaries.sh diff --git a/test/smoke_test/smoke_test.py b/test/smoke_test/smoke_test.py index a14ad4316..e97ddc839 100644 --- a/test/smoke_test/smoke_test.py +++ b/test/smoke_test/smoke_test.py @@ -15,9 +15,11 @@ gpu_arch_type = os.getenv("MATRIX_GPU_ARCH_TYPE") channel = os.getenv("MATRIX_CHANNEL") stable_version = os.getenv("MATRIX_STABLE_VERSION") +release_version = os.getenv("RELEASE_VERSION") package_type = os.getenv("MATRIX_PACKAGE_TYPE") target_os = os.getenv("TARGET_OS") BASE_DIR = Path(__file__).parent.parent.parent +release_matrix = None is_cuda_system = gpu_arch_type == "cuda" NIGHTLY_ALLOWED_DELTA = 3 @@ -40,21 +42,6 @@ ] -class Net(nn.Module): - def __init__(self): - super().__init__() - self.conv1 = nn.Conv2d(1, 32, 3, 1) - self.conv2 = nn.Conv2d(32, 64, 3, 1) - self.fc1 = nn.Linear(9216, 1) - - def forward(self, x): - x = self.conv1(x) - x = self.conv2(x) - x = F.max_pool2d(x, 2) - x = torch.flatten(x, 1) - output = self.fc1(x) - return output - def load_json_from_basedir(filename: str): try: with open(BASE_DIR / filename) as fptr: @@ -76,17 +63,17 @@ def check_version(package: str) -> None: raise RuntimeError( f"Torch version mismatch, expected {stable_version} for channel {channel}. But its {torch.__version__}" ) - release_version = read_release_matrix() - if package == "all": + + if release_version and package == "all": for module in MODULES: imported_module = importlib.import_module(module["name"]) module_version = imported_module.__version__ - if not module_version.startswith(release_version[module["name"]]): + if not module_version.startswith(release_matrix[module["name"]]): raise RuntimeError( - f"{module['name']} version mismatch, expected {release_version[module['name']]} for channel {channel}. But its {module_version}" + f"{module['name']} version mismatch, expected {release_matrix[module['name']]} for channel {channel}. But its {module_version}" ) else: - print(f"{module['name']} version actual: {module_version} expected: {release_version[module['name']]} for channel {channel}.") + print(f"{module['name']} version actual: {module_version} expected: {release_matrix[module['name']]} for channel {channel}.") else: print(f"Skip version check for channel {channel} as stable version is None") @@ -281,6 +268,12 @@ def main() -> None: ) options = parser.parse_args() print(f"torch: {torch.__version__}") + + # if release_version is specified, override stable_version coming from the matrix file + if(release_version): + release_matrix = read_release_matrix() + stable_version = release_matrix["torch"] + check_version(options.package) smoke_test_conv2d() smoke_test_linalg() From a8b45fdba1e3d257076493d95c3b9c9601c99dcc Mon Sep 17 00:00:00 2001 From: atalman Date: Thu, 16 Nov 2023 08:50:10 -0800 Subject: [PATCH 2/4] test --- .../validate-aarch64-linux-binaries.yml | 4 ++-- .../workflows/validate-macos-arm64-binaries.yml | 4 ++-- .github/workflows/validate-macos-binaries.yml | 4 ++-- .github/workflows/validate-windows-binaries.yml | 4 ++-- test/smoke_test/smoke_test.py | 16 +++++++++++++++- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.github/workflows/validate-aarch64-linux-binaries.yml b/.github/workflows/validate-aarch64-linux-binaries.yml index 3d07ef1d8..8abf865f5 100644 --- a/.github/workflows/validate-aarch64-linux-binaries.yml +++ b/.github/workflows/validate-aarch64-linux-binaries.yml @@ -84,8 +84,8 @@ jobs: export ENV_NAME="conda-env-${{ github.run_id }}" export TARGET_OS="linux-aarch64" export TORCH_ONLY=${{ inputs.torchonly }} - export RELEASE_VERSION=${{ inputs.version }} - printf '%s\n' ${{ toJson(needs.generate-release-matrix.outputs.matrix) }} > release_matrix.json + export RELEASE_VERSION=${{ inputs.version }} + printf '%s\n' ${{ toJson(needs.generate-release-matrix.outputs.matrix) }} > release_matrix.json eval "$(conda shell.bash hook)" # Standart case: Validate binaries diff --git a/.github/workflows/validate-macos-arm64-binaries.yml b/.github/workflows/validate-macos-arm64-binaries.yml index ebe38e619..59d9393d0 100644 --- a/.github/workflows/validate-macos-arm64-binaries.yml +++ b/.github/workflows/validate-macos-arm64-binaries.yml @@ -78,6 +78,6 @@ jobs: export ENV_NAME="conda-env-${{ github.run_id }}" export TARGET_OS="macos-arm64" export TORCH_ONLY=${{ inputs.torchonly }} - export RELEASE_VERSION=${{ inputs.version }} - printf '%s\n' ${{ toJson(needs.generate-release-matrix.outputs.matrix) }} > release_matrix.json + export RELEASE_VERSION=${{ inputs.version }} + printf '%s\n' ${{ toJson(needs.generate-release-matrix.outputs.matrix) }} > release_matrix.json source ./.github/scripts/validate_binaries.sh diff --git a/.github/workflows/validate-macos-binaries.yml b/.github/workflows/validate-macos-binaries.yml index e1a4f5d45..325fcf8a6 100644 --- a/.github/workflows/validate-macos-binaries.yml +++ b/.github/workflows/validate-macos-binaries.yml @@ -78,6 +78,6 @@ jobs: export ENV_NAME="conda-env-${{ github.run_id }}" export TARGET_OS="macos" export TORCH_ONLY=${{ inputs.torchonly }} - export RELEASE_VERSION=${{ inputs.version }} - printf '%s\n' ${{ toJson(needs.generate-release-matrix.outputs.matrix) }} > release_matrix.json + export RELEASE_VERSION=${{ inputs.version }} + printf '%s\n' ${{ toJson(needs.generate-release-matrix.outputs.matrix) }} > release_matrix.json source ./.github/scripts/validate_binaries.sh diff --git a/.github/workflows/validate-windows-binaries.yml b/.github/workflows/validate-windows-binaries.yml index cd0ed1886..4a7891c20 100644 --- a/.github/workflows/validate-windows-binaries.yml +++ b/.github/workflows/validate-windows-binaries.yml @@ -79,8 +79,8 @@ jobs: export ENV_NAME="conda-env-${{ github.run_id }}" export TARGET_OS="windows" export TORCH_ONLY=${{ inputs.torchonly }} - export RELEASE_VERSION=${{ inputs.version }} - printf '%s\n' ${{ toJson(needs.generate-release-matrix.outputs.matrix) }} > release_matrix.json + export RELEASE_VERSION=${{ inputs.version }} + printf '%s\n' ${{ toJson(needs.generate-release-matrix.outputs.matrix) }} > release_matrix.json source /c/Jenkins/Miniconda3/etc/profile.d/conda.sh if [[ ${MATRIX_GPU_ARCH_VERSION} == "12.1" ]]; then ./windows/internal/driver_update.bat diff --git a/test/smoke_test/smoke_test.py b/test/smoke_test/smoke_test.py index e97ddc839..c34208771 100644 --- a/test/smoke_test/smoke_test.py +++ b/test/smoke_test/smoke_test.py @@ -41,6 +41,20 @@ }, ] +class Net(nn.Module): + def __init__(self): + super().__init__() + self.conv1 = nn.Conv2d(1, 32, 3, 1) + self.conv2 = nn.Conv2d(32, 64, 3, 1) + self.fc1 = nn.Linear(9216, 1) + + def forward(self, x): + x = self.conv1(x) + x = self.conv2(x) + x = F.max_pool2d(x, 2) + x = torch.flatten(x, 1) + output = self.fc1(x) + return output def load_json_from_basedir(filename: str): try: @@ -269,7 +283,7 @@ def main() -> None: options = parser.parse_args() print(f"torch: {torch.__version__}") - # if release_version is specified, override stable_version coming from the matrix file + # if release_version is specified, override stable_version coming binary matrix if(release_version): release_matrix = read_release_matrix() stable_version = release_matrix["torch"] From 9703050424a90160c3eaa55c0119d4a3103487cc Mon Sep 17 00:00:00 2001 From: atalman Date: Thu, 16 Nov 2023 09:00:58 -0800 Subject: [PATCH 3/4] test --- .github/workflows/validate-aarch64-linux-binaries.yml | 3 ++- .github/workflows/validate-linux-binaries.yml | 1 + .github/workflows/validate-macos-arm64-binaries.yml | 1 + .github/workflows/validate-macos-binaries.yml | 1 + .github/workflows/validate-windows-binaries.yml | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validate-aarch64-linux-binaries.yml b/.github/workflows/validate-aarch64-linux-binaries.yml index 8abf865f5..de741247d 100644 --- a/.github/workflows/validate-aarch64-linux-binaries.yml +++ b/.github/workflows/validate-aarch64-linux-binaries.yml @@ -57,11 +57,12 @@ jobs: os: linux-aarch64 channel: ${{ inputs.channel }} generate-release-matrix: + needs: generate-aarch64-linux-matrix uses: pytorch/test-infra/.github/workflows/generate_release_matrix.yml@main with: version: ${{ inputs.version }} linux-aarch64: - needs: generate-aarch64-linux-matrix + needs: [generate-aarch64-linux-matrix, generate-release-matrix] strategy: matrix: ${{ fromJson(needs.generate-aarch64-linux-matrix.outputs.matrix) }} fail-fast: false diff --git a/.github/workflows/validate-linux-binaries.yml b/.github/workflows/validate-linux-binaries.yml index 9078fbb26..e19d7d63a 100644 --- a/.github/workflows/validate-linux-binaries.yml +++ b/.github/workflows/validate-linux-binaries.yml @@ -58,6 +58,7 @@ jobs: os: linux channel: ${{ inputs.channel }} generate-release-matrix: + needs: generate-linux-matrix uses: pytorch/test-infra/.github/workflows/generate_release_matrix.yml@main with: version: ${{ inputs.version }} diff --git a/.github/workflows/validate-macos-arm64-binaries.yml b/.github/workflows/validate-macos-arm64-binaries.yml index 59d9393d0..4d6f7b12f 100644 --- a/.github/workflows/validate-macos-arm64-binaries.yml +++ b/.github/workflows/validate-macos-arm64-binaries.yml @@ -57,6 +57,7 @@ jobs: os: macos-arm64 channel: ${{ inputs.channel }} generate-release-matrix: + needs: generate-macos-arm64-matrix uses: pytorch/test-infra/.github/workflows/generate_release_matrix.yml@main with: version: ${{ inputs.version }} diff --git a/.github/workflows/validate-macos-binaries.yml b/.github/workflows/validate-macos-binaries.yml index 325fcf8a6..2b388dde0 100644 --- a/.github/workflows/validate-macos-binaries.yml +++ b/.github/workflows/validate-macos-binaries.yml @@ -57,6 +57,7 @@ jobs: os: macos channel: ${{ inputs.channel }} generate-release-matrix: + needs: generate-macos-matrix uses: pytorch/test-infra/.github/workflows/generate_release_matrix.yml@main with: version: ${{ inputs.version }} diff --git a/.github/workflows/validate-windows-binaries.yml b/.github/workflows/validate-windows-binaries.yml index 4a7891c20..97a199eb8 100644 --- a/.github/workflows/validate-windows-binaries.yml +++ b/.github/workflows/validate-windows-binaries.yml @@ -57,6 +57,7 @@ jobs: os: windows channel: ${{ inputs.channel }} generate-release-matrix: + needs: generate-windows-matrix uses: pytorch/test-infra/.github/workflows/generate_release_matrix.yml@main with: version: ${{ inputs.version }} From 8d1435c0a18abf97783de29c4923ba05aa0eac94 Mon Sep 17 00:00:00 2001 From: atalman Date: Thu, 16 Nov 2023 09:10:31 -0800 Subject: [PATCH 4/4] test --- .github/workflows/validate-aarch64-linux-binaries.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/validate-aarch64-linux-binaries.yml b/.github/workflows/validate-aarch64-linux-binaries.yml index de741247d..37d3a129b 100644 --- a/.github/workflows/validate-aarch64-linux-binaries.yml +++ b/.github/workflows/validate-aarch64-linux-binaries.yml @@ -56,6 +56,7 @@ jobs: package-type: wheel os: linux-aarch64 channel: ${{ inputs.channel }} + with-cuda: disable generate-release-matrix: needs: generate-aarch64-linux-matrix uses: pytorch/test-infra/.github/workflows/generate_release_matrix.yml@main