Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
d6a70d6
Update
GregoryComer Aug 26, 2025
18866f4
Update
GregoryComer Aug 26, 2025
e7423a4
Update
GregoryComer Aug 26, 2025
323d96c
Update
GregoryComer Aug 26, 2025
bca23f5
Update
GregoryComer Aug 27, 2025
ab69e35
Update
GregoryComer Aug 27, 2025
c47d467
Update
GregoryComer Aug 27, 2025
cd8e9bc
Update
GregoryComer Aug 27, 2025
cb60871
Update
GregoryComer Aug 27, 2025
19dda19
Update
GregoryComer Aug 27, 2025
cd0178f
Update
GregoryComer Aug 27, 2025
ed4cffd
Update
GregoryComer Aug 27, 2025
934682f
Update
GregoryComer Aug 27, 2025
ef62839
Update
GregoryComer Aug 27, 2025
441fd5f
Update
GregoryComer Aug 27, 2025
7010cf3
Update
GregoryComer Aug 27, 2025
3cfae60
Update
GregoryComer Aug 27, 2025
b583635
Update
GregoryComer Aug 27, 2025
ed133f7
Update
GregoryComer Aug 27, 2025
228e146
Update
GregoryComer Aug 27, 2025
b64bd0f
Update
GregoryComer Aug 27, 2025
fe40834
Update
GregoryComer Aug 27, 2025
b97ba63
Update
GregoryComer Aug 27, 2025
5be90d9
Update
GregoryComer Aug 27, 2025
f15e674
Update
GregoryComer Aug 27, 2025
33da5e3
Update
GregoryComer Aug 28, 2025
2a6f87b
Update
GregoryComer Aug 28, 2025
8ce9df7
Update
GregoryComer Aug 28, 2025
d5efbf9
Update
GregoryComer Aug 28, 2025
e918a78
Update
GregoryComer Aug 28, 2025
3a12680
Update
GregoryComer Aug 28, 2025
f0511c6
Update
GregoryComer Aug 28, 2025
dcc1ad9
Update
GregoryComer Aug 28, 2025
4fcf61e
Update
GregoryComer Aug 28, 2025
3b38d5a
Update
GregoryComer Aug 28, 2025
2bc56f3
Update
GregoryComer Aug 28, 2025
6e392b6
Update
GregoryComer Aug 28, 2025
82b7858
Update
GregoryComer Aug 28, 2025
e2bf0b0
Update
GregoryComer Aug 28, 2025
fe214c0
Update
GregoryComer Aug 28, 2025
f7db054
Update
GregoryComer Aug 28, 2025
e075bed
Update
GregoryComer Aug 28, 2025
a1056d7
Update
GregoryComer Aug 28, 2025
3a64498
Update
GregoryComer Aug 28, 2025
1b9b951
Update
GregoryComer Aug 28, 2025
00ffef2
Update
GregoryComer Aug 28, 2025
8664d51
Update
GregoryComer Aug 28, 2025
ca165c7
Update
GregoryComer Aug 28, 2025
a3be73a
Update
GregoryComer Aug 29, 2025
9b3c472
Update
GregoryComer Aug 29, 2025
c46506d
Update
GregoryComer Aug 29, 2025
eca7e47
Update
GregoryComer Aug 29, 2025
ecf4665
Update
GregoryComer Aug 29, 2025
fa1b497
Update
GregoryComer Aug 29, 2025
5c0dd42
Update
GregoryComer Aug 29, 2025
c76e310
Update
GregoryComer Aug 29, 2025
612cec0
Update
GregoryComer Aug 29, 2025
0f9fdc5
Update
GregoryComer Aug 29, 2025
aad0d66
Update
GregoryComer Aug 29, 2025
480f09c
Update
GregoryComer Aug 29, 2025
07b3463
Update
GregoryComer Aug 29, 2025
083701d
Update
GregoryComer Aug 29, 2025
9173ed5
Update
GregoryComer Aug 29, 2025
e0d149e
Update
GregoryComer Aug 29, 2025
198cd72
Update
GregoryComer Aug 29, 2025
d138641
Update
GregoryComer Aug 30, 2025
715b648
Update
GregoryComer Aug 30, 2025
00aa3b4
Update
GregoryComer Aug 30, 2025
1b80338
Update
GregoryComer Aug 30, 2025
b55594f
Update
GregoryComer Aug 30, 2025
920c64f
Update
GregoryComer Aug 30, 2025
6b48e01
Update
GregoryComer Aug 30, 2025
70b980c
Update
GregoryComer Aug 30, 2025
5866307
Update
GregoryComer Aug 31, 2025
12bf1c9
Update
GregoryComer Aug 31, 2025
e5cdeea
Update
GregoryComer Aug 31, 2025
a267549
Update
GregoryComer Aug 31, 2025
fd59a13
Update
GregoryComer Aug 31, 2025
2202ef1
Update
GregoryComer Aug 31, 2025
8ce15a3
Update
GregoryComer Aug 31, 2025
75ec78e
Update
GregoryComer Aug 31, 2025
1e356e1
Update
GregoryComer Sep 2, 2025
67d6d1d
Update
GregoryComer Sep 2, 2025
2706db0
Update
GregoryComer Sep 2, 2025
f151c3d
Update
GregoryComer Sep 2, 2025
7a121a9
Update
GregoryComer Sep 2, 2025
ae63814
Update
GregoryComer Sep 2, 2025
39b994c
Update
GregoryComer Sep 2, 2025
569f9c3
Update
GregoryComer Sep 2, 2025
fdd8e12
Update
GregoryComer Sep 2, 2025
c285ecf
Update
GregoryComer Sep 2, 2025
5948272
Update
GregoryComer Sep 2, 2025
edfd321
Update
GregoryComer Sep 3, 2025
95856ad
Update
GregoryComer Sep 3, 2025
7e1efc4
Update
GregoryComer Sep 3, 2025
240ae1b
Update
GregoryComer Sep 3, 2025
b41ddee
Update
GregoryComer Sep 3, 2025
a8ea1e6
Update
GregoryComer Sep 3, 2025
15b9ce0
Update
GregoryComer Sep 3, 2025
b1566bc
Update
GregoryComer Sep 3, 2025
a8795a5
Update
GregoryComer Sep 3, 2025
f63ba8d
Update
GregoryComer Sep 3, 2025
fd3d9c3
Update
GregoryComer Sep 3, 2025
447d814
Update
GregoryComer Sep 3, 2025
fc9d9b9
Update
GregoryComer Sep 3, 2025
a8171c9
Update
GregoryComer Sep 3, 2025
8a4a0e3
Update
GregoryComer Sep 3, 2025
aae2ad8
Update
GregoryComer Sep 3, 2025
bc6b1a9
Update
GregoryComer Sep 3, 2025
fbde97d
Update
GregoryComer Sep 3, 2025
056b85d
Update
GregoryComer Sep 3, 2025
c5fe24f
Update
GregoryComer Sep 3, 2025
0360486
Update
GregoryComer Sep 3, 2025
aec4169
Update
GregoryComer Sep 3, 2025
d521e08
Update
GregoryComer Sep 3, 2025
271d870
Update
GregoryComer Sep 3, 2025
8a68c22
Update
GregoryComer Sep 3, 2025
95ab941
Update
GregoryComer Sep 3, 2025
1381885
Update
GregoryComer Sep 3, 2025
ae5b6e3
Update
GregoryComer Sep 4, 2025
3128d72
Update
GregoryComer Sep 4, 2025
a74df90
Update
GregoryComer Sep 4, 2025
6efefde
Update
GregoryComer Sep 4, 2025
bfe75f2
Update
GregoryComer Sep 5, 2025
1ad84b8
Update
GregoryComer Sep 5, 2025
2bdb390
Update
GregoryComer Sep 5, 2025
8c9322c
Update
GregoryComer Sep 5, 2025
c88e350
Update
GregoryComer Sep 6, 2025
be158fd
Update
GregoryComer Sep 6, 2025
053b8de
Update
GregoryComer Sep 6, 2025
e8531a4
Update
GregoryComer Sep 6, 2025
04c7a05
Update
GregoryComer Sep 6, 2025
87bfc3d
Update
GregoryComer Sep 6, 2025
68a3cdd
Update
GregoryComer Sep 6, 2025
7ddbc04
Update
GregoryComer Sep 6, 2025
82f54e4
Update
GregoryComer Sep 7, 2025
074dcf0
Update
GregoryComer Sep 7, 2025
d78f795
Update
GregoryComer Sep 7, 2025
2220f86
Update
GregoryComer Sep 7, 2025
2692f94
Update
GregoryComer Sep 7, 2025
ed00d71
Update
GregoryComer Sep 7, 2025
661f4a7
Update
GregoryComer Sep 8, 2025
46cf0e6
Update
GregoryComer Sep 8, 2025
44df1d6
Update
GregoryComer Sep 8, 2025
82fc792
Update
GregoryComer Sep 8, 2025
023baef
Update
GregoryComer Sep 8, 2025
43db3a9
Update
GregoryComer Sep 8, 2025
7abfa44
Update
GregoryComer Sep 8, 2025
0c7c5d3
Update
GregoryComer Sep 8, 2025
f5319f0
Update
GregoryComer Sep 8, 2025
66bdcfe
Update
GregoryComer Sep 9, 2025
036f302
Update
GregoryComer Sep 9, 2025
94760b4
Update
GregoryComer Sep 9, 2025
efa5b13
Update
GregoryComer Sep 9, 2025
eb3715c
Update
GregoryComer Sep 9, 2025
7326544
Update
GregoryComer Sep 9, 2025
205413d
Update
GregoryComer Sep 9, 2025
1bb4994
Update
GregoryComer Sep 10, 2025
18f0fe3
Update
GregoryComer Sep 10, 2025
377dad4
Update
GregoryComer Sep 10, 2025
5e177d4
Update
GregoryComer Sep 10, 2025
4d35f0b
Update
GregoryComer Sep 10, 2025
56f6ea6
Update
GregoryComer Sep 10, 2025
4e75b92
Update
GregoryComer Sep 11, 2025
70ab5e5
Update
GregoryComer Sep 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/scripts/test_model.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function ExportModel-Xnnpack {
[bool]$quantize
)

if $(quantize) {
if ($quantize) {
python -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate --quantize | Write-Host
$modelFile = "$($modelName)_xnnpack_q8.pte"
} else {
Expand Down
19 changes: 18 additions & 1 deletion .ci/scripts/wheel/pre_build_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,26 @@ set -euxo pipefail

# This script is run before building ExecuTorch binaries

# Clone nested submodules for tokenizers - this is a workaround for recursive
# submodule clone failing due to path length limitations on Windows. Eventually,
# we should update the core job in test-infra to enable long paths before
# checkout to avoid needing to do this.
pushd extension/llm/tokenizers
git submodule update --init
popd

# On Windows, enable symlinks and re-checkout the current revision to create
# the symlinked src/ directory. This is needed to build the wheel.
UNAME_S=$(uname -s)
if [[ $UNAME_S == *"MINGW"* || $UNAME_S == *"MSYS"* ]]; then
echo "Enabling symlinks on Windows"
git config core.symlinks true
git checkout -f HEAD
fi

# Manually install build requirements because `python setup.py bdist_wheel` does
# not install them. TODO(dbort): Switch to using `python -m build --wheel`,
# which does install them. Though we'd need to disable build isolation to be
# able to see the installed torch package.

"${GITHUB_WORKSPACE}/${REPOSITORY}/install_requirements.sh" --example
"${GITHUB_WORKSPACE}/${REPOSITORY}/install_requirements.sh" --example
75 changes: 75 additions & 0 deletions .ci/scripts/wheel/test_windows.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env python
Copy link
Member Author

@GregoryComer GregoryComer Sep 10, 2025

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.

# 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,
),
]
)
61 changes: 61 additions & 0 deletions .ci/scripts/wheel/vc_env_helper.bat
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
59 changes: 59 additions & 0 deletions .github/workflows/build-wheels-windows.yml
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
1 change: 1 addition & 0 deletions examples/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __str__(self) -> str:


class Backend(str, Enum):
Xnnpack = "xnnpack"
XnnpackQuantizationDelegation = "xnnpack-quantization-delegation"
CoreMlExportOnly = "coreml"
CoreMlExportAndTest = "coreml-test" # AOT export + test with runner
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def string(cls) -> str:
@classmethod
def write_to_python_file(cls, path: str) -> None:
"""Creates a file similar to PyTorch core's `torch/version.py`."""

lines = [
"from typing import Optional",
'__all__ = ["__version__", "git_version"]',
Expand Down Expand Up @@ -773,7 +774,7 @@ def run(self): # noqa C901
# platform-specific files using InstallerBuildExt.
ext_modules=[
BuiltFile(
src_dir="%CMAKE_CACHE_DIR%/third-party/flatc_proj/bin/",
src_dir="%CMAKE_CACHE_DIR%/third-party/flatc_ep/bin/",
src_name="flatc",
dst="executorch/data/bin/",
is_executable=True,
Expand Down
4 changes: 3 additions & 1 deletion third-party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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
Expand Down
Loading