-
Notifications
You must be signed in to change notification settings - Fork 685
[Windows] Add CI wheel build jobs for Windows #13837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
165 commits
Select commit
Hold shift + click to select a range
d6a70d6
Update
GregoryComer 18866f4
Update
GregoryComer e7423a4
Update
GregoryComer 323d96c
Update
GregoryComer bca23f5
Update
GregoryComer ab69e35
Update
GregoryComer c47d467
Update
GregoryComer cd8e9bc
Update
GregoryComer cb60871
Update
GregoryComer 19dda19
Update
GregoryComer cd0178f
Update
GregoryComer ed4cffd
Update
GregoryComer 934682f
Update
GregoryComer ef62839
Update
GregoryComer 441fd5f
Update
GregoryComer 7010cf3
Update
GregoryComer 3cfae60
Update
GregoryComer b583635
Update
GregoryComer ed133f7
Update
GregoryComer 228e146
Update
GregoryComer b64bd0f
Update
GregoryComer fe40834
Update
GregoryComer b97ba63
Update
GregoryComer 5be90d9
Update
GregoryComer f15e674
Update
GregoryComer 33da5e3
Update
GregoryComer 2a6f87b
Update
GregoryComer 8ce9df7
Update
GregoryComer d5efbf9
Update
GregoryComer e918a78
Update
GregoryComer 3a12680
Update
GregoryComer f0511c6
Update
GregoryComer dcc1ad9
Update
GregoryComer 4fcf61e
Update
GregoryComer 3b38d5a
Update
GregoryComer 2bc56f3
Update
GregoryComer 6e392b6
Update
GregoryComer 82b7858
Update
GregoryComer e2bf0b0
Update
GregoryComer fe214c0
Update
GregoryComer f7db054
Update
GregoryComer e075bed
Update
GregoryComer a1056d7
Update
GregoryComer 3a64498
Update
GregoryComer 1b9b951
Update
GregoryComer 00ffef2
Update
GregoryComer 8664d51
Update
GregoryComer ca165c7
Update
GregoryComer a3be73a
Update
GregoryComer 9b3c472
Update
GregoryComer c46506d
Update
GregoryComer eca7e47
Update
GregoryComer ecf4665
Update
GregoryComer fa1b497
Update
GregoryComer 5c0dd42
Update
GregoryComer c76e310
Update
GregoryComer 612cec0
Update
GregoryComer 0f9fdc5
Update
GregoryComer aad0d66
Update
GregoryComer 480f09c
Update
GregoryComer 07b3463
Update
GregoryComer 083701d
Update
GregoryComer 9173ed5
Update
GregoryComer e0d149e
Update
GregoryComer 198cd72
Update
GregoryComer d138641
Update
GregoryComer 715b648
Update
GregoryComer 00aa3b4
Update
GregoryComer 1b80338
Update
GregoryComer b55594f
Update
GregoryComer 920c64f
Update
GregoryComer 6b48e01
Update
GregoryComer 70b980c
Update
GregoryComer 5866307
Update
GregoryComer 12bf1c9
Update
GregoryComer e5cdeea
Update
GregoryComer a267549
Update
GregoryComer fd59a13
Update
GregoryComer 2202ef1
Update
GregoryComer 8ce15a3
Update
GregoryComer 75ec78e
Update
GregoryComer 1e356e1
Update
GregoryComer 67d6d1d
Update
GregoryComer 2706db0
Update
GregoryComer f151c3d
Update
GregoryComer 7a121a9
Update
GregoryComer ae63814
Update
GregoryComer 39b994c
Update
GregoryComer 569f9c3
Update
GregoryComer fdd8e12
Update
GregoryComer c285ecf
Update
GregoryComer 5948272
Update
GregoryComer edfd321
Update
GregoryComer 95856ad
Update
GregoryComer 7e1efc4
Update
GregoryComer 240ae1b
Update
GregoryComer b41ddee
Update
GregoryComer a8ea1e6
Update
GregoryComer 15b9ce0
Update
GregoryComer b1566bc
Update
GregoryComer a8795a5
Update
GregoryComer f63ba8d
Update
GregoryComer fd3d9c3
Update
GregoryComer 447d814
Update
GregoryComer fc9d9b9
Update
GregoryComer a8171c9
Update
GregoryComer 8a4a0e3
Update
GregoryComer aae2ad8
Update
GregoryComer bc6b1a9
Update
GregoryComer fbde97d
Update
GregoryComer 056b85d
Update
GregoryComer c5fe24f
Update
GregoryComer 0360486
Update
GregoryComer aec4169
Update
GregoryComer d521e08
Update
GregoryComer 271d870
Update
GregoryComer 8a68c22
Update
GregoryComer 95ab941
Update
GregoryComer 1381885
Update
GregoryComer ae5b6e3
Update
GregoryComer 3128d72
Update
GregoryComer a74df90
Update
GregoryComer 6efefde
Update
GregoryComer bfe75f2
Update
GregoryComer 1ad84b8
Update
GregoryComer 2bdb390
Update
GregoryComer 8c9322c
Update
GregoryComer c88e350
Update
GregoryComer be158fd
Update
GregoryComer 053b8de
Update
GregoryComer e8531a4
Update
GregoryComer 04c7a05
Update
GregoryComer 87bfc3d
Update
GregoryComer 68a3cdd
Update
GregoryComer 7ddbc04
Update
GregoryComer 82f54e4
Update
GregoryComer 074dcf0
Update
GregoryComer d78f795
Update
GregoryComer 2220f86
Update
GregoryComer 2692f94
Update
GregoryComer ed00d71
Update
GregoryComer 661f4a7
Update
GregoryComer 46cf0e6
Update
GregoryComer 44df1d6
Update
GregoryComer 82fc792
Update
GregoryComer 023baef
Update
GregoryComer 43db3a9
Update
GregoryComer 7abfa44
Update
GregoryComer 0c7c5d3
Update
GregoryComer f5319f0
Update
GregoryComer 66bdcfe
Update
GregoryComer 036f302
Update
GregoryComer 94760b4
Update
GregoryComer efa5b13
Update
GregoryComer eb3715c
Update
GregoryComer 7326544
Update
GregoryComer 205413d
Update
GregoryComer 1bb4994
Update
GregoryComer 18f0fe3
Update
GregoryComer 377dad4
Update
GregoryComer 5e177d4
Update
GregoryComer 4d35f0b
Update
GregoryComer 56f6ea6
Update
GregoryComer 4e75b92
Update
GregoryComer 70ab5e5
Update
GregoryComer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env python | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
from typing import List | ||
|
||
import torch | ||
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner | ||
from executorch.examples.models import Backend, Model, MODEL_NAME_TO_MODEL | ||
from executorch.examples.models.model_factory import EagerModelFactory | ||
from executorch.examples.xnnpack import MODEL_NAME_TO_OPTIONS | ||
from executorch.examples.xnnpack.quantization.utils import quantize as quantize_xnn | ||
from executorch.exir import EdgeCompileConfig, to_edge_transform_and_lower | ||
from executorch.extension.pybindings.portable_lib import ( | ||
_load_for_executorch_from_buffer, | ||
) | ||
from test_base import ModelTest | ||
|
||
|
||
def test_model_xnnpack(model: Model, quantize: bool) -> None: | ||
model_instance, example_inputs, _, _ = EagerModelFactory.create_model( | ||
*MODEL_NAME_TO_MODEL[str(model)] | ||
) | ||
|
||
model_instance.eval() | ||
ref_outputs = model_instance(*example_inputs) | ||
|
||
if quantize: | ||
quant_type = MODEL_NAME_TO_OPTIONS[str(model)].quantization | ||
model_instance = torch.export.export_for_training( | ||
model_instance, example_inputs | ||
) | ||
model_instance = quantize_xnn( | ||
model_instance.module(), example_inputs, quant_type | ||
) | ||
|
||
lowered = to_edge_transform_and_lower( | ||
torch.export.export(model_instance, example_inputs), | ||
partitioner=[XnnpackPartitioner()], | ||
compile_config=EdgeCompileConfig( | ||
_check_ir_validity=False, | ||
), | ||
).to_executorch() | ||
|
||
loaded_model = _load_for_executorch_from_buffer(lowered.buffer) | ||
et_outputs = loaded_model([*example_inputs]) | ||
|
||
if isinstance(ref_outputs, torch.Tensor): | ||
ref_outputs = (ref_outputs,) | ||
|
||
assert len(ref_outputs) == len(et_outputs) | ||
for i in range(len(ref_outputs)): | ||
torch.testing.assert_close(ref_outputs[i], et_outputs[i], atol=1e-4, rtol=1e-5) | ||
|
||
|
||
def run_tests(model_tests: List[ModelTest]) -> None: | ||
for model_test in model_tests: | ||
if model_test.backend == Backend.Xnnpack: | ||
test_model_xnnpack(model_test.model, quantize=False) | ||
else: | ||
raise RuntimeError(f"Unsupported backend {model_test.backend}.") | ||
|
||
|
||
if __name__ == "__main__": | ||
run_tests( | ||
model_tests=[ | ||
ModelTest( | ||
model=Model.Mv3, | ||
backend=Backend.Xnnpack, | ||
), | ||
] | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
REM This is lightly modified from the torchvision Windows build logic. | ||
REM See https://github.com/pytorch/vision/blob/main/packaging/windows/internal/vc_env_helper.bat | ||
|
||
@echo on | ||
|
||
set VC_VERSION_LOWER=17 | ||
set VC_VERSION_UPPER=18 | ||
|
||
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -legacy -products * -version [%VC_VERSION_LOWER%^,%VC_VERSION_UPPER%^) -property installationPath`) do ( | ||
if exist "%%i" if exist "%%i\VC\Auxiliary\Build\vcvarsall.bat" ( | ||
set "VS15INSTALLDIR=%%i" | ||
set "VS15VCVARSALL=%%i\VC\Auxiliary\Build\vcvarsall.bat" | ||
goto vswhere | ||
) | ||
) | ||
|
||
:vswhere | ||
if "%VSDEVCMD_ARGS%" == "" ( | ||
call "%VS15VCVARSALL%" x64 || exit /b 1 | ||
) else ( | ||
call "%VS15VCVARSALL%" x64 %VSDEVCMD_ARGS% || exit /b 1 | ||
) | ||
|
||
@echo on | ||
|
||
if "%CU_VERSION%" == "xpu" call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" | ||
|
||
set DISTUTILS_USE_SDK=1 | ||
|
||
set args=%1 | ||
shift | ||
:start | ||
if [%1] == [] goto done | ||
set args=%args% %1 | ||
shift | ||
goto start | ||
|
||
:done | ||
if "%args%" == "" ( | ||
echo Usage: vc_env_helper.bat [command] [args] | ||
echo e.g. vc_env_helper.bat cl /c test.cpp | ||
) | ||
|
||
set work_dir=%CD% | ||
if exist setup.py ( | ||
echo "Creating symlink..." | ||
REM Setup a symlink to shorten the path length. | ||
REM Note that the ET directory has to be named "executorch". | ||
cd %GITHUB_WORKSPACE% | ||
if not exist et\ ( | ||
mkdir et | ||
) | ||
cd et | ||
echo Work dir: %work_dir% | ||
if not exist executorch\ ( | ||
mklink /d executorch %work_dir% | ||
) | ||
cd executorch | ||
) | ||
|
||
%args% || exit /b 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Build Windows Wheels | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- nightly | ||
- main | ||
- release/* | ||
tags: | ||
# NOTE: Binary build pipelines should only get triggered on release candidate builds | ||
# Release candidate tags look like: v1.11.0-rc1 | ||
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ | ||
workflow_dispatch: | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
generate-matrix: | ||
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main | ||
with: | ||
package-type: wheel | ||
os: windows | ||
test-infra-repository: pytorch/test-infra | ||
test-infra-ref: main | ||
with-cuda: disabled | ||
with-rocm: disabled | ||
python-versions: '["3.10", "3.11", "3.12"]' | ||
|
||
build: | ||
needs: generate-matrix | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- repository: pytorch/executorch | ||
pre-script: .ci\\scripts\\wheel\\pre_build_script.sh | ||
env-script: .ci\\scripts\\wheel\\vc_env_helper.bat | ||
post-script: .ci\\scripts\\wheel\\post_build_script.sh | ||
smoke-test-script: .ci/scripts/wheel/test_windows.py | ||
package-name: executorch | ||
name: ${{ matrix.repository }} | ||
uses: pytorch/test-infra/.github/workflows/build_wheels_windows.yml@main | ||
with: | ||
repository: ${{ matrix.repository }} | ||
ref: "" | ||
test-infra-repository: pytorch/test-infra | ||
test-infra-ref: main | ||
build-matrix: ${{ needs.generate-matrix.outputs.matrix }} | ||
pre-script: ${{ matrix.pre-script }} | ||
env-script: ${{ matrix.env-script }} | ||
post-script: ${{ matrix.post-script }} | ||
package-name: ${{ matrix.package-name }} | ||
smoke-test-script: ${{ matrix.smoke-test-script }} | ||
trigger-event: ${{ github.event_name }} | ||
wheel-build-params: "--verbose" | ||
submodules: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,8 @@ endif() | |
# Otherwise, flatc will target the project's toolchain (i.e. iOS, or Android). | ||
ExternalProject_Add( | ||
flatbuffers_ep | ||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatc_proj | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More path length workarounds. |
||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatc_ep | ||
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/flatc_ep/src/build | ||
SOURCE_DIR ${PROJECT_SOURCE_DIR}/third-party/flatbuffers | ||
CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON | ||
-DFLATBUFFERS_INSTALL=ON | ||
|
@@ -82,6 +83,7 @@ ExternalProject_Add( | |
flatcc_ep | ||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatcc_ep | ||
SOURCE_DIR ${PROJECT_SOURCE_DIR}/third-party/flatcc | ||
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/flatcc_ep/src/build | ||
CMAKE_ARGS -DFLATCC_RTONLY=OFF | ||
-DFLATCC_TEST=OFF | ||
-DFLATCC_REFLECTION=OFF | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test logic is intentionally different from the Linux/Mac logic. This is due to needing a bunch of additional environment setup in the job for native build. This Windows test logic is actually a bit more comprehensive, as it uses pybindings and verifies model outputs (vs just running the exported model on the native runner and ensuring it doesn't crash). I'd like to come back and update the other logic post-GA.