Skip to content

Commit 252463f

Browse files
authored
Release validations using release version matrix (#1611)
* Release pypi prep change (#1587) * [aarch64] Release pypi prep script change for aarch64 builds * Release versions for testing Testing calling version (#1588) Upstream/release validations (#1589) * Testing calling version * add release matrix Upstream/release validations (#1590) * Testing calling version * add release matrix * test test (#1591) test (#1592) Release v1 (#1595) * test * test Release v1 (#1596) * test * test * test test (#1597) Test versions validations (#1598) * test * basedir Test versions validations (#1599) * test * basedir * test test (#1600) * test * test Add release versions everywhere (#1601) * test * test * test * test test (#1602) Test version validations (#1603) * test * test Test version validations (#1604) * test * test * test tests (#1605) More tests nov16 (#1606) * tests * test More tests nov16 (#1607) * tests * test * test More tests nov16 (#1608) * tests * test * test * test More tests nov16 (#1609) * tests * test * test * test * test * fix_lint
1 parent b321562 commit 252463f

7 files changed

+174
-5
lines changed

.github/workflows/validate-aarch64-linux-binaries.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ on:
1717
default: false
1818
required: false
1919
type: boolean
20+
version:
21+
description: 'Version to validate - optional'
22+
default: ""
23+
required: false
24+
type: string
25+
release-matrix:
26+
description: 'Release matrix - optional'
27+
default: ""
28+
required: false
29+
type: string
2030
workflow_dispatch:
2131
inputs:
2232
channel:
@@ -38,6 +48,16 @@ on:
3848
default: false
3949
required: false
4050
type: boolean
51+
version:
52+
description: 'Version to validate - optional'
53+
default: ""
54+
required: false
55+
type: string
56+
release-matrix:
57+
description: 'Release matrix - optional'
58+
default: ""
59+
required: false
60+
type: string
4161

4262
jobs:
4363
generate-aarch64-linux-matrix:
@@ -47,7 +67,6 @@ jobs:
4767
os: linux-aarch64
4868
channel: ${{ inputs.channel }}
4969
with-cuda: disable
50-
5170
linux-aarch64:
5271
needs: generate-aarch64-linux-matrix
5372
strategy:
@@ -72,6 +91,8 @@ jobs:
7291
export ENV_NAME="conda-env-${{ github.run_id }}"
7392
export TARGET_OS="linux-aarch64"
7493
export TORCH_ONLY=${{ inputs.torchonly }}
94+
export RELEASE_VERSION=${{ inputs.version }}
95+
printf '%s\n' ${{ toJson(inputs.release-matrix) }} > release_matrix.json
7596
eval "$(conda shell.bash hook)"
7697
7798
# Standart case: Validate binaries

.github/workflows/validate-binaries.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,44 +60,69 @@ on:
6060
default: false
6161
required: false
6262
type: boolean
63+
version:
64+
description: 'Version to validate'
65+
default: ""
66+
required: false
67+
type: string
68+
6369

6470
jobs:
71+
generate-release-matrix:
72+
uses: pytorch/test-infra/.github/workflows/generate_release_matrix.yml@main
73+
with:
74+
version: ${{ inputs.version }}
75+
6576
win:
6677
if: inputs.os == 'windows' || inputs.os == 'all'
78+
needs: generate-release-matrix
6779
uses: ./.github/workflows/validate-windows-binaries.yml
6880
with:
6981
channel: ${{ inputs.channel }}
7082
ref: ${{ inputs.ref || github.ref }}
7183
torchonly: ${{ inputs.torchonly }}
84+
version: ${{ inputs.version }}
85+
release-matrix: ${{ needs.generate-release-matrix.outputs.matrix }}
7286

7387
linux:
7488
if: inputs.os == 'linux' || inputs.os == 'all'
89+
needs: generate-release-matrix
7590
uses: ./.github/workflows/validate-linux-binaries.yml
7691
with:
7792
channel: ${{ inputs.channel }}
7893
ref: ${{ inputs.ref || github.ref }}
7994
torchonly: ${{ inputs.torchonly }}
95+
version: ${{ inputs.version }}
96+
release-matrix: ${{ needs.generate-release-matrix.outputs.matrix }}
8097

8198
linux-aarch64:
8299
if: inputs.os == 'linux-aarch64'
100+
needs: generate-release-matrix
83101
uses: ./.github/workflows/validate-aarch64-linux-binaries.yml
84102
with:
85103
channel: ${{ inputs.channel }}
86104
ref: ${{ inputs.ref || github.ref }}
87105
torchonly: ${{ inputs.torchonly }}
88-
106+
version: ${{ inputs.version }}
107+
release-matrix: ${{ needs.generate-release-matrix.outputs.matrix }}
89108
mac:
90109
if: inputs.os == 'macos' || inputs.os == 'all'
110+
needs: generate-release-matrix
91111
uses: ./.github/workflows/validate-macos-binaries.yml
92112
with:
93113
channel: ${{ inputs.channel }}
94114
ref: ${{ inputs.ref || github.ref }}
95115
torchonly: ${{ inputs.torchonly }}
116+
version: ${{ inputs.version }}
117+
release-matrix: ${{ needs.generate-rlease-matrix.outputs.matrix }}
96118

97119
mac-arm64:
98120
if: inputs.os == 'macos' || inputs.os == 'all'
121+
needs: generate-release-matrix
99122
uses: ./.github/workflows/validate-macos-arm64-binaries.yml
100123
with:
101124
channel: ${{ inputs.channel }}
102125
ref: ${{ inputs.ref || github.ref }}
103126
torchonly: ${{ inputs.torchonly }}
127+
version: ${{ inputs.version }}
128+
release-matrix: ${{ needs.generate-release-matrix.outputs.matrix }}

.github/workflows/validate-linux-binaries.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ on:
1717
default: false
1818
required: false
1919
type: boolean
20+
version:
21+
description: 'Version to validate - optional'
22+
default: ""
23+
required: false
24+
type: string
25+
release-matrix:
26+
description: 'Release matrix - optional'
27+
default: ""
28+
required: false
29+
type: string
2030
workflow_dispatch:
2131
inputs:
2232
channel:
@@ -38,6 +48,16 @@ on:
3848
default: false
3949
required: false
4050
type: boolean
51+
version:
52+
description: 'Version to validate - optional'
53+
default: ""
54+
required: false
55+
type: string
56+
release-matrix:
57+
description: 'Release matrix - optional'
58+
default: ""
59+
required: false
60+
type: string
4161

4262
jobs:
4363
generate-linux-matrix:
@@ -64,8 +84,11 @@ jobs:
6484
set -ex
6585
export ENV_NAME="conda-env-${{ github.run_id }}"
6686
export TORCH_ONLY=${{ inputs.torchonly }}
87+
export RELEASE_VERSION=${{ inputs.version }}
6788
export TARGET_OS="linux"
6889
eval "$(conda shell.bash hook)"
90+
printf '%s\n' ${{ toJson(inputs.release-matrix) }} > release_matrix.json
91+
cat release_matrix.json
6992
7093
# Special case PyPi installation package. And Install of PyPi package via poetry
7194
if [[ ${MATRIX_PACKAGE_TYPE} == "manywheel" && ${MATRIX_GPU_ARCH_VERSION} == "12.1" ]]; then

.github/workflows/validate-macos-arm64-binaries.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ on:
1717
default: false
1818
required: false
1919
type: boolean
20+
version:
21+
description: 'Version to validate - optional'
22+
default: ""
23+
required: false
24+
type: string
25+
release-matrix:
26+
description: 'Release matrix - optional'
27+
default: ""
28+
required: false
29+
type: string
2030
workflow_dispatch:
2131
inputs:
2232
channel:
@@ -38,6 +48,16 @@ on:
3848
default: false
3949
required: false
4050
type: boolean
51+
version:
52+
description: 'Version to validate - optional'
53+
default: ""
54+
required: false
55+
type: string
56+
release-matrix:
57+
description: 'Release matrix - optional'
58+
default: ""
59+
required: false
60+
type: string
4161

4262
jobs:
4363
generate-macos-arm64-matrix:
@@ -64,4 +84,6 @@ jobs:
6484
export ENV_NAME="conda-env-${{ github.run_id }}"
6585
export TARGET_OS="macos-arm64"
6686
export TORCH_ONLY=${{ inputs.torchonly }}
87+
export RELEASE_VERSION=${{ inputs.version }}
88+
printf '%s\n' ${{ toJson(inputs.release-matrix) }} > release_matrix.json
6789
source ./.github/scripts/validate_binaries.sh

.github/workflows/validate-macos-binaries.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ on:
1717
default: false
1818
required: false
1919
type: boolean
20+
version:
21+
description: 'Version to validate - optional'
22+
default: ""
23+
required: false
24+
type: string
25+
release-matrix:
26+
description: 'Release matrix - optional'
27+
default: ""
28+
required: false
29+
type: string
2030
workflow_dispatch:
2131
inputs:
2232
channel:
@@ -38,6 +48,16 @@ on:
3848
default: false
3949
required: false
4050
type: boolean
51+
version:
52+
description: 'Version to validate - optional'
53+
default: ""
54+
required: false
55+
type: string
56+
release-matrix:
57+
description: 'Release matrix - optional'
58+
default: ""
59+
required: false
60+
type: string
4161

4262
jobs:
4363
generate-macos-matrix:
@@ -64,4 +84,6 @@ jobs:
6484
export ENV_NAME="conda-env-${{ github.run_id }}"
6585
export TARGET_OS="macos"
6686
export TORCH_ONLY=${{ inputs.torchonly }}
87+
export RELEASE_VERSION=${{ inputs.version }}
88+
printf '%s\n' ${{ toJson(inputs.release-matrix) }} > release_matrix.json
6789
source ./.github/scripts/validate_binaries.sh

.github/workflows/validate-windows-binaries.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ on:
1717
default: false
1818
required: false
1919
type: boolean
20+
version:
21+
description: 'Version to validate - optional'
22+
default: ""
23+
required: false
24+
type: string
25+
release-matrix:
26+
description: 'Release matrix - optional'
27+
default: ""
28+
required: false
29+
type: string
2030
workflow_dispatch:
2131
inputs:
2232
channel:
@@ -38,6 +48,16 @@ on:
3848
default: false
3949
required: false
4050
type: boolean
51+
version:
52+
description: 'Version to validate - optional'
53+
default: ""
54+
required: false
55+
type: string
56+
release-matrix:
57+
description: 'Release matrix - optional'
58+
default: ""
59+
required: false
60+
type: string
4161

4262
jobs:
4363
generate-windows-matrix:
@@ -46,7 +66,6 @@ jobs:
4666
package-type: all
4767
os: windows
4868
channel: ${{ inputs.channel }}
49-
5069
win:
5170
needs: generate-windows-matrix
5271
strategy:
@@ -66,9 +85,10 @@ jobs:
6685
export ENV_NAME="conda-env-${{ github.run_id }}"
6786
export TARGET_OS="windows"
6887
export TORCH_ONLY=${{ inputs.torchonly }}
88+
export RELEASE_VERSION=${{ inputs.version }}
89+
printf '%s\n' ${{ toJson(inputs.release-matrix) }} > release_matrix.json
6990
source /c/Jenkins/Miniconda3/etc/profile.d/conda.sh
7091
if [[ ${MATRIX_GPU_ARCH_VERSION} == "12.1" ]]; then
7192
./windows/internal/driver_update.bat
7293
fi
73-
7494
source ./.github/scripts/validate_binaries.sh

test/smoke_test/smoke_test.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
import sys
44
import argparse
55
import torch
6+
import json
67
import importlib
78
import subprocess
89
import torch._dynamo
910
import torch.nn as nn
1011
import torch.nn.functional as F
12+
from pathlib import Path
1113

1214
gpu_arch_ver = os.getenv("MATRIX_GPU_ARCH_VERSION")
1315
gpu_arch_type = os.getenv("MATRIX_GPU_ARCH_TYPE")
1416
channel = os.getenv("MATRIX_CHANNEL")
15-
stable_version = os.getenv("MATRIX_STABLE_VERSION")
1617
package_type = os.getenv("MATRIX_PACKAGE_TYPE")
1718
target_os = os.getenv("TARGET_OS")
19+
BASE_DIR = Path(__file__).parent.parent.parent
1820

1921
is_cuda_system = gpu_arch_type == "cuda"
2022
NIGHTLY_ALLOWED_DELTA = 3
@@ -52,8 +54,27 @@ def forward(self, x):
5254
output = self.fc1(x)
5355
return output
5456

57+
def load_json_from_basedir(filename: str):
58+
try:
59+
with open(BASE_DIR / filename) as fptr:
60+
return json.load(fptr)
61+
except FileNotFoundError as exc:
62+
raise ImportError(f"File {filename} not found error: {exc.strerror}") from exc
63+
except json.JSONDecodeError as exc:
64+
raise ImportError(f"Invalid JSON {filename}") from exc
65+
66+
def read_release_matrix():
67+
return load_json_from_basedir("release_matrix.json")
5568

5669
def check_version(package: str) -> None:
70+
release_version = os.getenv("RELEASE_VERSION")
71+
# if release_version is specified, use it to validate the packages
72+
if(release_version):
73+
release_matrix = read_release_matrix()
74+
stable_version = release_matrix["torch"]
75+
else:
76+
stable_version = os.getenv("MATRIX_STABLE_VERSION")
77+
5778
# only makes sense to check nightly package where dates are known
5879
if channel == "nightly":
5980
check_nightly_binaries_date(package)
@@ -62,6 +83,20 @@ def check_version(package: str) -> None:
6283
raise RuntimeError(
6384
f"Torch version mismatch, expected {stable_version} for channel {channel}. But its {torch.__version__}"
6485
)
86+
87+
if release_version and package == "all":
88+
for module in MODULES:
89+
imported_module = importlib.import_module(module["name"])
90+
module_version = imported_module.__version__
91+
if not module_version.startswith(release_matrix[module["name"]]):
92+
raise RuntimeError(
93+
f"{module['name']} version mismatch, expected: \
94+
{release_matrix[module['name']]} for channel {channel}. But its {module_version}"
95+
)
96+
else:
97+
print(f"{module['name']} version actual: {module_version} expected: \
98+
{release_matrix[module['name']]} for channel {channel}.")
99+
65100
else:
66101
print(f"Skip version check for channel {channel} as stable version is None")
67102

@@ -255,6 +290,7 @@ def main() -> None:
255290
)
256291
options = parser.parse_args()
257292
print(f"torch: {torch.__version__}")
293+
258294
check_version(options.package)
259295
smoke_test_conv2d()
260296
smoke_test_linalg()

0 commit comments

Comments
 (0)