From d6a70d66a9ca1897446af07392b2c586ec2eeba9 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 26 Aug 2025 15:48:07 -0700 Subject: [PATCH 001/134] Update [ghstack-poisoned] --- kernels/portable/cpu/op_amax.cpp | 3 ++- kernels/portable/cpu/op_amin.cpp | 3 ++- kernels/portable/cpu/op_argmax.cpp | 3 ++- kernels/portable/cpu/op_argmin.cpp | 3 ++- kernels/portable/cpu/op_max.cpp | 7 ++++--- kernels/portable/cpu/op_min.cpp | 7 ++++--- kernels/portable/cpu/op_relu.cpp | 5 ++++- kernels/portable/cpu/op_sign.cpp | 3 ++- kernels/portable/cpu/op_topk.cpp | 4 +++- kernels/portable/cpu/util/math_util.h | 21 ++++++++++++++++++- .../kernels/portable/op_registration_util.bzl | 11 ++++++++++ tools/cmake/preset/windows.cmake | 10 +++------ 12 files changed, 59 insertions(+), 21 deletions(-) diff --git a/kernels/portable/cpu/op_amax.cpp b/kernels/portable/cpu/op_amax.cpp index 192fad5c908..8ae395f3c81 100644 --- a/kernels/portable/cpu/op_amax.cpp +++ b/kernels/portable/cpu/op_amax.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -55,7 +56,7 @@ Tensor& amax_out( for (const auto out_ix : c10::irange(begin, end)) { out_data[out_ix] = plan.execute( [](CTYPE v, CTYPE max_v) { - return std::isnan(v) || v > max_v ? v : max_v; + return utils::isnan_override(v) || v > max_v ? v : max_v; }, out_ix); } diff --git a/kernels/portable/cpu/op_amin.cpp b/kernels/portable/cpu/op_amin.cpp index d4e9be4f4e0..dc077e2dc44 100644 --- a/kernels/portable/cpu/op_amin.cpp +++ b/kernels/portable/cpu/op_amin.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -54,7 +55,7 @@ Tensor& amin_out( for (const auto out_ix : c10::irange(begin, end)) { out_data[out_ix] = plan.execute( [](CTYPE v, CTYPE min_v) { - return std::isnan(v) || v < min_v ? v : min_v; + return utils::isnan_override(v) || v < min_v ? v : min_v; }, out_ix); } diff --git a/kernels/portable/cpu/op_argmax.cpp b/kernels/portable/cpu/op_argmax.cpp index 0e62c049082..e9a561366f7 100644 --- a/kernels/portable/cpu/op_argmax.cpp +++ b/kernels/portable/cpu/op_argmax.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -58,7 +59,7 @@ Tensor& argmax_out( // the below condition as written is equivalent to // !isnan(accval) && (isnan(v) || v > acc_val). See // argument in op_argmin.cpp. - if (!std::isnan(acc_val) && !(v <= acc_val)) { + if (!utils::isnan_override(acc_val) && !(v <= acc_val)) { acc_val = v; acc_ix = ix; } diff --git a/kernels/portable/cpu/op_argmin.cpp b/kernels/portable/cpu/op_argmin.cpp index d422610769f..fda9463c5ee 100644 --- a/kernels/portable/cpu/op_argmin.cpp +++ b/kernels/portable/cpu/op_argmin.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -65,7 +66,7 @@ Tensor& argmin_out( // - false, so the result is true. The result is trivially // - true for the above condition that uses isnan(v) as // - well. - if (!std::isnan(acc_val) && !(v >= acc_val)) { + if (!utils::isnan_override(acc_val) && !(v >= acc_val)) { acc_val = v; acc_ix = ix; } diff --git a/kernels/portable/cpu/op_max.cpp b/kernels/portable/cpu/op_max.cpp index 3f4a1d27c0e..cdea0834806 100644 --- a/kernels/portable/cpu/op_max.cpp +++ b/kernels/portable/cpu/op_max.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -88,8 +89,8 @@ std::tuple max_out( for (const auto out_ix : c10::irange(begin, end)) { std::tuple acc = reduce_over_dim( [](CTYPE v, long ix, CTYPE acc_val, long acc_ix) { - if (!std::isnan(acc_val) && - (std::isnan(v) || v > acc_val)) { + if (!utils::isnan_override(acc_val) && + (utils::isnan_override(v) || v > acc_val)) { acc_val = v; acc_ix = ix; } @@ -132,7 +133,7 @@ max_unary_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) { data_out[0] = lower_bound(); for (const auto i : c10::irange(in.numel())) { CTYPE_OUT val = static_cast(data_in[i]); - if (std::isnan(val)) { + if (utils::isnan_override(val)) { data_out[0] = val; break; } diff --git a/kernels/portable/cpu/op_min.cpp b/kernels/portable/cpu/op_min.cpp index 8b70bcd40f5..d4d59d04128 100644 --- a/kernels/portable/cpu/op_min.cpp +++ b/kernels/portable/cpu/op_min.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -88,8 +89,8 @@ std::tuple min_out( for (const auto out_ix : c10::irange(begin, end)) { std::tuple acc = reduce_over_dim( [](CTYPE v, long ix, CTYPE acc_val, long acc_ix) { - if (!std::isnan(acc_val) && - (std::isnan(v) || v < acc_val)) { + if (!utils::isnan_override(acc_val) && + (utils::isnan_override(v) || v < acc_val)) { acc_val = v; acc_ix = ix; } @@ -132,7 +133,7 @@ min_unary_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) { data_out[0] = upper_bound(); for (const auto i : c10::irange(in.numel())) { CTYPE_OUT val = static_cast(data_in[i]); - if (std::isnan(val)) { + if (utils::isnan_override(val)) { data_out[0] = val; break; } diff --git a/kernels/portable/cpu/op_relu.cpp b/kernels/portable/cpu/op_relu.cpp index 973542a2a77..4b848fa17e4 100644 --- a/kernels/portable/cpu/op_relu.cpp +++ b/kernels/portable/cpu/op_relu.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -45,7 +46,9 @@ Tensor& relu_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) { ET_SWITCH_REALHBF16_TYPES(in.scalar_type(), ctx, "relu.out", CTYPE, [&]() { apply_unary_map_fn( [](const CTYPE val_in) { - return (std::isnan(val_in) || val_in >= CTYPE(0)) ? val_in : CTYPE(0); + return (utils::isnan_override(val_in) || val_in >= CTYPE(0)) + ? val_in + : CTYPE(0); }, in.const_data_ptr(), out.mutable_data_ptr(), diff --git a/kernels/portable/cpu/op_sign.cpp b/kernels/portable/cpu/op_sign.cpp index e6945094973..56d07133539 100644 --- a/kernels/portable/cpu/op_sign.cpp +++ b/kernels/portable/cpu/op_sign.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -42,7 +43,7 @@ Tensor& sign_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) { ET_SWITCH_REALHBF16_TYPES(in.scalar_type(), ctx, "sign.out", CTYPE, [&] { apply_unary_map_fn( [](const CTYPE val_in) { - if (std::isnan(val_in)) { + if (utils::isnan_override(val_in)) { return val_in; } else { return static_cast((val_in > 0) - (val_in < 0)); diff --git a/kernels/portable/cpu/op_topk.cpp b/kernels/portable/cpu/op_topk.cpp index e35e67193bf..e2143ce78d5 100644 --- a/kernels/portable/cpu/op_topk.cpp +++ b/kernels/portable/cpu/op_topk.cpp @@ -10,6 +10,8 @@ #include #include +#include +#include #include namespace torch { @@ -62,7 +64,7 @@ bool float_less_than(T x, T y) { if constexpr (std::is_integral_v) { return x < y; } - return (!std::isnan(x) && std::isnan(y)) || x < y; + return (!utils::isnan_override(x) && utils::isnan_override(y)) || x < y; } template > diff --git a/kernels/portable/cpu/util/math_util.h b/kernels/portable/cpu/util/math_util.h index 2c4828b9e6e..a3a64997a5f 100644 --- a/kernels/portable/cpu/util/math_util.h +++ b/kernels/portable/cpu/util/math_util.h @@ -8,10 +8,14 @@ #pragma once +#include + #if defined(ET_USE_PYTORCH_HEADERS) && ET_USE_PYTORCH_HEADERS #include #endif +#include + namespace torch { namespace executor { namespace native { @@ -29,7 +33,8 @@ template < typename std::enable_if::value, bool>::type = true> INT_T floor_divide(INT_T a, INT_T b) { const auto quot = a / b; - if (std::signbit(a) == std::signbit(b)) { + // MSVC does not like signbit on integral types. + if ((a < 0) == (b < 0)) { return quot; } const auto rem = a % b; @@ -52,6 +57,20 @@ FLOAT_T floor_divide(FLOAT_T a, FLOAT_T b) { return div; } +/** + * A wrapper around std::isnan that works with MSVC. When building with MSVC, + * std::isnan calls with integer inputs fail to compile due to ambiguous + * overload resolution. + */ +template +bool isnan_override(T a) { + if constexpr (!std::is_integral_v) { + return std::isnan(a); + } else { + return false; + } +} + /** * Override min/max so we can emulate PyTorch's behavior with NaN entries. */ diff --git a/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl b/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl index a0394113126..158d2cd2769 100644 --- a/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl +++ b/shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl @@ -279,6 +279,7 @@ ATEN_OPS = ( deps = [ "//executorch/runtime/core/exec_aten/util:scalar_type_util", "//executorch/runtime/core/exec_aten/util:tensor_util", + "//executorch/kernels/portable/cpu/util:math_util", "//executorch/kernels/portable/cpu/util:reduce_util", ], ), @@ -288,6 +289,7 @@ ATEN_OPS = ( "//executorch/runtime/core/exec_aten/util:scalar_type_util", "//executorch/runtime/core/exec_aten/util:tensor_util", "//executorch/kernels/portable/cpu/util:index_util", + "//executorch/kernels/portable/cpu/util:math_util", "//executorch/kernels/portable/cpu/util:reduce_util", ], ), @@ -311,12 +313,14 @@ ATEN_OPS = ( op_target( name = "op_argmax", deps = [ + "//executorch/kernels/portable/cpu/util:math_util", "//executorch/kernels/portable/cpu/util:reduce_util", ], ), op_target( name = "op_argmin", deps = [ + "//executorch/kernels/portable/cpu/util:math_util", "//executorch/kernels/portable/cpu/util:reduce_util", ], ), @@ -839,6 +843,7 @@ ATEN_OPS = ( op_target( name = "op_max", deps = [ + "//executorch/kernels/portable/cpu/util:math_util", "//executorch/kernels/portable/cpu/util:reduce_util", ], ), @@ -876,6 +881,7 @@ ATEN_OPS = ( op_target( name = "op_min", deps = [ + "//executorch/kernels/portable/cpu/util:math_util", "//executorch/kernels/portable/cpu/util:reduce_util", ], ), @@ -1052,6 +1058,7 @@ ATEN_OPS = ( name = "op_relu", deps = [ "//executorch/kernels/portable/cpu/util:functional_util", + "//executorch/kernels/portable/cpu/util:math_util", ], ), op_target( @@ -1162,6 +1169,7 @@ ATEN_OPS = ( name = "op_sign", deps = [ "//executorch/kernels/portable/cpu/util:functional_util", + "//executorch/kernels/portable/cpu/util:math_util", ], ), op_target( @@ -1270,6 +1278,9 @@ ATEN_OPS = ( ), op_target( name = "op_topk", + deps = [ + "//executorch/kernels/portable/cpu/util:math_util", + ] ), op_target( name = "op_transpose_copy", diff --git a/tools/cmake/preset/windows.cmake b/tools/cmake/preset/windows.cmake index fb44ed56494..5cf26a21caf 100644 --- a/tools/cmake/preset/windows.cmake +++ b/tools/cmake/preset/windows.cmake @@ -5,19 +5,15 @@ # LICENSE file in the root directory of this source tree. # keep sorted +set_overridable_option(EXECUTORCH_BUILD_EXECUTOR_RUNNER ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_EVALUE_UTIL ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON) # Below options are not yet buildable on Windows, but should be. -set(EXECUTORCH_BUILD_PORTABLE_OPS - OFF - CACHE BOOL "" -) -# set_overridable_option(EXECUTORCH_BUILD_EXECUTOR_RUNNER ON) -# set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON) -# set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON) # set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON) From 18866f43b9442ef7d5ffb892f4109de974c861c3 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 26 Aug 2025 15:56:42 -0700 Subject: [PATCH 002/134] Update [ghstack-poisoned] --- .github/workflows/build-presets.yml | 5 ++++- backends/xnnpack/cmake/Dependencies.cmake | 8 ++++++++ tools/cmake/preset/windows.cmake | 4 +--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index 76ec7dfd42d..794c715eaf7 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -109,7 +109,7 @@ jobs: strategy: fail-fast: false matrix: - preset: [windows] + preset: [pybind, windows] with: job-name: build ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} @@ -122,14 +122,17 @@ jobs: Set-PSDebug -Trace 1 \$ErrorActionPreference = 'Stop' \$PSNativeCommandUseErrorActionPreference = \$true + conda create --yes --quiet -n et python=3.12 conda activate et python install_requirements.py + cmake --preset ${{ matrix.preset }} -T ClangCL if (\$LASTEXITCODE -ne 0) { Write-Host "CMake configuration was unsuccessful. Exit code: \$LASTEXITCODE." exit \$LASTEXITCODE } + \$numCores = [System.Environment]::GetEnvironmentVariable('NUMBER_OF_PROCESSORS') - 1 cmake --build cmake-out -j \$numCores if (\$LASTEXITCODE -ne 0) { diff --git a/backends/xnnpack/cmake/Dependencies.cmake b/backends/xnnpack/cmake/Dependencies.cmake index 8d5d0845430..ce25f5cec22 100644 --- a/backends/xnnpack/cmake/Dependencies.cmake +++ b/backends/xnnpack/cmake/Dependencies.cmake @@ -55,6 +55,14 @@ else() ) endif() +if(WIN32) + # These XNNPACK options don't currently build on Windows. + set_overridable_option(XNNPACK_ENABLE_AVX256SKX OFF) + set_overridable_option(XNNPACK_ENABLE_AVX256VNNI OFF) + set_overridable_option(XNNPACK_ENABLE_AVX256VNNIGFNI OFF) + set_overridable_option(XNNPACK_ENABLE_AVX512BF16 OFF) +endif() + set(XNNPACK_BUILD_ALL_MICROKERNELS OFF CACHE BOOL "" diff --git a/tools/cmake/preset/windows.cmake b/tools/cmake/preset/windows.cmake index 5cf26a21caf..b75a5af578e 100644 --- a/tools/cmake/preset/windows.cmake +++ b/tools/cmake/preset/windows.cmake @@ -14,6 +14,4 @@ set_overridable_option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON) set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON) set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON) - -# Below options are not yet buildable on Windows, but should be. -# set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON) +set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON) From e7423a45b46ed35b9ec4276de722313636fe7323 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 26 Aug 2025 16:18:10 -0700 Subject: [PATCH 003/134] Update [ghstack-poisoned] --- extension/data_loader/CMakeLists.txt | 5 +++++ tools/cmake/preset/pybind.cmake | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/extension/data_loader/CMakeLists.txt b/extension/data_loader/CMakeLists.txt index 104cd23c977..a5e7a0c4a81 100644 --- a/extension/data_loader/CMakeLists.txt +++ b/extension/data_loader/CMakeLists.txt @@ -24,6 +24,11 @@ if(NOT ET_HAVE_SYS_MMAN_H AND NOT WIN32) "extension/data_loader/mmap_data_loader.cpp" ) endif() +if(WIN32) + list(APPEND _extension_data_loader__srcs + "extension/data_loader/mman_windows.cpp" + ) +endif() list(TRANSFORM _extension_data_loader__srcs PREPEND "${EXECUTORCH_ROOT}/") add_library(extension_data_loader ${_extension_data_loader__srcs}) target_link_libraries(extension_data_loader executorch_core) diff --git a/tools/cmake/preset/pybind.cmake b/tools/cmake/preset/pybind.cmake index e13fe026ef2..c7ad94cd8be 100644 --- a/tools/cmake/preset/pybind.cmake +++ b/tools/cmake/preset/pybind.cmake @@ -21,12 +21,13 @@ set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON) set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON) set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON) -set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING ON) if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set_overridable_option(EXECUTORCH_BUILD_COREML ON) + set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING ON) elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") set_overridable_option(EXECUTORCH_BUILD_COREML ON) + set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING ON) elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WIN32" ) From 323d96ced98390c0b23d68e271daf8c6143234da Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 26 Aug 2025 16:24:53 -0700 Subject: [PATCH 004/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 15 +++++++++++++++ .github/workflows/_unittest.yml | 9 +++++++++ backends/xnnpack/CMakeLists.txt | 2 +- install_executorch.py | 5 ----- setup.py | 7 ++++++- 5 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 .ci/scripts/unittest-windows.ps1 diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 new file mode 100644 index 00000000000..9c0e7c073ed --- /dev/null +++ b/.ci/scripts/unittest-windows.ps1 @@ -0,0 +1,15 @@ +Set-PSDebug -Trace 1 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $true + +conda create --yes --quiet -n et python=3.12 +conda activate et + +install_executorch.bat +if ($LASTEXITCODE -ne 0) { + Write-Host "Installation was unsuccessful. Exit code: $LASTEXITCODE." + exit $LASTEXITCODE +} + +# Run pytest with coverage +pytest -n auto --cov=./ --cov-report=xml diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index 63f5e6693b7..47681add8ce 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -52,3 +52,12 @@ jobs: # This is needed to get the prebuilt PyTorch wheel from S3 ${CONDA_RUN} --no-capture-output pip install awscli==1.37.21 .ci/scripts/unittest-macos.sh --build-tool "${{ inputs.build-tool }}" --build-mode "${{ inputs.build-mode }}" --editable "${{ inputs.editable }}" + + windows: + uses: pytorch/test-infra/.github/workflows/windows_job.yml@main + with: + submodules: 'recursive' + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + script: | + conda init powershell + powershell .ci/scripts/unittest-windows.ps1 diff --git a/backends/xnnpack/CMakeLists.txt b/backends/xnnpack/CMakeLists.txt index 5e2bc3d3f9b..200d8987b19 100644 --- a/backends/xnnpack/CMakeLists.txt +++ b/backends/xnnpack/CMakeLists.txt @@ -62,7 +62,7 @@ endforeach() if(WIN32 AND NOT CMAKE_CROSSCOMPILING) set(MV_COMMAND powershell -Command - "Move-Item -Path ${_xnnpack_flatbuffer__outputs} -Destination ${_xnnpack_schema__outputs}" + "Move-Item -Path ${_xnnpack_flatbuffer__outputs} -Destination ${_xnnpack_schema__outputs} -Force" ) else() set(MV_COMMAND mv ${_xnnpack_flatbuffer__outputs} ${_xnnpack_schema__outputs}) diff --git a/install_executorch.py b/install_executorch.py index a6cb89dd587..f64d9539d36 100644 --- a/install_executorch.py +++ b/install_executorch.py @@ -195,11 +195,6 @@ def main(args): return cmake_args = [os.getenv("CMAKE_ARGS", "")] - # Use ClangCL on Windows. - # ClangCL is an alias to Clang that configures it to work in an MSVC-compatible - # mode. Using it on Windows to avoid compiler compatibility issues for MSVC. - if os.name == "nt": - cmake_args.append("-T ClangCL") os.environ["CMAKE_ARGS"] = " ".join(cmake_args) check_and_update_submodules() diff --git a/setup.py b/setup.py index 69f59a2a2d5..7908f97bf34 100644 --- a/setup.py +++ b/setup.py @@ -672,6 +672,10 @@ def run(self): # noqa C901 f"-DCMAKE_BUILD_TYPE={cmake_build_type}", ] + # Use ClangCL on Windows. + if _is_windows(): + cmake_configuration_args += ["-T ClangCL"] + # Allow adding extra cmake args through the environment. Used by some # tests and demos to expand the set of targets included in the pip # package. @@ -795,7 +799,8 @@ def run(self): # noqa C901 dependent_cmake_flags=["EXECUTORCH_BUILD_EXTENSION_TRAINING"], ), BuiltExtension( - src="codegen/tools/selective_build.*", + src_dir="%CMAKE_CACHE_DIR%/codegen/tools/%BUILD_TYPE%/", + src="selective_build.cp*" if _is_windows() else "selective_build.*", modpath="executorch.codegen.tools.selective_build", dependent_cmake_flags=["EXECUTORCH_BUILD_PYBIND"], ), From cd8e9bc2143372b81472657ac374a976c536333e Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 26 Aug 2025 20:45:20 -0700 Subject: [PATCH 005/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 58a5ba657cb..ca8b85b19db 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -8,6 +8,9 @@ set(CMAKE_POLICY_VERSION_MINIMUM 3.5) add_subdirectory(json) add_subdirectory(gflags) +# Unset the toolchain to build for the host instead of the toolchain set for the project. +set(_host_toolchain) + if(EXECUTORCH_BUILD_PYBIND) add_subdirectory(pybind11) endif() @@ -18,8 +21,9 @@ endif() # MARK: - flatbuffers -if(WIN32) +if(CMAKE_HOST_CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") set(_executorch_external_project_additional_args) + set(_host_toolchain ClangCL) else() # Always use Make to avoid needing to codesign flatc if the project is using Xcode. set(_executorch_external_project_additional_args CMAKE_GENERATOR "Unix Makefiles") @@ -38,8 +42,7 @@ ExternalProject_Add( -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT}" - # Unset the toolchain to build for the host instead of the toolchain set for the project. - -DCMAKE_TOOLCHAIN_FILE= + -DCMAKE_TOOLCHAIN_FILE="${_host_toolchain}" # If building for iOS, "unset" these variables to rely on the host (macOS) defaults. $<$,$>>:-DCMAKE_OSX_SYSROOT=> -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} @@ -90,7 +93,7 @@ ExternalProject_Add( -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_TOOLCHAIN_FILE= + -DCMAKE_TOOLCHAIN_FILE="${_host_toolchain}" $<$,$>>:-DCMAKE_OSX_SYSROOT=> -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} ${_flatcc_extra_cmake_args} From cb608719bd0ad25985af6da94993d574fab27dac Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 26 Aug 2025 20:53:44 -0700 Subject: [PATCH 006/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index ca8b85b19db..eaa8167b0fe 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -42,7 +42,7 @@ ExternalProject_Add( -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT}" - -DCMAKE_TOOLCHAIN_FILE="${_host_toolchain}" + -DCMAKE_TOOLCHAIN_FILE=${_host_toolchain} # If building for iOS, "unset" these variables to rely on the host (macOS) defaults. $<$,$>>:-DCMAKE_OSX_SYSROOT=> -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} @@ -93,7 +93,7 @@ ExternalProject_Add( -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_TOOLCHAIN_FILE="${_host_toolchain}" + -DCMAKE_TOOLCHAIN_FILE=${_host_toolchain} $<$,$>>:-DCMAKE_OSX_SYSROOT=> -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} ${_flatcc_extra_cmake_args} From 19dda193273a90e761927707a40cb9514be48b0e Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 26 Aug 2025 21:06:42 -0700 Subject: [PATCH 007/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index eaa8167b0fe..16ab2daaf27 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -8,9 +8,6 @@ set(CMAKE_POLICY_VERSION_MINIMUM 3.5) add_subdirectory(json) add_subdirectory(gflags) -# Unset the toolchain to build for the host instead of the toolchain set for the project. -set(_host_toolchain) - if(EXECUTORCH_BUILD_PYBIND) add_subdirectory(pybind11) endif() @@ -22,8 +19,8 @@ endif() # MARK: - flatbuffers if(CMAKE_HOST_CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") - set(_executorch_external_project_additional_args) - set(_host_toolchain ClangCL) + # Use Clang CL for Windows builds. + set(_executorch_external_project_additional_args -T ClangCL) else() # Always use Make to avoid needing to codesign flatc if the project is using Xcode. set(_executorch_external_project_additional_args CMAKE_GENERATOR "Unix Makefiles") @@ -42,7 +39,8 @@ ExternalProject_Add( -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT}" - -DCMAKE_TOOLCHAIN_FILE=${_host_toolchain} + # Unset the toolchain to build for the host instead of the toolchain set for the project. + -DCMAKE_TOOLCHAIN_FILE= # If building for iOS, "unset" these variables to rely on the host (macOS) defaults. $<$,$>>:-DCMAKE_OSX_SYSROOT=> -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} From cd0178f50f074fea6a237fbeb93dc71f29d6fc36 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 26 Aug 2025 21:11:48 -0700 Subject: [PATCH 008/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 16ab2daaf27..6acf719c65e 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -18,14 +18,23 @@ endif() # MARK: - flatbuffers -if(CMAKE_HOST_CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") - # Use Clang CL for Windows builds. - set(_executorch_external_project_additional_args -T ClangCL) +if(WIN32) + set(_executorch_external_project_additional_args) else() # Always use Make to avoid needing to codesign flatc if the project is using Xcode. set(_executorch_external_project_additional_args CMAKE_GENERATOR "Unix Makefiles") endif() +if(WIN32) + # For some reason, when configuring the external project during build + # CMAKE_C_SIMULATE_ID is set to MSVC, but CMAKE_CXX_SIMULATE_ID is not set. + # To make sure the external project is configured correctly, set it explicitly + # here. + set(_executorch_external_project_extra_cmake_args -DCMAKE_CXX_SIMULATE_ID=MSVC) +else() + set(_executorch_external_project_extra_cmake_args) +endif() + # We use ExternalProject to build flatc from source to force it target the host. # Otherwise, flatc will target the project's toolchain (i.e. iOS, or Android). ExternalProject_Add( @@ -44,6 +53,7 @@ ExternalProject_Add( # If building for iOS, "unset" these variables to rely on the host (macOS) defaults. $<$,$>>:-DCMAKE_OSX_SYSROOT=> -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} + ${_executorch_external_project_extra_cmake_args} BUILD_BYPRODUCTS /bin/flatc ${_executorch_external_project_additional_args} ) @@ -67,16 +77,6 @@ endif() # MARK: - flatcc -if(WIN32) - # For some reason, when configuring the external project during build - # CMAKE_C_SIMULATE_ID is set to MSVC, but CMAKE_CXX_SIMULATE_ID is not set. - # To make sure the external project is configured correctly, set it explicitly - # here. - set(_flatcc_extra_cmake_args -DCMAKE_CXX_SIMULATE_ID=MSVC) -else() - set(_flatcc_extra_cmake_args) -endif() - # Similar to flatbuffers, we want to build flatcc for the host. See inline comments # in the flatbuffers ExternalProject_Add for more details. ExternalProject_Add( @@ -91,10 +91,10 @@ ExternalProject_Add( -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_TOOLCHAIN_FILE=${_host_toolchain} + -DCMAKE_TOOLCHAIN_FILE= $<$,$>>:-DCMAKE_OSX_SYSROOT=> -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} - ${_flatcc_extra_cmake_args} + ${_executorch_external_project_extra_cmake_args} BUILD_BYPRODUCTS /bin/flatcc {_executorch_external_project_additional_args} ) From ed4cffd76ad13c49355b9ae04b85c2535f7eee0f Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 26 Aug 2025 22:04:50 -0700 Subject: [PATCH 009/134] Update [ghstack-poisoned] --- setup.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 7908f97bf34..1553f8ae9ca 100644 --- a/setup.py +++ b/setup.py @@ -708,11 +708,12 @@ def run(self): # noqa C901 cmake_build_args = [ # Default build parallelism based on number of cores, but allow # overriding through the environment. - "-j{parallelism}".format( - parallelism=os.environ.get( - "CMAKE_BUILD_PARALLEL_LEVEL", os.cpu_count() - 1 - ) - ), + "-j1", # DEBUG + #"-j{parallelism}".format( + # parallelism=os.environ.get( + # "CMAKE_BUILD_PARALLEL_LEVEL", os.cpu_count() - 1 + # ) + #), # CMAKE_BUILD_TYPE variable specifies the build type (configuration) for # single-configuration generators (e.g., Makefile Generators or Ninja). # For multi-config generators (like Visual Studio), CMAKE_BUILD_TYPE @@ -720,6 +721,8 @@ def run(self): # noqa C901 # During the build step, --config specifies the configuration to build # for multi-config generators. f"--config={cmake_build_type}", + "--", + "/verbosity:diagnostic", ] # Allow adding extra build args through the environment. Used by some From 934682fe2bf2e84376ed6564eb5d8b82f095c4f3 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 26 Aug 2025 22:13:16 -0700 Subject: [PATCH 010/134] Update [ghstack-poisoned] --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 1553f8ae9ca..0ba49cf8c7b 100644 --- a/setup.py +++ b/setup.py @@ -721,8 +721,6 @@ def run(self): # noqa C901 # During the build step, --config specifies the configuration to build # for multi-config generators. f"--config={cmake_build_type}", - "--", - "/verbosity:diagnostic", ] # Allow adding extra build args through the environment. Used by some @@ -750,6 +748,8 @@ def run(self): # noqa C901 if cmake_cache.is_enabled("EXECUTORCH_BUILD_KERNELS_LLM_AOT"): cmake_build_args += ["--target", "custom_ops_aot_lib"] cmake_build_args += ["--target", "quantized_ops_aot_lib"] + + cmake_build_args += ["--verbose"] # Set PYTHONPATH to the location of the pip package. os.environ["PYTHONPATH"] = ( From ef62839001741dff2a3994964d2e92d27b16ff2b Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 26 Aug 2025 22:31:37 -0700 Subject: [PATCH 011/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 6acf719c65e..245782e7db1 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -30,7 +30,7 @@ if(WIN32) # CMAKE_C_SIMULATE_ID is set to MSVC, but CMAKE_CXX_SIMULATE_ID is not set. # To make sure the external project is configured correctly, set it explicitly # here. - set(_executorch_external_project_extra_cmake_args -DCMAKE_CXX_SIMULATE_ID=MSVC) + set(_executorch_external_project_extra_cmake_args -DCMAKE_CXX_SIMULATE_ID=MSVC -DCMAKE_CXX_COMPILER="clang-cl") else() set(_executorch_external_project_extra_cmake_args) endif() From 441fd5f0c6c04d7054252a3c7ad0a144a60d573d Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 26 Aug 2025 22:38:40 -0700 Subject: [PATCH 012/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 245782e7db1..36bf3678c4e 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -30,7 +30,7 @@ if(WIN32) # CMAKE_C_SIMULATE_ID is set to MSVC, but CMAKE_CXX_SIMULATE_ID is not set. # To make sure the external project is configured correctly, set it explicitly # here. - set(_executorch_external_project_extra_cmake_args -DCMAKE_CXX_SIMULATE_ID=MSVC -DCMAKE_CXX_COMPILER="clang-cl") + set(_executorch_external_project_extra_cmake_args -DCMAKE_CXX_SIMULATE_ID=MSVC -DCMAKE_CXX_COMPILER="clang-cl.exe") else() set(_executorch_external_project_extra_cmake_args) endif() From ed133f74bf862e8a3c16888dd958add0a2169e2b Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Wed, 27 Aug 2025 12:14:16 -0700 Subject: [PATCH 013/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 54fe1a37ec5..dd6a1621d55 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -30,7 +30,8 @@ if(WIN32) # CMAKE_C_SIMULATE_ID is set to MSVC, but CMAKE_CXX_SIMULATE_ID is not set. # To make sure the external project is configured correctly, set it explicitly # here. - set(_executorch_external_project_extra_cmake_args -DCMAKE_CXX_SIMULATE_ID=MSVC -DCMAKE_CXX_COMPILER="clang-cl.exe") + message(STATUS "CXX Compiler: ${CMAKE_CXX_COMPILER}.") + set(_executorch_external_project_extra_cmake_args -DCMAKE_CXX_SIMULATE_ID=MSVC -DCMAKE_CXX_COMPILER="clang") else() # Unset the toolchain to build for the host instead of the toolchain set for the project. set(_executorch_external_project_extra_cmake_args -DCMAKE_TOOLCHAIN_FILE=) From 228e1466b623e3337b2c97fde988bc25cc7cca79 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 27 Aug 2025 14:17:53 -0700 Subject: [PATCH 014/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index dd6a1621d55..1d99a64a7ac 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -31,7 +31,11 @@ if(WIN32) # To make sure the external project is configured correctly, set it explicitly # here. message(STATUS "CXX Compiler: ${CMAKE_CXX_COMPILER}.") - set(_executorch_external_project_extra_cmake_args -DCMAKE_CXX_SIMULATE_ID=MSVC -DCMAKE_CXX_COMPILER="clang") + set(_executorch_external_project_extra_cmake_args + -DCMAKE_CXX_SIMULATE_ID=MSVC + -DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}" + -DCMAKE_C_COMPILER="${CMAKE_C_COMPILER}" + ) else() # Unset the toolchain to build for the host instead of the toolchain set for the project. set(_executorch_external_project_extra_cmake_args -DCMAKE_TOOLCHAIN_FILE=) From b64bd0f4f22f66eaf38d99f2deb3cf0d976bbc81 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 27 Aug 2025 14:52:25 -0700 Subject: [PATCH 015/134] Update [ghstack-poisoned] --- setup.py | 9 +++++---- third-party/CMakeLists.txt | 6 +----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index 0ba49cf8c7b..c12d5c2c1d7 100644 --- a/setup.py +++ b/setup.py @@ -698,6 +698,7 @@ def run(self): # noqa C901 "pybind", "-B", cmake_cache_dir, + "--trace", ], check=True, ) @@ -708,12 +709,12 @@ def run(self): # noqa C901 cmake_build_args = [ # Default build parallelism based on number of cores, but allow # overriding through the environment. - "-j1", # DEBUG - #"-j{parallelism}".format( + "-j1", # DEBUG + # "-j{parallelism}".format( # parallelism=os.environ.get( # "CMAKE_BUILD_PARALLEL_LEVEL", os.cpu_count() - 1 # ) - #), + # ), # CMAKE_BUILD_TYPE variable specifies the build type (configuration) for # single-configuration generators (e.g., Makefile Generators or Ninja). # For multi-config generators (like Visual Studio), CMAKE_BUILD_TYPE @@ -748,7 +749,7 @@ def run(self): # noqa C901 if cmake_cache.is_enabled("EXECUTORCH_BUILD_KERNELS_LLM_AOT"): cmake_build_args += ["--target", "custom_ops_aot_lib"] cmake_build_args += ["--target", "quantized_ops_aot_lib"] - + cmake_build_args += ["--verbose"] # Set PYTHONPATH to the location of the pip package. diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 1d99a64a7ac..0e49d90dd20 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -31,11 +31,7 @@ if(WIN32) # To make sure the external project is configured correctly, set it explicitly # here. message(STATUS "CXX Compiler: ${CMAKE_CXX_COMPILER}.") - set(_executorch_external_project_extra_cmake_args - -DCMAKE_CXX_SIMULATE_ID=MSVC - -DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}" - -DCMAKE_C_COMPILER="${CMAKE_C_COMPILER}" - ) + set(_executorch_external_project_extra_cmake_args -DCMAKE_CXX_SIMULATE_ID=MSVC -DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}" -DCMAKE_C_COMPILER="${CMAKE_C_COMPILER}") else() # Unset the toolchain to build for the host instead of the toolchain set for the project. set(_executorch_external_project_extra_cmake_args -DCMAKE_TOOLCHAIN_FILE=) From fe408346cbd147710a62feb80526feb05d719c79 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 27 Aug 2025 15:32:23 -0700 Subject: [PATCH 016/134] Update [ghstack-poisoned] --- .github/workflows/_unittest.yml | 1 + third-party/CMakeLists.txt | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index 47681add8ce..8be2db83071 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -55,6 +55,7 @@ jobs: windows: uses: pytorch/test-infra/.github/workflows/windows_job.yml@main + if: {{ inputs.build-tool == 'cmake' }} # ET doesn't currently build with buck2 on Windows with: submodules: 'recursive' ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 0e49d90dd20..dfc4eb8c98b 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -37,6 +37,8 @@ else() set(_executorch_external_project_extra_cmake_args -DCMAKE_TOOLCHAIN_FILE=) endif() +message(STATUS "Extra CMake args: ${_executorch_external_project_extra_cmake_args}") + # We use ExternalProject to build flatc from source to force it target the host. # Otherwise, flatc will target the project's toolchain (i.e. iOS, or Android). ExternalProject_Add( @@ -48,12 +50,12 @@ ExternalProject_Add( -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_TESTS=OFF + ${_executorch_external_project_extra_cmake_args} -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT}" # If building for iOS, "unset" these variables to rely on the host (macOS) defaults. $<$,$>>:-DCMAKE_OSX_SYSROOT=> -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} - ${_executorch_external_project_extra_cmake_args} BUILD_BYPRODUCTS /bin/flatc ${_executorch_external_project_additional_args} ) From b97ba637584898841344c635ed4ee2742a7e008b Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 27 Aug 2025 16:05:16 -0700 Subject: [PATCH 017/134] Update [ghstack-poisoned] --- .github/workflows/_unittest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index 8be2db83071..191bf14c83d 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -55,7 +55,7 @@ jobs: windows: uses: pytorch/test-infra/.github/workflows/windows_job.yml@main - if: {{ inputs.build-tool == 'cmake' }} # ET doesn't currently build with buck2 on Windows + #if: {{ inputs.build-tool == 'cmake' }} # ET doesn't currently build with buck2 on Windows with: submodules: 'recursive' ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} From 5be90d98c2904bf4c36a5eb626f3b641a7408981 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 27 Aug 2025 16:16:09 -0700 Subject: [PATCH 018/134] Update [ghstack-poisoned] --- .github/workflows/_unittest.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index 191bf14c83d..47681add8ce 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -55,7 +55,6 @@ jobs: windows: uses: pytorch/test-infra/.github/workflows/windows_job.yml@main - #if: {{ inputs.build-tool == 'cmake' }} # ET doesn't currently build with buck2 on Windows with: submodules: 'recursive' ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} From f15e67497a46eebe5ec55eb543d13c36636d3f7b Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 27 Aug 2025 16:41:36 -0700 Subject: [PATCH 019/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index dfc4eb8c98b..0c2624d26eb 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -58,6 +58,9 @@ ExternalProject_Add( -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} BUILD_BYPRODUCTS /bin/flatc ${_executorch_external_project_additional_args} + LOG_CONFIGURE TRUE + LOG_MERGED_STDOUTERR TRUE + LOG_OUTPUT_ON_FAILURE TRUE ) ExternalProject_Get_Property(flatbuffers_external_project INSTALL_DIR) add_executable(flatc IMPORTED GLOBAL) From 33da5e35cfa4bcf25b426e75a2bcdef9b6ab1a08 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 27 Aug 2025 17:04:33 -0700 Subject: [PATCH 020/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 50 +++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 0c2624d26eb..a95c664c57b 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -25,22 +25,9 @@ else() set(_executorch_external_project_additional_args CMAKE_GENERATOR "Unix Makefiles") endif() -if(WIN32) - # For some reason, when configuring the external project during build - # CMAKE_C_SIMULATE_ID is set to MSVC, but CMAKE_CXX_SIMULATE_ID is not set. - # To make sure the external project is configured correctly, set it explicitly - # here. - message(STATUS "CXX Compiler: ${CMAKE_CXX_COMPILER}.") - set(_executorch_external_project_extra_cmake_args -DCMAKE_CXX_SIMULATE_ID=MSVC -DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}" -DCMAKE_C_COMPILER="${CMAKE_C_COMPILER}") -else() - # Unset the toolchain to build for the host instead of the toolchain set for the project. - set(_executorch_external_project_extra_cmake_args -DCMAKE_TOOLCHAIN_FILE=) -endif() - -message(STATUS "Extra CMake args: ${_executorch_external_project_extra_cmake_args}") - # We use ExternalProject to build flatc from source to force it target the host. # Otherwise, flatc will target the project's toolchain (i.e. iOS, or Android). +if(NOT WIN32) ExternalProject_Add( flatbuffers_external_project PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatbuffers_external_project @@ -50,18 +37,32 @@ ExternalProject_Add( -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_TESTS=OFF - ${_executorch_external_project_extra_cmake_args} -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT}" + # Unset the toolchain to build for the host instead of the toolchain set for the project. + -DCMAKE_TOOLCHAIN_FILE= # If building for iOS, "unset" these variables to rely on the host (macOS) defaults. $<$,$>>:-DCMAKE_OSX_SYSROOT=> -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} BUILD_BYPRODUCTS /bin/flatc ${_executorch_external_project_additional_args} - LOG_CONFIGURE TRUE - LOG_MERGED_STDOUTERR TRUE - LOG_OUTPUT_ON_FAILURE TRUE ) +else() # WIN32 + ExternalProject_Add( + flatbuffers_external_project + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatbuffers_external_project + SOURCE_DIR ${PROJECT_SOURCE_DIR}/third-party/flatbuffers + CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON + -DFLATBUFFERS_INSTALL=ON + -DFLATBUFFERS_BUILD_FLATHASH=OFF + -DFLATBUFFERS_BUILD_FLATLIB=OFF + -DFLATBUFFERS_BUILD_TESTS=OFF + -DCMAKE_INSTALL_PREFIX:PATH= + -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT}" + BUILD_BYPRODUCTS /bin/flatc + ${_executorch_external_project_additional_args} + ) +endif() ExternalProject_Get_Property(flatbuffers_external_project INSTALL_DIR) add_executable(flatc IMPORTED GLOBAL) add_dependencies(flatc flatbuffers_external_project) @@ -82,6 +83,16 @@ endif() # MARK: - flatcc +if(WIN32) + # For some reason, when configuring the external project during build + # CMAKE_C_SIMULATE_ID is set to MSVC, but CMAKE_CXX_SIMULATE_ID is not set. + # To make sure the external project is configured correctly, set it explicitly + # here. + set(_flatcc_extra_cmake_args -DCMAKE_CXX_SIMULATE_ID=MSVC) +else() + set(_flatcc_extra_cmake_args) +endif() + # Similar to flatbuffers, we want to build flatcc for the host. See inline comments # in the flatbuffers ExternalProject_Add for more details. ExternalProject_Add( @@ -96,9 +107,10 @@ ExternalProject_Add( -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_TOOLCHAIN_FILE= $<$,$>>:-DCMAKE_OSX_SYSROOT=> -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} - ${_executorch_external_project_extra_cmake_args} + ${_flatcc_extra_cmake_args} BUILD_BYPRODUCTS /bin/flatcc {_executorch_external_project_additional_args} ) From 2a6f87b6841d3abdb0fef9af19afbc1e843cd066 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 27 Aug 2025 17:14:28 -0700 Subject: [PATCH 021/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index a95c664c57b..e579f1f9dd4 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -59,6 +59,8 @@ else() # WIN32 -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT}" + -DCMAKE_CXX_SIMULATE_ID=MSVC + -DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}" BUILD_BYPRODUCTS /bin/flatc ${_executorch_external_project_additional_args} ) From 8ce9df7dad53f1047030196a9fc08c62bf4b16e4 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 27 Aug 2025 17:29:21 -0700 Subject: [PATCH 022/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index e579f1f9dd4..f75c3c4845f 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -60,8 +60,8 @@ else() # WIN32 -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT}" -DCMAKE_CXX_SIMULATE_ID=MSVC - -DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}" BUILD_BYPRODUCTS /bin/flatc + CMAKE_GENERATOR ${CMAKE_GENERATOR} ${_executorch_external_project_additional_args} ) endif() From d5efbf97b57e5939b7451184ad9023afc3358e90 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 27 Aug 2025 17:41:45 -0700 Subject: [PATCH 023/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index f75c3c4845f..62f69918ee0 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -60,6 +60,7 @@ else() # WIN32 -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT}" -DCMAKE_CXX_SIMULATE_ID=MSVC + -T ClangCL BUILD_BYPRODUCTS /bin/flatc CMAKE_GENERATOR ${CMAKE_GENERATOR} ${_executorch_external_project_additional_args} From e918a78b16433d3d41baa8fc120403adf5da4161 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Wed, 27 Aug 2025 19:21:12 -0700 Subject: [PATCH 024/134] Update [ghstack-poisoned] --- .gitmodules | 2 +- third-party/flatbuffers | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 5f4c5fca1d1..5cbfa47af07 100644 --- a/.gitmodules +++ b/.gitmodules @@ -33,7 +33,7 @@ url = https://gitlab.com/libeigen/eigen.git [submodule "third-party/flatbuffers"] path = third-party/flatbuffers - url = https://github.com/google/flatbuffers.git + url = https://github.com/gregorycomer/flatbuffers.git [submodule "third-party/flatcc"] path = third-party/flatcc url = https://github.com/dvidelabs/flatcc.git diff --git a/third-party/flatbuffers b/third-party/flatbuffers index 595bf0007ab..bb96ad801a1 160000 --- a/third-party/flatbuffers +++ b/third-party/flatbuffers @@ -1 +1 @@ -Subproject commit 595bf0007ab1929570c7671f091313c8fc20644e +Subproject commit bb96ad801a18cfdaef85643daa7360cfe3d3fe84 From 3a126800d6f51275dd714cfb8fe9fd492e29a9c5 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Wed, 27 Aug 2025 19:33:26 -0700 Subject: [PATCH 025/134] Update [ghstack-poisoned] --- setup.py | 3 --- third-party/CMakeLists.txt | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index c12d5c2c1d7..c851377e13c 100644 --- a/setup.py +++ b/setup.py @@ -698,7 +698,6 @@ def run(self): # noqa C901 "pybind", "-B", cmake_cache_dir, - "--trace", ], check=True, ) @@ -750,8 +749,6 @@ def run(self): # noqa C901 cmake_build_args += ["--target", "custom_ops_aot_lib"] cmake_build_args += ["--target", "quantized_ops_aot_lib"] - cmake_build_args += ["--verbose"] - # Set PYTHONPATH to the location of the pip package. os.environ["PYTHONPATH"] = ( site.getsitepackages()[0] + ";" + os.environ.get("PYTHONPATH", "") diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 62f69918ee0..9f19107ffc9 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -44,8 +44,12 @@ ExternalProject_Add( # If building for iOS, "unset" these variables to rely on the host (macOS) defaults. $<$,$>>:-DCMAKE_OSX_SYSROOT=> -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} + --verbose BUILD_BYPRODUCTS /bin/flatc ${_executorch_external_project_additional_args} + LOG_CONFIGURE TRUE + LOG_MERGED_STDOUTERR TRUE + LOG_OUTPUT_ON_FAILURE TRUE ) else() # WIN32 ExternalProject_Add( From f0511c6e0be938f44bc477f290c505bf20f20bb1 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Wed, 27 Aug 2025 20:03:44 -0700 Subject: [PATCH 026/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 9f19107ffc9..878e6572b26 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -44,12 +44,10 @@ ExternalProject_Add( # If building for iOS, "unset" these variables to rely on the host (macOS) defaults. $<$,$>>:-DCMAKE_OSX_SYSROOT=> -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} --verbose BUILD_BYPRODUCTS /bin/flatc - ${_executorch_external_project_additional_args} - LOG_CONFIGURE TRUE - LOG_MERGED_STDOUTERR TRUE - LOG_OUTPUT_ON_FAILURE TRUE + ${_executorch_external_project_additional_args} LOG_CONFIGURE TRUE LOG_MERGED_STDOUTERR TRUE LOG_OUTPUT_ON_FAILURE TRUE ) else() # WIN32 ExternalProject_Add( From dcc1ad9e2c4099f27bb9319cd3fcc84efad660eb Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Wed, 27 Aug 2025 20:27:47 -0700 Subject: [PATCH 027/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 878e6572b26..20f8e76ef2f 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -47,7 +47,7 @@ ExternalProject_Add( -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} --verbose BUILD_BYPRODUCTS /bin/flatc - ${_executorch_external_project_additional_args} LOG_CONFIGURE TRUE LOG_MERGED_STDOUTERR TRUE LOG_OUTPUT_ON_FAILURE TRUE + ${_executorch_external_project_additional_args} ) else() # WIN32 ExternalProject_Add( @@ -62,7 +62,7 @@ else() # WIN32 -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT}" -DCMAKE_CXX_SIMULATE_ID=MSVC - -T ClangCL + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} BUILD_BYPRODUCTS /bin/flatc CMAKE_GENERATOR ${CMAKE_GENERATOR} ${_executorch_external_project_additional_args} From 4fcf61ee9d99ea1554e3586d5692cea942b77ed9 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Wed, 27 Aug 2025 20:47:07 -0700 Subject: [PATCH 028/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 20f8e76ef2f..d9c79248620 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -29,8 +29,8 @@ endif() # Otherwise, flatc will target the project's toolchain (i.e. iOS, or Android). if(NOT WIN32) ExternalProject_Add( - flatbuffers_external_project - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatbuffers_external_project + fb_ep + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/fb_ep SOURCE_DIR ${PROJECT_SOURCE_DIR}/third-party/flatbuffers CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON -DFLATBUFFERS_INSTALL=ON @@ -51,8 +51,8 @@ ExternalProject_Add( ) else() # WIN32 ExternalProject_Add( - flatbuffers_external_project - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatbuffers_external_project + fb_ep + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/fp_ep SOURCE_DIR ${PROJECT_SOURCE_DIR}/third-party/flatbuffers CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON -DFLATBUFFERS_INSTALL=ON @@ -68,9 +68,9 @@ else() # WIN32 ${_executorch_external_project_additional_args} ) endif() -ExternalProject_Get_Property(flatbuffers_external_project INSTALL_DIR) +ExternalProject_Get_Property(fb_ep INSTALL_DIR) add_executable(flatc IMPORTED GLOBAL) -add_dependencies(flatc flatbuffers_external_project) +add_dependencies(flatc fb_ep) if(WIN32 AND NOT CMAKE_CROSSCOMPILING) # flatbuffers does not use CMAKE_BUILD_TYPE. Internally, the build forces Release # config, but from CMake's perspective the build type is always Debug. From 3b38d5a8b178cb1abc7b89de35df54b60594d2ed Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Wed, 27 Aug 2025 21:07:15 -0700 Subject: [PATCH 029/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index d9c79248620..e90acd68b36 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -27,10 +27,9 @@ endif() # We use ExternalProject to build flatc from source to force it target the host. # Otherwise, flatc will target the project's toolchain (i.e. iOS, or Android). -if(NOT WIN32) ExternalProject_Add( - fb_ep - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/fb_ep + flatbuffers_ep + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatbuffers_ep SOURCE_DIR ${PROJECT_SOURCE_DIR}/third-party/flatbuffers CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON -DFLATBUFFERS_INSTALL=ON @@ -44,33 +43,12 @@ ExternalProject_Add( # If building for iOS, "unset" these variables to rely on the host (macOS) defaults. $<$,$>>:-DCMAKE_OSX_SYSROOT=> -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - --verbose BUILD_BYPRODUCTS /bin/flatc ${_executorch_external_project_additional_args} ) -else() # WIN32 - ExternalProject_Add( - fb_ep - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/fp_ep - SOURCE_DIR ${PROJECT_SOURCE_DIR}/third-party/flatbuffers - CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON - -DFLATBUFFERS_INSTALL=ON - -DFLATBUFFERS_BUILD_FLATHASH=OFF - -DFLATBUFFERS_BUILD_FLATLIB=OFF - -DFLATBUFFERS_BUILD_TESTS=OFF - -DCMAKE_INSTALL_PREFIX:PATH= - -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT}" - -DCMAKE_CXX_SIMULATE_ID=MSVC - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - BUILD_BYPRODUCTS /bin/flatc - CMAKE_GENERATOR ${CMAKE_GENERATOR} - ${_executorch_external_project_additional_args} - ) -endif() -ExternalProject_Get_Property(fb_ep INSTALL_DIR) +ExternalProject_Get_Property(flatbuffers_ep INSTALL_DIR) add_executable(flatc IMPORTED GLOBAL) -add_dependencies(flatc fb_ep) +add_dependencies(flatc flatbuffers_ep) if(WIN32 AND NOT CMAKE_CROSSCOMPILING) # flatbuffers does not use CMAKE_BUILD_TYPE. Internally, the build forces Release # config, but from CMake's perspective the build type is always Debug. @@ -101,8 +79,8 @@ endif() # Similar to flatbuffers, we want to build flatcc for the host. See inline comments # in the flatbuffers ExternalProject_Add for more details. ExternalProject_Add( - flatcc_external_project - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatcc_external_project + flatcc_ep + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatcc_ep SOURCE_DIR ${PROJECT_SOURCE_DIR}/third-party/flatcc CMAKE_ARGS -DFLATCC_RTONLY=OFF -DFLATCC_TEST=OFF @@ -120,9 +98,9 @@ ExternalProject_Add( {_executorch_external_project_additional_args} ) file(REMOVE_RECURSE ${PROJECT_SOURCE_DIR}/third-party/flatcc/lib) -ExternalProject_Get_Property(flatcc_external_project INSTALL_DIR) +ExternalProject_Get_Property(flatcc_ep INSTALL_DIR) add_executable(flatcc_cli IMPORTED GLOBAL) -add_dependencies(flatcc_cli flatcc_external_project) +add_dependencies(flatcc_cli flatcc_ep) if(WIN32 AND NOT CMAKE_CROSSCOMPILING) set_target_properties(flatcc_cli PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/flatcc.exe) else() From 2bc56f384ca3929b88df81d0764b16cc58348849 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Wed, 27 Aug 2025 21:29:23 -0700 Subject: [PATCH 030/134] Update [ghstack-poisoned] --- setup.py | 13 ++++++------- third-party/CMakeLists.txt | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index c851377e13c..3307dee08a3 100644 --- a/setup.py +++ b/setup.py @@ -708,12 +708,11 @@ def run(self): # noqa C901 cmake_build_args = [ # Default build parallelism based on number of cores, but allow # overriding through the environment. - "-j1", # DEBUG - # "-j{parallelism}".format( - # parallelism=os.environ.get( - # "CMAKE_BUILD_PARALLEL_LEVEL", os.cpu_count() - 1 - # ) - # ), + "-j{parallelism}".format( + parallelism=os.environ.get( + "CMAKE_BUILD_PARALLEL_LEVEL", os.cpu_count() - 1 + ) + ), # CMAKE_BUILD_TYPE variable specifies the build type (configuration) for # single-configuration generators (e.g., Makefile Generators or Ninja). # For multi-config generators (like Visual Studio), CMAKE_BUILD_TYPE @@ -774,7 +773,7 @@ def run(self): # noqa C901 # platform-specific files using InstallerBuildExt. ext_modules=[ BuiltFile( - src_dir="%CMAKE_CACHE_DIR%/third-party/flatbuffers_external_project/bin/", + src_dir="%CMAKE_CACHE_DIR%/third-party/flatc_proj/bin/", src_name="flatc", dst="executorch/data/bin/", is_executable=True, diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index e90acd68b36..8d3665c513c 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -29,7 +29,7 @@ endif() # Otherwise, flatc will target the project's toolchain (i.e. iOS, or Android). ExternalProject_Add( flatbuffers_ep - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatbuffers_ep + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatc_proj SOURCE_DIR ${PROJECT_SOURCE_DIR}/third-party/flatbuffers CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON -DFLATBUFFERS_INSTALL=ON From 6e392b6d6e110181e12ab1adef5e932d65101cff Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Wed, 27 Aug 2025 22:05:25 -0700 Subject: [PATCH 031/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 7 ++++++- .gitmodules | 2 +- third-party/flatbuffers | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 9c0e7c073ed..1289a30f37c 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -12,4 +12,9 @@ if ($LASTEXITCODE -ne 0) { } # Run pytest with coverage -pytest -n auto --cov=./ --cov-report=xml +# pytest -n auto --cov=./ --cov-report=xml +pytest +if ($LASTEXITCODE -ne 0) { + Write-Host "Pytest invocation was unsuccessful. Exit code: $LASTEXITCODE." + exit $LASTEXITCODE +} \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 5cbfa47af07..5f4c5fca1d1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -33,7 +33,7 @@ url = https://gitlab.com/libeigen/eigen.git [submodule "third-party/flatbuffers"] path = third-party/flatbuffers - url = https://github.com/gregorycomer/flatbuffers.git + url = https://github.com/google/flatbuffers.git [submodule "third-party/flatcc"] path = third-party/flatcc url = https://github.com/dvidelabs/flatcc.git diff --git a/third-party/flatbuffers b/third-party/flatbuffers index bb96ad801a1..595bf0007ab 160000 --- a/third-party/flatbuffers +++ b/third-party/flatbuffers @@ -1 +1 @@ -Subproject commit bb96ad801a18cfdaef85643daa7360cfe3d3fe84 +Subproject commit 595bf0007ab1929570c7671f091313c8fc20644e From 82b7858017655102907a2970190b899ef21bd655 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 28 Aug 2025 12:07:38 -0700 Subject: [PATCH 032/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 4 ++-- .gitignore | 4 ++++ .../models/llama/source_transformation/custom_kv_cache.py | 2 +- extension/llm/custom_ops/custom_ops.py | 2 +- extension/llm/custom_ops/op_tile_crop_aot.py | 2 +- install_executorch.py | 3 --- kernels/quantized/__init__.py | 2 +- setup.py | 5 +++++ 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 1289a30f37c..21e5d67976d 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -13,8 +13,8 @@ if ($LASTEXITCODE -ne 0) { # Run pytest with coverage # pytest -n auto --cov=./ --cov-report=xml -pytest +pytest -n auto --continue-on-collection-errors if ($LASTEXITCODE -ne 0) { Write-Host "Pytest invocation was unsuccessful. Exit code: $LASTEXITCODE." exit $LASTEXITCODE -} \ No newline at end of file +} diff --git a/.gitignore b/.gitignore index 38029ba8458..511fb324ba2 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,7 @@ xcuserdata/ # Android *.aar + +# Windows +*.dll +*.pyd diff --git a/examples/models/llama/source_transformation/custom_kv_cache.py b/examples/models/llama/source_transformation/custom_kv_cache.py index 0fbdd1936ef..8d4d37e0e93 100644 --- a/examples/models/llama/source_transformation/custom_kv_cache.py +++ b/examples/models/llama/source_transformation/custom_kv_cache.py @@ -269,7 +269,7 @@ def replace_kv_cache_with_quantized_kv_cache(module): executorch_package_path = executorch.__path__[-1] libs = list( glob.glob( - f"{executorch_package_path}/**/libquantized_ops_aot_lib.*", + f"{executorch_package_path}/**/*quantized_ops_aot_lib.*", recursive=True, ) ) diff --git a/extension/llm/custom_ops/custom_ops.py b/extension/llm/custom_ops/custom_ops.py index 947eae6c0d0..3c3243142cf 100644 --- a/extension/llm/custom_ops/custom_ops.py +++ b/extension/llm/custom_ops/custom_ops.py @@ -33,7 +33,7 @@ package_path = Path(__file__).parent.resolve() logging.info(f"Looking for libcustom_ops_aot_lib.so in {package_path}") - libs = list(package_path.glob("**/libcustom_ops_aot_lib.*")) + libs = list(package_path.glob("**/*custom_ops_aot_lib.*")) assert len(libs) == 1, f"Expected 1 library but got {len(libs)}" logging.info(f"Loading custom ops library: {libs[0]}") diff --git a/extension/llm/custom_ops/op_tile_crop_aot.py b/extension/llm/custom_ops/op_tile_crop_aot.py index 701aabc441c..e03a979ffc5 100644 --- a/extension/llm/custom_ops/op_tile_crop_aot.py +++ b/extension/llm/custom_ops/op_tile_crop_aot.py @@ -13,7 +13,7 @@ tile_crop = torch.ops.preprocess.tile_crop.default assert tile_crop is not None except: - libs = list(Path(__file__).parent.resolve().glob("libcustom_ops_aot_lib.*")) + libs = list(Path(__file__).parent.resolve().glob("*custom_ops_aot_lib.*")) assert len(libs) == 1, f"Expected 1 library but got {len(libs)}" logging.info(f"Loading custom ops library: {libs[0]}") torch.ops.load_library(libs[0]) diff --git a/install_executorch.py b/install_executorch.py index f64d9539d36..b54e0e21b69 100644 --- a/install_executorch.py +++ b/install_executorch.py @@ -194,9 +194,6 @@ def main(args): clean() return - cmake_args = [os.getenv("CMAKE_ARGS", "")] - os.environ["CMAKE_ARGS"] = " ".join(cmake_args) - check_and_update_submodules() # This option is used in CI to make sure that PyTorch build from the pinned commit # is used instead of nightly. CI jobs wouldn't be able to catch regression from the diff --git a/kernels/quantized/__init__.py b/kernels/quantized/__init__.py index e507db6d936..388363047f2 100644 --- a/kernels/quantized/__init__.py +++ b/kernels/quantized/__init__.py @@ -7,7 +7,7 @@ try: from pathlib import Path - libs = list(Path(__file__).parent.resolve().glob("**/libquantized_ops_aot_lib.*")) + libs = list(Path(__file__).parent.resolve().glob("**/*quantized_ops_aot_lib.*")) del Path assert len(libs) == 1, f"Expected 1 library but got {len(libs)}" import torch as _torch diff --git a/setup.py b/setup.py index 3307dee08a3..db9436d9f61 100644 --- a/setup.py +++ b/setup.py @@ -671,6 +671,11 @@ def run(self): # noqa C901 f"-DCMAKE_PREFIX_PATH={cmake_prefix_path}", f"-DCMAKE_BUILD_TYPE={cmake_build_type}", ] + + # Use ClangCL on Windows. + if _is_windows(): + cmake_configuration_args += ["-T ClangCL"] + # Use ClangCL on Windows. if _is_windows(): From e2bf0b09c7511919e45e3d96193b5b2c824b6b51 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 28 Aug 2025 12:17:53 -0700 Subject: [PATCH 033/134] Update [ghstack-poisoned] --- setup.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/setup.py b/setup.py index db9436d9f61..70b23930762 100644 --- a/setup.py +++ b/setup.py @@ -672,11 +672,6 @@ def run(self): # noqa C901 f"-DCMAKE_BUILD_TYPE={cmake_build_type}", ] - # Use ClangCL on Windows. - if _is_windows(): - cmake_configuration_args += ["-T ClangCL"] - - # Use ClangCL on Windows. if _is_windows(): cmake_configuration_args += ["-T ClangCL"] From fe214c0e8d6494a0edac91579048fad97c99833e Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 28 Aug 2025 13:03:07 -0700 Subject: [PATCH 034/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 6 ++++++ setup.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 21e5d67976d..ccff11e91a3 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -5,6 +5,12 @@ $PSNativeCommandUseErrorActionPreference = $true conda create --yes --quiet -n et python=3.12 conda activate et +# Activate the VS environment - this is required for Dynamo to work, as +# it uses the MSVC compiler. +$vsInstallPath = vswhere -version 17.0 -prerelease -property installationpath +Import-Module (Join-Path $vsInstallPath "Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll") +Enter-VsDevShell -VsInstallPath $vsInstallPath -DevCmdArguments "-arch=x64" -SkipAutomaticLocation + install_executorch.bat if ($LASTEXITCODE -ne 0) { Write-Host "Installation was unsuccessful. Exit code: $LASTEXITCODE." diff --git a/setup.py b/setup.py index 70b23930762..a112802f2a6 100644 --- a/setup.py +++ b/setup.py @@ -671,7 +671,7 @@ def run(self): # noqa C901 f"-DCMAKE_PREFIX_PATH={cmake_prefix_path}", f"-DCMAKE_BUILD_TYPE={cmake_build_type}", ] - + # Use ClangCL on Windows. if _is_windows(): cmake_configuration_args += ["-T ClangCL"] @@ -708,7 +708,7 @@ def run(self): # noqa C901 cmake_build_args = [ # Default build parallelism based on number of cores, but allow # overriding through the environment. - "-j{parallelism}".format( + "-j{parallelism}".format( parallelism=os.environ.get( "CMAKE_BUILD_PARALLEL_LEVEL", os.cpu_count() - 1 ) From f7db054e3f6847e1a4be36d3638197eeab61f8f0 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 28 Aug 2025 13:39:34 -0700 Subject: [PATCH 035/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index ccff11e91a3..6ee08304593 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -7,7 +7,7 @@ conda activate et # Activate the VS environment - this is required for Dynamo to work, as # it uses the MSVC compiler. -$vsInstallPath = vswhere -version 17.0 -prerelease -property installationpath +$vsInstallPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationpath Import-Module (Join-Path $vsInstallPath "Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll") Enter-VsDevShell -VsInstallPath $vsInstallPath -DevCmdArguments "-arch=x64" -SkipAutomaticLocation From e075bed92c34e3676ee8e46ff8d56c740ed47254 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 28 Aug 2025 13:58:57 -0700 Subject: [PATCH 036/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 6ee08304593..d9272f67a27 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -7,7 +7,8 @@ conda activate et # Activate the VS environment - this is required for Dynamo to work, as # it uses the MSVC compiler. -$vsInstallPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationpath +$vsInstallPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationpath +echo "VS Install Path: $vsInstallPath" Import-Module (Join-Path $vsInstallPath "Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll") Enter-VsDevShell -VsInstallPath $vsInstallPath -DevCmdArguments "-arch=x64" -SkipAutomaticLocation From a1056d7ee4560461cf9238c723a07d51e1a2c77d Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 28 Aug 2025 14:15:33 -0700 Subject: [PATCH 037/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index d9272f67a27..8b4458d33d5 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -7,8 +7,7 @@ conda activate et # Activate the VS environment - this is required for Dynamo to work, as # it uses the MSVC compiler. -$vsInstallPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationpath -echo "VS Install Path: $vsInstallPath" +$vsInstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\" Import-Module (Join-Path $vsInstallPath "Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll") Enter-VsDevShell -VsInstallPath $vsInstallPath -DevCmdArguments "-arch=x64" -SkipAutomaticLocation From 3a64498740816d46f8de71989f5b71e69fad1918 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 28 Aug 2025 14:41:36 -0700 Subject: [PATCH 038/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 8b4458d33d5..014091adced 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -5,6 +5,11 @@ $PSNativeCommandUseErrorActionPreference = $true conda create --yes --quiet -n et python=3.12 conda activate et +ls -Path "C:\Program Files" +ls -Path "C:\Program Files (x86)" +ls -Path "C:\Program Files\Microsoft Visual Studio\2022\" +ls -Path "C:\Program Files (x86)\Microsoft Visual Studio\2022\" + # Activate the VS environment - this is required for Dynamo to work, as # it uses the MSVC compiler. $vsInstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\" From 1b9b951ec49389b93b02e9fcea9ef9217211d1fd Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 28 Aug 2025 14:49:53 -0700 Subject: [PATCH 039/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 014091adced..3fa333a8210 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -5,16 +5,16 @@ $PSNativeCommandUseErrorActionPreference = $true conda create --yes --quiet -n et python=3.12 conda activate et -ls -Path "C:\Program Files" -ls -Path "C:\Program Files (x86)" -ls -Path "C:\Program Files\Microsoft Visual Studio\2022\" -ls -Path "C:\Program Files (x86)\Microsoft Visual Studio\2022\" +#ls -Path "C:\Program Files" +#ls -Path "C:\Program Files (x86)" +#ls -Path "C:\Program Files\Microsoft Visual Studio\2022\" +#ls -Path "C:\Program Files (x86)\Microsoft Visual Studio\2022\" # Activate the VS environment - this is required for Dynamo to work, as # it uses the MSVC compiler. -$vsInstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\" -Import-Module (Join-Path $vsInstallPath "Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll") -Enter-VsDevShell -VsInstallPath $vsInstallPath -DevCmdArguments "-arch=x64" -SkipAutomaticLocation +#$vsInstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\" +#Import-Module (Join-Path $vsInstallPath "Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll") +#Enter-VsDevShell -VsInstallPath $vsInstallPath -DevCmdArguments "-arch=x64" -SkipAutomaticLocation install_executorch.bat if ($LASTEXITCODE -ne 0) { From 00ffef258234f5dd9d1b0d7b1d85ff83b716b39b Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 28 Aug 2025 15:08:36 -0700 Subject: [PATCH 040/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 3fa333a8210..a20f787cb82 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -5,16 +5,14 @@ $PSNativeCommandUseErrorActionPreference = $true conda create --yes --quiet -n et python=3.12 conda activate et -#ls -Path "C:\Program Files" -#ls -Path "C:\Program Files (x86)" -#ls -Path "C:\Program Files\Microsoft Visual Studio\2022\" -#ls -Path "C:\Program Files (x86)\Microsoft Visual Studio\2022\" +ls -Path "C:\Program Files (x86)\Microsoft Visual Studio\2022\" +ls -Path "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\x64\bin\" # Activate the VS environment - this is required for Dynamo to work, as # it uses the MSVC compiler. -#$vsInstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\" -#Import-Module (Join-Path $vsInstallPath "Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll") -#Enter-VsDevShell -VsInstallPath $vsInstallPath -DevCmdArguments "-arch=x64" -SkipAutomaticLocation +$vsInstallPath = "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\" +Import-Module (Join-Path $vsInstallPath "Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll") +Enter-VsDevShell -VsInstallPath $vsInstallPath -DevCmdArguments "-arch=x64" -SkipAutomaticLocation install_executorch.bat if ($LASTEXITCODE -ne 0) { From 8664d51e1d69a66fa4258d47d93ed5b980e9b71a Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 28 Aug 2025 15:25:45 -0700 Subject: [PATCH 041/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index a20f787cb82..c31e59b8719 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -5,14 +5,14 @@ $PSNativeCommandUseErrorActionPreference = $true conda create --yes --quiet -n et python=3.12 conda activate et -ls -Path "C:\Program Files (x86)\Microsoft Visual Studio\2022\" -ls -Path "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\x64\bin\" +#ls -Path "C:\Program Files (x86)\Microsoft Visual Studio\2022\" +#ls -Path "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\x64\bin\" # Activate the VS environment - this is required for Dynamo to work, as # it uses the MSVC compiler. -$vsInstallPath = "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\" -Import-Module (Join-Path $vsInstallPath "Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll") -Enter-VsDevShell -VsInstallPath $vsInstallPath -DevCmdArguments "-arch=x64" -SkipAutomaticLocation +#$vsInstallPath = "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\" +#Import-Module (Join-Path $vsInstallPath "Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll") +#Enter-VsDevShell -VsInstallPath $vsInstallPath -DevCmdArguments "-arch=x64" -SkipAutomaticLocation install_executorch.bat if ($LASTEXITCODE -ne 0) { From ca165c768ff5bf93a38159384619b5fbb732b5bc Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 28 Aug 2025 15:43:07 -0700 Subject: [PATCH 042/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index c31e59b8719..6f86c013a04 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -5,14 +5,10 @@ $PSNativeCommandUseErrorActionPreference = $true conda create --yes --quiet -n et python=3.12 conda activate et -#ls -Path "C:\Program Files (x86)\Microsoft Visual Studio\2022\" -#ls -Path "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\x64\bin\" - -# Activate the VS environment - this is required for Dynamo to work, as -# it uses the MSVC compiler. -#$vsInstallPath = "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\" -#Import-Module (Join-Path $vsInstallPath "Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll") -#Enter-VsDevShell -VsInstallPath $vsInstallPath -DevCmdArguments "-arch=x64" -SkipAutomaticLocation +# Activate the VS environment - this is required for Dynamo to work, as it uses the MSVC compiler. +# There are a bunch of env vars that needs. +# See https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line. +& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 install_executorch.bat if ($LASTEXITCODE -ne 0) { From a3be73af1649c752a3a95f5dbdf163e21fbd045a Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 28 Aug 2025 17:12:17 -0700 Subject: [PATCH 043/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 10 +++++++--- .github/workflows/_unittest.yml | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 6f86c013a04..1e37cd851c0 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -1,3 +1,7 @@ +param ( + [bool]$editable +) + Set-PSDebug -Trace 1 $ErrorActionPreference = 'Stop' $PSNativeCommandUseErrorActionPreference = $true @@ -5,12 +9,12 @@ $PSNativeCommandUseErrorActionPreference = $true conda create --yes --quiet -n et python=3.12 conda activate et -# Activate the VS environment - this is required for Dynamo to work, as it uses the MSVC compiler. -# There are a bunch of env vars that needs. +# Activate the VS environment - this is required for Dynamo to work, as it uses MSVC. +# There are a bunch of environment variables that it requires. # See https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line. & "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -install_executorch.bat +install_executorch.bat --editable:$editable if ($LASTEXITCODE -ne 0) { Write-Host "Installation was unsuccessful. Exit code: $LASTEXITCODE." exit $LASTEXITCODE diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index 47681add8ce..53adf7aeb6e 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -56,8 +56,9 @@ jobs: windows: uses: pytorch/test-infra/.github/workflows/windows_job.yml@main with: + if: ${{ inputs.build-tool == 'cmake' }} submodules: 'recursive' ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} script: | conda init powershell - powershell .ci/scripts/unittest-windows.ps1 + powershell .ci/scripts/unittest-windows.ps1 -editable "${{ inputs.editable }}" From 9b3c4720a92f730842d8d5f2116bdec8d47abdd0 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Thu, 28 Aug 2025 20:00:02 -0700 Subject: [PATCH 044/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 1e37cd851c0..6a419da81b1 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -22,7 +22,7 @@ if ($LASTEXITCODE -ne 0) { # Run pytest with coverage # pytest -n auto --cov=./ --cov-report=xml -pytest -n auto --continue-on-collection-errors +pytest -n auto --continue-on-collection-errors -s if ($LASTEXITCODE -ne 0) { Write-Host "Pytest invocation was unsuccessful. Exit code: $LASTEXITCODE." exit $LASTEXITCODE From c46506daf09ee8cceeaef6e42db1d2fbcdcb9fb0 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Thu, 28 Aug 2025 20:25:47 -0700 Subject: [PATCH 045/134] Update [ghstack-poisoned] --- .github/workflows/_unittest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index 53adf7aeb6e..e7e0c91a337 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -54,9 +54,9 @@ jobs: .ci/scripts/unittest-macos.sh --build-tool "${{ inputs.build-tool }}" --build-mode "${{ inputs.build-mode }}" --editable "${{ inputs.editable }}" windows: + if: ${{ inputs.build-tool == 'cmake' }} uses: pytorch/test-infra/.github/workflows/windows_job.yml@main with: - if: ${{ inputs.build-tool == 'cmake' }} submodules: 'recursive' ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} script: | From eca7e47191dd3928e27013656e74a85a8a6b2949 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Thu, 28 Aug 2025 20:42:59 -0700 Subject: [PATCH 046/134] Update [ghstack-poisoned] --- .github/workflows/_unittest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index e7e0c91a337..e06a8b5d7e4 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -19,6 +19,7 @@ on: required: false type: string description: Install ExecuTorch in editable mode or not. + default: 'false' python-version: required: false type: string From ecf4665c11e6cda03264a1632774d45e3add252a Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Thu, 28 Aug 2025 20:49:38 -0700 Subject: [PATCH 047/134] Update [ghstack-poisoned] --- .github/workflows/_unittest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index e06a8b5d7e4..c261f325234 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -62,4 +62,4 @@ jobs: ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} script: | conda init powershell - powershell .ci/scripts/unittest-windows.ps1 -editable "${{ inputs.editable }}" + powershell .ci/scripts/unittest-windows.ps1 -editable ("${{ inputs.editable }}" -eq "true") From fa1b497690c3059b4b7492a506f615e62c78edcf Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Thu, 28 Aug 2025 20:51:14 -0700 Subject: [PATCH 048/134] Update [ghstack-poisoned] --- .github/workflows/_unittest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index c261f325234..5c98ceaf9e8 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -62,4 +62,4 @@ jobs: ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} script: | conda init powershell - powershell .ci/scripts/unittest-windows.ps1 -editable ("${{ inputs.editable }}" -eq "true") + powershell .ci/scripts/unittest-windows.ps1 -editable $("${{ inputs.editable }}" -eq "true") From 5c0dd42dcfffe8382fe337b3534f996d1e15c8f2 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Thu, 28 Aug 2025 21:14:27 -0700 Subject: [PATCH 049/134] Update [ghstack-poisoned] --- .github/workflows/_unittest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index 5c98ceaf9e8..e06a8b5d7e4 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -62,4 +62,4 @@ jobs: ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} script: | conda init powershell - powershell .ci/scripts/unittest-windows.ps1 -editable $("${{ inputs.editable }}" -eq "true") + powershell .ci/scripts/unittest-windows.ps1 -editable "${{ inputs.editable }}" From c76e310d77a13c17d2327986e8a63c6391dbdb43 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Thu, 28 Aug 2025 21:18:27 -0700 Subject: [PATCH 050/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 6a419da81b1..fb1c1286360 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -1,5 +1,5 @@ param ( - [bool]$editable + [string]$editable ) Set-PSDebug -Trace 1 @@ -14,7 +14,7 @@ conda activate et # See https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line. & "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -install_executorch.bat --editable:$editable +install_executorch.bat --editable:$($editable -eq 'true') if ($LASTEXITCODE -ne 0) { Write-Host "Installation was unsuccessful. Exit code: $LASTEXITCODE." exit $LASTEXITCODE From 612cec02a9c649dc2f75fb6da1119c901c57f6aa Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Thu, 28 Aug 2025 21:51:49 -0700 Subject: [PATCH 051/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index fb1c1286360..50d5d8e216a 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -14,7 +14,11 @@ conda activate et # See https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line. & "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -install_executorch.bat --editable:$($editable -eq 'true') +if ($editable -eq 'true') { + install_executorch.bat --editable +} else { + install_executorch.bat +} if ($LASTEXITCODE -ne 0) { Write-Host "Installation was unsuccessful. Exit code: $LASTEXITCODE." exit $LASTEXITCODE From 0f9fdc5dc48c121c536d8710031aae1a36ffaf0a Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Thu, 28 Aug 2025 23:05:18 -0700 Subject: [PATCH 052/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 2 +- .github/workflows/_unittest.yml | 1 + pyproject.toml | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 50d5d8e216a..f4371830c49 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -26,7 +26,7 @@ if ($LASTEXITCODE -ne 0) { # Run pytest with coverage # pytest -n auto --cov=./ --cov-report=xml -pytest -n auto --continue-on-collection-errors -s +pytest -n auto --continue-on-collection-errors -s --timeout=600 --full-trace if ($LASTEXITCODE -ne 0) { Write-Host "Pytest invocation was unsuccessful. Exit code: $LASTEXITCODE." exit $LASTEXITCODE diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index e06a8b5d7e4..783f69df5b7 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -60,6 +60,7 @@ jobs: with: submodules: 'recursive' ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + timeout: 120 script: | conda init powershell powershell .ci/scripts/unittest-windows.ps1 -editable "${{ inputs.editable }}" diff --git a/pyproject.toml b/pyproject.toml index 0637cb827a0..028987f973e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,6 +64,7 @@ dependencies=[ "pytest", "pytest-xdist", "pytest-rerunfailures", + "pytest-timeout", "pyyaml", "ruamel.yaml", "sympy", From aad0d66484eb9e6485f820e9b0912efe03dc41ae Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Thu, 28 Aug 2025 23:37:05 -0700 Subject: [PATCH 053/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index f4371830c49..1a1e6721835 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -26,7 +26,7 @@ if ($LASTEXITCODE -ne 0) { # Run pytest with coverage # pytest -n auto --cov=./ --cov-report=xml -pytest -n auto --continue-on-collection-errors -s --timeout=600 --full-trace +pytest -n auto --continue-on-collection-errors -vv --timeout=600 --full-trace if ($LASTEXITCODE -ne 0) { Write-Host "Pytest invocation was unsuccessful. Exit code: $LASTEXITCODE." exit $LASTEXITCODE From 480f09cfadec2cada0d7d670f553117a01df1325 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Fri, 29 Aug 2025 00:04:25 -0700 Subject: [PATCH 054/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 1a1e6721835..4bcf5235c05 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -26,7 +26,7 @@ if ($LASTEXITCODE -ne 0) { # Run pytest with coverage # pytest -n auto --cov=./ --cov-report=xml -pytest -n auto --continue-on-collection-errors -vv --timeout=600 --full-trace +pytest --continue-on-collection-errors -vv --timeout=600 --full-trace if ($LASTEXITCODE -ne 0) { Write-Host "Pytest invocation was unsuccessful. Exit code: $LASTEXITCODE." exit $LASTEXITCODE From 07b34633b1d226adcc756dbf3741599034721ec9 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Fri, 29 Aug 2025 11:13:05 -0700 Subject: [PATCH 055/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 2 +- pytest.ini | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 4bcf5235c05..8736333f77d 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -26,7 +26,7 @@ if ($LASTEXITCODE -ne 0) { # Run pytest with coverage # pytest -n auto --cov=./ --cov-report=xml -pytest --continue-on-collection-errors -vv --timeout=600 --full-trace +pytest --continue-on-collection-errors -vv --full-trace if ($LASTEXITCODE -ne 0) { Write-Host "Pytest invocation was unsuccessful. Exit code: $LASTEXITCODE." exit $LASTEXITCODE diff --git a/pytest.ini b/pytest.ini index aae87f242a7..319739a6719 100644 --- a/pytest.ini +++ b/pytest.ini @@ -19,9 +19,9 @@ addopts = # examples examples/models/llama/tests examples/models/llama/config - examples/models/llama3_2_vision/preprocess - examples/models/llama3_2_vision/vision_encoder/test - examples/models/llama3_2_vision/text_decoder/test + #examples/models/llama3_2_vision/preprocess + e#xamples/models/llama3_2_vision/vision_encoder/test + ex#amples/models/llama3_2_vision/text_decoder/test # examples/models/llava/test TODO: enable this # exir exir/_serialize/test From 9173ed5b134f2da5a065ca2876b679e581803b97 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 29 Aug 2025 13:47:10 -0700 Subject: [PATCH 056/134] Update [ghstack-poisoned] --- pytest.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytest.ini b/pytest.ini index 319739a6719..e42ab99327e 100644 --- a/pytest.ini +++ b/pytest.ini @@ -20,8 +20,8 @@ addopts = examples/models/llama/tests examples/models/llama/config #examples/models/llama3_2_vision/preprocess - e#xamples/models/llama3_2_vision/vision_encoder/test - ex#amples/models/llama3_2_vision/text_decoder/test + #examples/models/llama3_2_vision/vision_encoder/test + #examples/models/llama3_2_vision/text_decoder/test # examples/models/llava/test TODO: enable this # exir exir/_serialize/test From e0d149e96f0f05b29952d794949335dcc42ff947 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 29 Aug 2025 15:47:14 -0700 Subject: [PATCH 057/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 5 +- pytest-windows.ini | 116 +++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 pytest-windows.ini diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 8736333f77d..071d88627a8 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -24,9 +24,12 @@ if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } +# Install test dependencies +pip install -r .ci/docker/requirements-ci.txt + # Run pytest with coverage # pytest -n auto --cov=./ --cov-report=xml -pytest --continue-on-collection-errors -vv --full-trace +pytest --continue-on-collection-errors -vv --full-trace -c pytest-windows.ini if ($LASTEXITCODE -ne 0) { Write-Host "Pytest invocation was unsuccessful. Exit code: $LASTEXITCODE." exit $LASTEXITCODE diff --git a/pytest-windows.ini b/pytest-windows.ini new file mode 100644 index 00000000000..edf2d6dc40b --- /dev/null +++ b/pytest-windows.ini @@ -0,0 +1,116 @@ +# NOTE: This file is a copy of pytest.ini, but with additional tests disabled for Windows. This +# is intended to be a short-term solution to allow for incrementally enabling tests on Windows. +# This file is intended to be deleted once the enablement is complete. + +[pytest] +addopts = + # show summary of all tests that did not pass + -rEfX + # Make tracebacks shorter + --tb=native + # capture only Python print and C++ py::print, but not C output (low-level Python errors) + --capture=sys + # don't suppress warnings, but don't shove them all to the end either + -p no:warnings + # Ignore backends/arm tests you need to run examples/arm/setup.sh to install some tool to make them work + # For GitHub testing this is setup/executed in the unittest-arm job see .github/workflows/pull.yml for more info. + --ignore-glob=backends/arm/**/* + # explicitly list out tests that are running successfully in oss + .ci/scripts/tests + examples/models/test + devtools/ + --ignore=devtools/visualization/visualization_utils_test.py + # examples + # examples/models/llava/test TODO: enable this + # exir + exir/_serialize/test + exir/backend/test + exir/dialects/backend/test + exir/dialects/edge/test + exir/dialects/test + exir/emit/test + exir/program/test + exir/tests/ + # executorch/export + export/tests + --ignore=export/tests/test_export_stages.py + # kernels/ + kernels/prim_ops/test + kernels/quantized + # Because this test depends on test only cpp ops lib + # Will add test only cmake targets to re-enable this test + # but maybe it is a bit of anti-pattern + --ignore=kernels/quantized/test/test_quant_dequant_per_token.py + kernels/test/test_case_gen.py + # backends/test + # This effort is WIP and will be enabled in CI once testing infra + # is stable and signal to noise ratio is good (no irrelevant failures). + # See https://github.com/pytorch/executorch/discussions/11140 + --ignore=backends/test + backends/test/harness/tests + backends/test/suite/tests + # backends/xnnpack + backends/xnnpack/test/ops + --ignore=backends/xnnpack/test/ops/test_bmm.py + --ignore=backends/xnnpack/test/ops/test_conv2d.py + --ignore=backends/xnnpack/test/ops/test_linear.py + --ignore=backends/xnnpack/test/ops/test_sdpa.py + backends/xnnpack/test/passes + backends/xnnpack/test/recipes + backends/xnnpack/test/serialization + # backends/apple/coreml + backends/apple/coreml/test + # extension/ + extension/llm/custom_ops/test_sdpa_with_kv_cache.py + extension/llm/custom_ops/test_update_cache.py + extension/llm/custom_ops/test_quantized_sdpa.py + extension/pybindings/test + extension/training/pybindings/test + # Runtime + runtime + # Tools + codegen/test + tools/cmake + # test TODO: fix these tests + # test/end2end/test_end2end.py + --ignore=backends/xnnpack/test/ops/linear.py + --ignore=backends/xnnpack/test/models/llama2_et_example.py + # T200992559: Add torchao to ET as core dependency + --ignore=examples/models/llama/tests/test_pre_quantization_transforms.py + --ignore=exir/backend/test/demos + --ignore=exir/backend/test/test_backends.py + --ignore=exir/backend/test/test_backends_lifted.py + --ignore=exir/backend/test/test_partitioner.py + --ignore=exir/tests/test_common.py + --ignore=exir/tests/test_memory_format_ops_pass_aten.py + --ignore=exir/tests/test_memory_planning.py + --ignore=exir/tests/test_op_convert.py + --ignore=exir/tests/test_passes.py + --ignore=exir/tests/test_quant_fusion_pass.py + --ignore=exir/tests/test_quantization.py + --ignore=exir/tests/test_verification.py + + # Tests that are (temporarily) disabled for Windows + # TODO(gjcomer) Re-enable the LLM tests when tokenizers library is available on Windows. + #examples/models/llama3_2_vision/preprocess + #examples/models/llama3_2_vision/vision_encoder/test + #examples/models/llama3_2_vision/text_decoder/test + #examples/models/llama/tests + #examples/models/llama/config + #extension/llm/modules/test + #extension/llm/export + --ignore=extension/pybindings/test/test_pybindings.py::PybindingsTest::test_method_quantized_ops + --ignore=extension/pybindings/test/test_pybindings.py::PybindingsTest::test_quantized_ops + --ignore=runtime/test/test_runtime.py::RuntimeTest::test_load_program_with_path + --ignore=exir/backend/test/test_compatibility.py::TestCompatibility::test_compatibility_in_runtime + --ignore=exir/backend/test/test_compatibility.py::TestCompatibility::test_compatibility_in_runtime_edge_program_manager + --ignore=exir/backend/test/test_lowered_backend_module.py::TestBackendAPI::test_emit_lowered_backend_module_end_to_end + --ignore=exir/backend/test/test_to_backend_multi_method.py::TestToBackendMultiMethod::test_multi_method_end_to_end + --ignore=extension/llm/custom_ops/test_sdpa_with_kv_cache.py::SDPATestForSpeculativeDecode::test_sdpa_with_cache_seq_len_130 + --ignore=devtools/inspector/tests/inspector_test.py::TestInspector::test_etrecord_populates_correct_edge_dialect_aot_intermediate_outputs + --ignore=devtools/inspector/tests/inspector_test.py::TestInspector::test_etrecord_populates_correct_export_program_aot_intermediate_outputs + +# run the same tests multiple times to determine their +# flakiness status. Default to 50 re-runs +flake-finder = true +flake-runs = 50 From 198cd7217fe49c13ae9d08a1e9d62fda7a34eb33 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 29 Aug 2025 16:47:05 -0700 Subject: [PATCH 058/134] Update [ghstack-poisoned] --- exir/operator/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exir/operator/util.py b/exir/operator/util.py index 23dc3edd302..fae9a691813 100644 --- a/exir/operator/util.py +++ b/exir/operator/util.py @@ -48,7 +48,7 @@ def gen_out_variant_schema(func_op_schema: str) -> str: torch.ops.quantized_decomposed.dequantize_per_channel.default, torch.ops.quantized_decomposed.dequantize_per_tensor.default, torch.ops.quantized_decomposed.dequantize_per_tensor.tensor, - torch.ops.quantized_decomposed.convert_element_type.no_fuse, + #torch.ops.quantized_decomposed.convert_element_type.no_fuse, torch.ops.quantized_decomposed.quantize_per_tensor.default, torch.ops.quantized_decomposed.quantize_per_tensor.tensor, torch.ops.quantized_decomposed.quantize_per_channel.default, From d1386415246f612e9533f8dec3d6e71ad655f9e9 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 29 Aug 2025 17:22:59 -0700 Subject: [PATCH 059/134] Update [ghstack-poisoned] --- exir/operator/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exir/operator/util.py b/exir/operator/util.py index fae9a691813..af166505382 100644 --- a/exir/operator/util.py +++ b/exir/operator/util.py @@ -64,5 +64,7 @@ def gen_out_variant_schema(func_op_schema: str) -> str: torch.ops.torchao.choose_qparams_affine.default, ] ) +except AttributeError: + pass except ImportError: pass From 715b6489c4afd4083e0bce50a59e8a5e301ce129 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Fri, 29 Aug 2025 18:09:41 -0700 Subject: [PATCH 060/134] Update [ghstack-poisoned] --- exir/tracer.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/exir/tracer.py b/exir/tracer.py index a8a3a16be3b..64b3029cda0 100644 --- a/exir/tracer.py +++ b/exir/tracer.py @@ -48,6 +48,12 @@ from torch._decomp import get_decompositions from torch._dynamo.guards import Guard from torch._functorch.eager_transforms import _maybe_unwrap_functional_tensor + +print(f"Checking torch version...") +print(f"Version: {torch.__version__}") +print(torch.__file__) +print(torch.export.__file__) + from torch.export import default_decompositions from torch.func import functionalize from torch.fx.operator_schemas import normalize_function From 00aa3b4c8ab23531af903ce10d0a9efa74bf67a5 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Fri, 29 Aug 2025 18:54:44 -0700 Subject: [PATCH 061/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 6 +++--- exir/tracer.py | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 071d88627a8..2dc64009fb4 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -14,6 +14,9 @@ conda activate et # See https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line. & "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 +# Install test dependencies +pip install -r .ci/docker/requirements-ci.txt + if ($editable -eq 'true') { install_executorch.bat --editable } else { @@ -24,9 +27,6 @@ if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } -# Install test dependencies -pip install -r .ci/docker/requirements-ci.txt - # Run pytest with coverage # pytest -n auto --cov=./ --cov-report=xml pytest --continue-on-collection-errors -vv --full-trace -c pytest-windows.ini diff --git a/exir/tracer.py b/exir/tracer.py index 64b3029cda0..0a761e6a308 100644 --- a/exir/tracer.py +++ b/exir/tracer.py @@ -49,11 +49,6 @@ from torch._dynamo.guards import Guard from torch._functorch.eager_transforms import _maybe_unwrap_functional_tensor -print(f"Checking torch version...") -print(f"Version: {torch.__version__}") -print(torch.__file__) -print(torch.export.__file__) - from torch.export import default_decompositions from torch.func import functionalize from torch.fx.operator_schemas import normalize_function From 1b8033894f2b55cf69f4a25e0754ead7b6a50896 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Fri, 29 Aug 2025 22:27:45 -0700 Subject: [PATCH 062/134] Update [ghstack-poisoned] --- pytest-windows.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/pytest-windows.ini b/pytest-windows.ini index edf2d6dc40b..6d1189d32e4 100644 --- a/pytest-windows.ini +++ b/pytest-windows.ini @@ -89,7 +89,6 @@ addopts = --ignore=exir/tests/test_quant_fusion_pass.py --ignore=exir/tests/test_quantization.py --ignore=exir/tests/test_verification.py - # Tests that are (temporarily) disabled for Windows # TODO(gjcomer) Re-enable the LLM tests when tokenizers library is available on Windows. #examples/models/llama3_2_vision/preprocess From b55594fd6eb3193888fed572e142bbb2e408a687 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 30 Aug 2025 00:05:38 -0700 Subject: [PATCH 063/134] Update [ghstack-poisoned] --- pytest-windows.ini | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pytest-windows.ini b/pytest-windows.ini index 6d1189d32e4..0eb30e3583d 100644 --- a/pytest-windows.ini +++ b/pytest-windows.ini @@ -98,16 +98,16 @@ addopts = #examples/models/llama/config #extension/llm/modules/test #extension/llm/export - --ignore=extension/pybindings/test/test_pybindings.py::PybindingsTest::test_method_quantized_ops - --ignore=extension/pybindings/test/test_pybindings.py::PybindingsTest::test_quantized_ops - --ignore=runtime/test/test_runtime.py::RuntimeTest::test_load_program_with_path - --ignore=exir/backend/test/test_compatibility.py::TestCompatibility::test_compatibility_in_runtime - --ignore=exir/backend/test/test_compatibility.py::TestCompatibility::test_compatibility_in_runtime_edge_program_manager - --ignore=exir/backend/test/test_lowered_backend_module.py::TestBackendAPI::test_emit_lowered_backend_module_end_to_end - --ignore=exir/backend/test/test_to_backend_multi_method.py::TestToBackendMultiMethod::test_multi_method_end_to_end - --ignore=extension/llm/custom_ops/test_sdpa_with_kv_cache.py::SDPATestForSpeculativeDecode::test_sdpa_with_cache_seq_len_130 - --ignore=devtools/inspector/tests/inspector_test.py::TestInspector::test_etrecord_populates_correct_edge_dialect_aot_intermediate_outputs - --ignore=devtools/inspector/tests/inspector_test.py::TestInspector::test_etrecord_populates_correct_export_program_aot_intermediate_outputs + --deselect=extension/pybindings/test/test_pybindings.py::PybindingsTest::test_method_quantized_ops + --deselect=extension/pybindings/test/test_pybindings.py::PybindingsTest::test_quantized_ops + --deselect=runtime/test/test_runtime.py::RuntimeTest::test_load_program_with_path + --deselect=exir/backend/test/test_compatibility.py::TestCompatibility::test_compatibility_in_runtime + --deselect=exir/backend/test/test_compatibility.py::TestCompatibility::test_compatibility_in_runtime_edge_program_manager + --deselect=exir/backend/test/test_lowered_backend_module.py::TestBackendAPI::test_emit_lowered_backend_module_end_to_end + --deselect=exir/backend/test/test_to_backend_multi_method.py::TestToBackendMultiMethod::test_multi_method_end_to_end + --deselect=extension/llm/custom_ops/test_sdpa_with_kv_cache.py::SDPATestForSpeculativeDecode::test_sdpa_with_cache_seq_len_130 + --deselect=devtools/inspector/tests/inspector_test.py::TestInspector::test_etrecord_populates_correct_edge_dialect_aot_intermediate_outputs + --deselect=devtools/inspector/tests/inspector_test.py::TestInspector::test_etrecord_populates_correct_export_program_aot_intermediate_outputs # run the same tests multiple times to determine their # flakiness status. Default to 50 re-runs From 920c64f329faaa36182d98665225fc64487c4a00 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 30 Aug 2025 01:02:58 -0700 Subject: [PATCH 064/134] Update [ghstack-poisoned] --- backends/apple/coreml/test/__init__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 backends/apple/coreml/test/__init__.py diff --git a/backends/apple/coreml/test/__init__.py b/backends/apple/coreml/test/__init__.py new file mode 100644 index 00000000000..a2da34ed896 --- /dev/null +++ b/backends/apple/coreml/test/__init__.py @@ -0,0 +1,17 @@ +# 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. + +import sys + +try: + import pytest + + # Skip on Windows + if sys.platform == "win32": + pytest.skip("Core ML is not available on Windows.", allow_module_level=True) + +except ImportError: + pass \ No newline at end of file From 70b980c0e08676571c50c3844fcac5b1e0261990 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 30 Aug 2025 12:20:20 -0700 Subject: [PATCH 065/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 2dc64009fb4..596457a909e 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -29,7 +29,7 @@ if ($LASTEXITCODE -ne 0) { # Run pytest with coverage # pytest -n auto --cov=./ --cov-report=xml -pytest --continue-on-collection-errors -vv --full-trace -c pytest-windows.ini +pytest --continue-on-collection-errors -v --full-trace -c pytest-windows.ini -n auto if ($LASTEXITCODE -ne 0) { Write-Host "Pytest invocation was unsuccessful. Exit code: $LASTEXITCODE." exit $LASTEXITCODE From 586630720052302a83700ce843e310f525e5ca7f Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 30 Aug 2025 19:27:41 -0700 Subject: [PATCH 066/134] Update [ghstack-poisoned] --- .ci/scripts/setup-windows.ps1 | 24 +++++++++++++++++ .ci/scripts/test_model.ps1 | 45 ++++++++++++++++++++++++++++++++ .ci/scripts/unittest-windows.ps1 | 23 ++-------------- .github/workflows/trunk.yml | 14 ++++++++++ 4 files changed, 85 insertions(+), 21 deletions(-) create mode 100644 .ci/scripts/setup-windows.ps1 create mode 100644 .ci/scripts/test_model.ps1 diff --git a/.ci/scripts/setup-windows.ps1 b/.ci/scripts/setup-windows.ps1 new file mode 100644 index 00000000000..20d29e4f558 --- /dev/null +++ b/.ci/scripts/setup-windows.ps1 @@ -0,0 +1,24 @@ +param ( + [string]$editable = $false +) + +conda create --yes --quiet -n et python=3.12 +conda activate et + +# Activate the VS environment - this is required for Dynamo to work, as it uses MSVC. +# There are a bunch of environment variables that it requires. +# See https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line. +& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 + +# Install test dependencies +pip install -r .ci/docker/requirements-ci.txt + +if ($editable -eq 'true') { + install_executorch.bat --editable +} else { + install_executorch.bat +} +if ($LASTEXITCODE -ne 0) { + Write-Host "Installation was unsuccessful. Exit code: $LASTEXITCODE." + exit $LASTEXITCODE +} diff --git a/.ci/scripts/test_model.ps1 b/.ci/scripts/test_model.ps1 new file mode 100644 index 00000000000..058ce4883c9 --- /dev/null +++ b/.ci/scripts/test_model.ps1 @@ -0,0 +1,45 @@ +param ( + [string]$modelName, + [string]$backend, + [string]$buildDir = "cmake-out" + [bool]$strict = $false +) + +Set-PSDebug -Trace 1 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $true + +.ci/scripts/setup-windows.ps1 + +# Build the runner +if (Test-Path -Path $buildDir) { + Remove-Item -Path $buildDir -Recurse -Force +} +New-Item -Path $buildDir -ItemType Directory +Push-Directory $buildDir +cmake .. --preset windows +cmake --build . -t executor_runner -j16 --config Release +if ($LASTEXITCODE -ne 0) { + Write-Host "Runner build failed. Exit code: $LASTEXITCODE." + exit $LASTEXITCODE +} +$executorBinaryPath = Join-Path -Path $buildDir -ChildPath "Release\executor_runner.exe" +Pop-Location + +# Export the model +$exportParams = "--model_name", "$modelName" +if ($strict) { + $exportParams += "--strict" +} +python -m examples.portable.scripts.export @exportParams +if ($LASTEXITCODE -ne 0) { + Write-Host "Model export failed. Exit code: $LASTEXITCODE." + exit $LASTEXITCODE +} + +# Run the runner +& "$executorBinaryPath" --model_path="$(modelName).pte" +if ($LASTEXITCODE -ne 0) { + Write-Host "Model execution failed. Exit code: $LASTEXITCODE." + exit $LASTEXITCODE +} \ No newline at end of file diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 596457a909e..8b8c12247bf 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -1,31 +1,12 @@ param ( - [string]$editable + [string]$editable = $false ) Set-PSDebug -Trace 1 $ErrorActionPreference = 'Stop' $PSNativeCommandUseErrorActionPreference = $true -conda create --yes --quiet -n et python=3.12 -conda activate et - -# Activate the VS environment - this is required for Dynamo to work, as it uses MSVC. -# There are a bunch of environment variables that it requires. -# See https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line. -& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 - -# Install test dependencies -pip install -r .ci/docker/requirements-ci.txt - -if ($editable -eq 'true') { - install_executorch.bat --editable -} else { - install_executorch.bat -} -if ($LASTEXITCODE -ne 0) { - Write-Host "Installation was unsuccessful. Exit code: $LASTEXITCODE." - exit $LASTEXITCODE -} +.ci/scripts/setup-windows.ps1 -editable $editable # Run pytest with coverage # pytest -n auto --cov=./ --cov-report=xml diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index f03f3736588..b58ecee8a79 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -979,3 +979,17 @@ jobs: # Run MCU models chmod +x examples/arm/run_mcu_models_fvp.sh examples/arm/run_mcu_models_fvp.sh --target=cortex-m55 + + test-models-windows: + if: ${{ inputs.build-tool == 'cmake' }} + uses: pytorch/test-infra/.github/workflows/windows_job.yml@main + with: + submodules: 'recursive' + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + timeout: 60 + matrix: + model: [linear, add, add_mul, ic3, ic4, mv2, mv3, resnet18, resnet50, vit, w2l, mobilebert, emformer_join, emformer_transcribe] + backend: [portable, xnnpack] + script: | + conda init powershell + powershell .ci/scripts/test_model.ps1 -modelName $model -backend $backend \ No newline at end of file From 12bf1c9d8e6467786e339ba2069bcaa0a998b497 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 30 Aug 2025 19:54:59 -0700 Subject: [PATCH 067/134] Update [ghstack-poisoned] --- .github/workflows/trunk.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index b58ecee8a79..9319dfa8b4d 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -983,13 +983,14 @@ jobs: test-models-windows: if: ${{ inputs.build-tool == 'cmake' }} uses: pytorch/test-infra/.github/workflows/windows_job.yml@main + strategy: + matrix: + model: [linear, add, add_mul, ic3, ic4, mv2, mv3, resnet18, resnet50, vit, w2l, mobilebert, emformer_join, emformer_transcribe] + backend: [portable, xnnpack] with: submodules: 'recursive' ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} timeout: 60 - matrix: - model: [linear, add, add_mul, ic3, ic4, mv2, mv3, resnet18, resnet50, vit, w2l, mobilebert, emformer_join, emformer_transcribe] - backend: [portable, xnnpack] script: | conda init powershell powershell .ci/scripts/test_model.ps1 -modelName $model -backend $backend \ No newline at end of file From e5cdeea28ccf886ab8f612268aebbf2a87a6970b Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 30 Aug 2025 20:33:49 -0700 Subject: [PATCH 068/134] Update [ghstack-poisoned] --- .github/workflows/trunk.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index 9319dfa8b4d..1b8134fb46c 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -981,7 +981,6 @@ jobs: examples/arm/run_mcu_models_fvp.sh --target=cortex-m55 test-models-windows: - if: ${{ inputs.build-tool == 'cmake' }} uses: pytorch/test-infra/.github/workflows/windows_job.yml@main strategy: matrix: From a267549c7fbe4803cb942ec5e5ee1027cbd60438 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 30 Aug 2025 23:20:36 -0700 Subject: [PATCH 069/134] Update [ghstack-poisoned] --- .github/workflows/trunk.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index 1b8134fb46c..038275737d5 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -992,4 +992,4 @@ jobs: timeout: 60 script: | conda init powershell - powershell .ci/scripts/test_model.ps1 -modelName $model -backend $backend \ No newline at end of file + powershell .ci/scripts/test_model.ps1 -modelName ${{ matrix.model }} -backend ${{ matrix.backend }} \ No newline at end of file From fd59a13e96ffac7a684912b487d992d2c881095d Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 30 Aug 2025 23:40:55 -0700 Subject: [PATCH 070/134] Update [ghstack-poisoned] --- .ci/scripts/test_model.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/test_model.ps1 b/.ci/scripts/test_model.ps1 index 058ce4883c9..3d9dae696be 100644 --- a/.ci/scripts/test_model.ps1 +++ b/.ci/scripts/test_model.ps1 @@ -1,7 +1,7 @@ param ( [string]$modelName, [string]$backend, - [string]$buildDir = "cmake-out" + [string]$buildDir = "cmake-out", [bool]$strict = $false ) From 2202ef1443008720d2f3cba1d55e9ba1e462ff6c Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sun, 31 Aug 2025 00:18:22 -0700 Subject: [PATCH 071/134] Update [ghstack-poisoned] --- .ci/scripts/test_model.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/test_model.ps1 b/.ci/scripts/test_model.ps1 index 3d9dae696be..d48476e8b11 100644 --- a/.ci/scripts/test_model.ps1 +++ b/.ci/scripts/test_model.ps1 @@ -16,7 +16,7 @@ if (Test-Path -Path $buildDir) { Remove-Item -Path $buildDir -Recurse -Force } New-Item -Path $buildDir -ItemType Directory -Push-Directory $buildDir +Push-Location $buildDir cmake .. --preset windows cmake --build . -t executor_runner -j16 --config Release if ($LASTEXITCODE -ne 0) { From 8ce15a3d131b8bb5a49baa3116d5d0bbec633402 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sun, 31 Aug 2025 11:39:27 -0700 Subject: [PATCH 072/134] Update [ghstack-poisoned] --- .ci/scripts/test_model.ps1 | 2 +- .github/workflows/trunk.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.ci/scripts/test_model.ps1 b/.ci/scripts/test_model.ps1 index d48476e8b11..66b6e943ce2 100644 --- a/.ci/scripts/test_model.ps1 +++ b/.ci/scripts/test_model.ps1 @@ -38,7 +38,7 @@ if ($LASTEXITCODE -ne 0) { } # Run the runner -& "$executorBinaryPath" --model_path="$(modelName).pte" +& "$executorBinaryPath" --model_path="$modelName.pte" if ($LASTEXITCODE -ne 0) { Write-Host "Model execution failed. Exit code: $LASTEXITCODE." exit $LASTEXITCODE diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index 038275737d5..d0826adb30b 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -983,6 +983,7 @@ jobs: test-models-windows: uses: pytorch/test-infra/.github/workflows/windows_job.yml@main strategy: + fail-fast: false matrix: model: [linear, add, add_mul, ic3, ic4, mv2, mv3, resnet18, resnet50, vit, w2l, mobilebert, emformer_join, emformer_transcribe] backend: [portable, xnnpack] From 75ec78e817e3356c6f63ac18501f8573e46df58a Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sun, 31 Aug 2025 15:37:29 -0700 Subject: [PATCH 073/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/test_windows.py | 19 +++++++ .github/workflows/build-wheels-windows.yml | 65 ++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 .ci/scripts/wheel/test_windows.py create mode 100644 .github/workflows/build-wheels-windows.yml diff --git a/.ci/scripts/wheel/test_windows.py b/.ci/scripts/wheel/test_windows.py new file mode 100644 index 00000000000..f02772a3476 --- /dev/null +++ b/.ci/scripts/wheel/test_windows.py @@ -0,0 +1,19 @@ +#!/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. + +import test_base +from examples.models import Backend, Model + +if __name__ == "__main__": + test_base.run_tests( + model_tests=[ + test_base.ModelTest( + model=Model.Mv3, + backend=Backend.XnnpackQuantizationDelegation, + ), + ] + ) diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml new file mode 100644 index 00000000000..0881d4c67d1 --- /dev/null +++ b/.github/workflows/build-wheels-windows.yml @@ -0,0 +1,65 @@ +name: Build Windows Wheels + +on: + pull_request: + paths: + - .ci/**/* + - .github/workflows/build-wheels-windows.yml + - examples/**/* + - pyproject.toml + - setup.py + tags: + - ciflow/binaries/* + push: + branches: + - nightly + - 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]+ + - ciflow/binaries/* + workflow_dispatch: + +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 + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/executorch + pre-script: .ci/scripts/wheel/pre_build_script.sh + 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 }} + submodules: recursive + env-var-script: .ci/scripts/wheel/envvar_linux.sh + pre-script: ${{ matrix.pre-script }} + post-script: ${{ matrix.post-script }} + package-name: ${{ matrix.package-name }} + smoke-test-script: ${{ matrix.smoke-test-script }} + trigger-event: ${{ github.event_name }} + From 1e356e1b79dc8a87d3ab31c7e761708a55c69b33 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Mon, 1 Sep 2025 17:46:52 -0700 Subject: [PATCH 074/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/envvar_windows.ps1 | 0 .github/workflows/build-wheels-windows.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 .ci/scripts/wheel/envvar_windows.ps1 diff --git a/.ci/scripts/wheel/envvar_windows.ps1 b/.ci/scripts/wheel/envvar_windows.ps1 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index 0881d4c67d1..6ff5125b002 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -56,7 +56,7 @@ jobs: test-infra-ref: main build-matrix: ${{ needs.generate-matrix.outputs.matrix }} submodules: recursive - env-var-script: .ci/scripts/wheel/envvar_linux.sh + env-var-script: .ci/scripts/wheel/envvar_windows.ps1 pre-script: ${{ matrix.pre-script }} post-script: ${{ matrix.post-script }} package-name: ${{ matrix.package-name }} From 67d6d1d0a6f2808570c6987167ea8d8f5cbab9d0 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Mon, 1 Sep 2025 18:23:50 -0700 Subject: [PATCH 075/134] Update [ghstack-poisoned] --- .github/workflows/build-wheels-windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index 6ff5125b002..08d8e5b2216 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -56,7 +56,7 @@ jobs: test-infra-ref: main build-matrix: ${{ needs.generate-matrix.outputs.matrix }} submodules: recursive - env-var-script: .ci/scripts/wheel/envvar_windows.ps1 + env-script: .ci/scripts/wheel/envvar_windows.ps1 pre-script: ${{ matrix.pre-script }} post-script: ${{ matrix.post-script }} package-name: ${{ matrix.package-name }} From ae63814c399f06cc0eaf5c5afccf7ae6062d06e8 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 2 Sep 2025 11:53:45 -0700 Subject: [PATCH 076/134] Update [ghstack-poisoned] --- .ci/scripts/test_model.ps1 | 56 +++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/.ci/scripts/test_model.ps1 b/.ci/scripts/test_model.ps1 index 66b6e943ce2..79ae08d7f52 100644 --- a/.ci/scripts/test_model.ps1 +++ b/.ci/scripts/test_model.ps1 @@ -9,6 +9,39 @@ Set-PSDebug -Trace 1 $ErrorActionPreference = 'Stop' $PSNativeCommandUseErrorActionPreference = $true +function ExportModel-Portable { + param ( + [string]$model_name, + [bool]$strict + ) + + $exportParams = "--model_name", "$modelName" + if ($strict) { + $exportParams += "--strict" + } + python -m examples.portable.scripts.export @exportParams + if ($LASTEXITCODE -ne 0) { + Write-Host "Model export failed. Exit code: $LASTEXITCODE." + exit $LASTEXITCODE + } + + "$modelName.pte" +} + +function ExportModel-Xnnpack { + param ( + [string]$model_name, + ) + + python -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate + if ($LASTEXITCODE -ne 0) { + Write-Host "Model export failed. Exit code: $LASTEXITCODE." + exit $LASTEXITCODE + } + + "$($modelName)_xnnpack_fp32.pte" +} + .ci/scripts/setup-windows.ps1 # Build the runner @@ -27,19 +60,22 @@ $executorBinaryPath = Join-Path -Path $buildDir -ChildPath "Release\executor_run Pop-Location # Export the model -$exportParams = "--model_name", "$modelName" -if ($strict) { - $exportParams += "--strict" -} -python -m examples.portable.scripts.export @exportParams -if ($LASTEXITCODE -ne 0) { - Write-Host "Model export failed. Exit code: $LASTEXITCODE." - exit $LASTEXITCODE +switch ($backend) { + "portable" { + $model_path = ExportModel-Portable -model_name $modelName -strict $strict + } + "xnnpack" { + $model_path = ExportModel-Xnnpack -model_name $modelName + } + default { + Write-Host "Unknown backend $backend." + exit 1 + } } # Run the runner -& "$executorBinaryPath" --model_path="$modelName.pte" +& "$executorBinaryPath" --model_path="$model_path" if ($LASTEXITCODE -ne 0) { Write-Host "Model execution failed. Exit code: $LASTEXITCODE." exit $LASTEXITCODE -} \ No newline at end of file +} From 39b994ce76f089c1b4105406e2dc1ee3e5817192 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 2 Sep 2025 12:10:14 -0700 Subject: [PATCH 077/134] Update [ghstack-poisoned] --- .ci/scripts/test_model.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/test_model.ps1 b/.ci/scripts/test_model.ps1 index 79ae08d7f52..49a89255bae 100644 --- a/.ci/scripts/test_model.ps1 +++ b/.ci/scripts/test_model.ps1 @@ -30,7 +30,7 @@ function ExportModel-Portable { function ExportModel-Xnnpack { param ( - [string]$model_name, + [string]$model_name ) python -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate From 240ae1b08a77b9a5df4409869b1b0993aed5f645 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 2 Sep 2025 18:04:25 -0700 Subject: [PATCH 078/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/pre_build_script.sh | 11 +++++++++++ .github/workflows/build-wheels-windows.yml | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.ci/scripts/wheel/pre_build_script.sh b/.ci/scripts/wheel/pre_build_script.sh index 424529af864..a20864d7cf4 100755 --- a/.ci/scripts/wheel/pre_build_script.sh +++ b/.ci/scripts/wheel/pre_build_script.sh @@ -9,6 +9,17 @@ set -euxo pipefail # This script is run before building ExecuTorch binaries +# Enable long paths (relevant for Windows, but can run on any system). +git config --system core.longpaths true + +# 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 + # 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 diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index 08d8e5b2216..1b758f62634 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -55,11 +55,10 @@ jobs: test-infra-repository: pytorch/test-infra test-infra-ref: main build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - submodules: recursive + submodules: true env-script: .ci/scripts/wheel/envvar_windows.ps1 pre-script: ${{ matrix.pre-script }} post-script: ${{ matrix.post-script }} package-name: ${{ matrix.package-name }} smoke-test-script: ${{ matrix.smoke-test-script }} trigger-event: ${{ github.event_name }} - From b41ddee759cb052ec304abad158a28697daeaa08 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 2 Sep 2025 18:16:06 -0700 Subject: [PATCH 079/134] Update [ghstack-poisoned] --- conftest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conftest.py b/conftest.py index 74e8c15adc0..3bac9decc4e 100644 --- a/conftest.py +++ b/conftest.py @@ -1,5 +1,7 @@ import sys +collect_ignore_glob = [] + # Skip Apple tests on Windows. Note that some Core ML tests can run on Linux, as the AOT flow # is available. Tests will manage this internally. However, the coremltools import is not available # on Windows and causes collection to fail. The easiest way to manage this seems to be to just From b1566bce5c0beada3c197b662aaf5070100df8c0 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 2 Sep 2025 19:26:27 -0700 Subject: [PATCH 080/134] Update [ghstack-poisoned] --- .github/workflows/build-wheels-windows.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index b622f9b3acb..1af4030969a 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -56,7 +56,6 @@ jobs: test-infra-ref: main build-matrix: ${{ needs.generate-matrix.outputs.matrix }} submodules: true - env-script: .ci\scripts\wheel\envvar_windows.sh pre-script: ${{ matrix.pre-script }} post-script: ${{ matrix.post-script }} package-name: ${{ matrix.package-name }} From a8795a5294ec5d592347d30f282fca41bd25e71a Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 2 Sep 2025 20:09:24 -0700 Subject: [PATCH 081/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 8d3665c513c..29699819ba3 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -31,6 +31,7 @@ ExternalProject_Add( flatbuffers_ep PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatc_proj SOURCE_DIR ${PROJECT_SOURCE_DIR}/third-party/flatbuffers + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/flatc_proj/build CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON -DFLATBUFFERS_INSTALL=ON -DFLATBUFFERS_BUILD_FLATHASH=OFF From f63ba8dac80338432b3ec6fb024cb79526e6a0bd Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 2 Sep 2025 20:10:29 -0700 Subject: [PATCH 082/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 29699819ba3..09b23432d61 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -31,7 +31,7 @@ ExternalProject_Add( flatbuffers_ep PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatc_proj SOURCE_DIR ${PROJECT_SOURCE_DIR}/third-party/flatbuffers - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/flatc_proj/build + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/flatc_proj/src/build CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON -DFLATBUFFERS_INSTALL=ON -DFLATBUFFERS_BUILD_FLATHASH=OFF From fd3d9c35795505a85e478b4f9c4c137bf72a82a0 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 2 Sep 2025 21:06:52 -0700 Subject: [PATCH 083/134] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 index 0d2c32120e8..d99e87edf67 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -29,7 +29,7 @@ if ($LASTEXITCODE -ne 0) { # Run pytest with coverage # pytest -n auto --cov=./ --cov-report=xml -pytest -v --full-trace -c pytest-windows.ini -n auto +pytest -v --full-trace -c pytest-windows.ini if ($LASTEXITCODE -ne 0) { Write-Host "Pytest invocation was unsuccessful. Exit code: $LASTEXITCODE." exit $LASTEXITCODE From a8171c9b6620195f83f19377e2d90ffc27aa54e3 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 2 Sep 2025 21:37:59 -0700 Subject: [PATCH 084/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 09b23432d61..3c3ad668cfc 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -25,13 +25,17 @@ else() set(_executorch_external_project_additional_args CMAKE_GENERATOR "Unix Makefiles") endif() +# DEBUG +if(WIN32) + set_directory_properties(PROPERTIES EP_BASE "C:\\actions-runner\\_work\\") +endif() + # We use ExternalProject to build flatc from source to force it target the host. # Otherwise, flatc will target the project's toolchain (i.e. iOS, or Android). ExternalProject_Add( flatbuffers_ep PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatc_proj SOURCE_DIR ${PROJECT_SOURCE_DIR}/third-party/flatbuffers - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/flatc_proj/src/build CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON -DFLATBUFFERS_INSTALL=ON -DFLATBUFFERS_BUILD_FLATHASH=OFF From 8a4a0e32c5b93d77eac2069c2a1726fbc576f586 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 2 Sep 2025 21:41:51 -0700 Subject: [PATCH 085/134] Update [ghstack-poisoned] --- examples/apple/coreml/scripts/build_executor_runner.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/apple/coreml/scripts/build_executor_runner.sh b/examples/apple/coreml/scripts/build_executor_runner.sh index 00ee9821201..4da897bda96 100755 --- a/examples/apple/coreml/scripts/build_executor_runner.sh +++ b/examples/apple/coreml/scripts/build_executor_runner.sh @@ -93,7 +93,7 @@ find "$CMAKE_BUILD_DIR_PATH/" -name 'libcoreml_inmemoryfs.a' -exec cp -f "{}" "$ find "$CMAKE_BUILD_DIR_PATH/" -name 'libcoremldelegate.a' -exec cp -f "{}" "$LIBRARIES_DIR_PATH/libcoremldelegate.a" \; find "$CMAKE_BUILD_DIR_PATH/" -name 'libportable_ops_lib.a' -exec cp -f "{}" "$LIBRARIES_DIR_PATH/libportable_ops_lib.a" \; find "$CMAKE_BUILD_DIR_PATH/" -name 'libportable_kernels.a' -exec cp -f "{}" "$LIBRARIES_DIR_PATH/libportable_kernels.a" \; -cp -f "$CMAKE_BUILD_DIR_PATH/third-party/flatcc_external_project/lib/libflatccrt.a" "$LIBRARIES_DIR_PATH/libflatccrt.a" +cp -f "$CMAKE_BUILD_DIR_PATH/third-party/flatcc_ep/lib/libflatccrt.a" "$LIBRARIES_DIR_PATH/libflatccrt.a" # Build the runner echo "ExecuTorch: Building runner" From fbde97d733b87b30756f8a40cad6cbb98dc9f826 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 2 Sep 2025 22:05:58 -0700 Subject: [PATCH 086/134] Update [ghstack-poisoned] --- conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conftest.py b/conftest.py index 3bac9decc4e..6c9df86a1ce 100644 --- a/conftest.py +++ b/conftest.py @@ -1,6 +1,6 @@ import sys -collect_ignore_glob = [] +collect_ignore_glob: list[str] = [] # Skip Apple tests on Windows. Note that some Core ML tests can run on Linux, as the AOT flow # is available. Tests will manage this internally. However, the coremltools import is not available From d521e085ec994ac21177fd3d2c766fae954a2f1d Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Wed, 3 Sep 2025 12:53:12 -0700 Subject: [PATCH 087/134] Update [ghstack-poisoned] --- .github/workflows/_unittest.yml | 12 +++++++----- .github/workflows/trunk.yml | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index 69dc254cc17..a619b33dd2e 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -64,10 +64,12 @@ jobs: script: | conda init powershell - Set-PSDebug -Trace 1 - \$ErrorActionPreference = 'Stop' - \$PSNativeCommandUseErrorActionPreference = \$true + powershell -Command "& { + Set-PSDebug -Trace 1 + \$ErrorActionPreference = 'Stop' + \$PSNativeCommandUseErrorActionPreference = \$true - .ci/scripts/setup-windows.ps1 + .ci/scripts/setup-windows.ps1 - powershell .ci/scripts/unittest-windows.ps1 -editable "${{ inputs.editable }}" + powershell .ci/scripts/unittest-windows.ps1 -editable "${{ inputs.editable }}" + }" diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index 32aadf92285..8eecf950e61 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -994,10 +994,12 @@ jobs: script: | conda init powershell - Set-PSDebug -Trace 1 - \$ErrorActionPreference = 'Stop' - \$PSNativeCommandUseErrorActionPreference = \$true + powershell -Command "& { + Set-PSDebug -Trace 1 + \$ErrorActionPreference = 'Stop' + \$PSNativeCommandUseErrorActionPreference = \$true - .ci/scripts/setup-windows.ps1 + .ci/scripts/setup-windows.ps1 - powershell .ci/scripts/test_model.ps1 -modelName ${{ matrix.model }} -backend ${{ matrix.backend }} \ No newline at end of file + powershell .ci/scripts/test_model.ps1 -modelName ${{ matrix.model }} -backend ${{ matrix.backend }} + }" \ No newline at end of file From 95ab941f8f58019c1d988eb0abe0c5b975291e83 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 3 Sep 2025 15:05:44 -0700 Subject: [PATCH 088/134] Update [ghstack-poisoned] --- .github/workflows/build-wheels-windows.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index b3bb94e26e5..71934db3a19 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -43,8 +43,8 @@ jobs: matrix: include: - repository: pytorch/executorch - env-script: .ci/scripts/wheel/run_with_symlink_windows.sh pre-script: .ci/scripts/wheel/pre_build_script.sh + env-script: .ci/scripts/wheel/run_with_symlink_windows.sh post-script: .ci/scripts/wheel/post_build_script.sh smoke-test-script: .ci/scripts/wheel/test_windows.py package-name: executorch @@ -57,6 +57,7 @@ jobs: test-infra-ref: main build-matrix: ${{ needs.generate-matrix.outputs.matrix }} submodules: true + env-script: ${{ matrix.env-script }} pre-script: ${{ matrix.pre-script }} post-script: ${{ matrix.post-script }} package-name: ${{ matrix.package-name }} From 138188581f70e3befd3a9f83d42ed7ae2ab36049 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 3 Sep 2025 15:27:06 -0700 Subject: [PATCH 089/134] Update [ghstack-poisoned] --- .github/workflows/build-wheels-windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index 71934db3a19..c8066863fb5 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -44,7 +44,7 @@ jobs: include: - repository: pytorch/executorch pre-script: .ci/scripts/wheel/pre_build_script.sh - env-script: .ci/scripts/wheel/run_with_symlink_windows.sh + env-script: .ci\scripts\wheel\run_with_symlink_windows.sh post-script: .ci/scripts/wheel/post_build_script.sh smoke-test-script: .ci/scripts/wheel/test_windows.py package-name: executorch From ae5b6e3ec7a61ba264d9f44c8ccf75afddb32bec Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 4 Sep 2025 16:13:02 -0700 Subject: [PATCH 090/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/run_with_symlink_windows.sh | 21 --------- .ci/scripts/wheel/vc_env_helper.bat | 44 +++++++++++++++++++ .github/workflows/build-wheels-windows.yml | 33 +++++--------- 3 files changed, 55 insertions(+), 43 deletions(-) delete mode 100644 .ci/scripts/wheel/run_with_symlink_windows.sh create mode 100644 .ci/scripts/wheel/vc_env_helper.bat diff --git a/.ci/scripts/wheel/run_with_symlink_windows.sh b/.ci/scripts/wheel/run_with_symlink_windows.sh deleted file mode 100644 index a102317c736..00000000000 --- a/.ci/scripts/wheel/run_with_symlink_windows.sh +++ /dev/null @@ -1,21 +0,0 @@ -# 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. - -# This script runs the provided command from a symlinked version of the active -# working directory, in order to minimize path lengths and work around long -# path limitations on Windows. - -set -x - -PWSH_SCRIPT = "& { - \$symlinkDir = Join-Path -Path \$env:GITHUB_WORKSPACE -ChildPath \"et-build\" - New-Item -ItemType SymbolicLink -Path \$symlinkDir -Target $PWD - Write-Host \$symlinkDir -}" - -SYMLINK_DIR=`powershell -Command "$PWSH_SCRIPT"` -cd $SYMLINK_DIR -$1 ${@:2} diff --git a/.ci/scripts/wheel/vc_env_helper.bat b/.ci/scripts/wheel/vc_env_helper.bat new file mode 100644 index 00000000000..379c1a153a0 --- /dev/null +++ b/.ci/scripts/wheel/vc_env_helper.bat @@ -0,0 +1,44 @@ +REM This is based on 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 +) + +%args% || exit /b 1 diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index c8066863fb5..1a2c1123d8e 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -2,25 +2,21 @@ name: Build Windows Wheels on: pull_request: - paths: - - .ci/**/* - - .github/workflows/build-wheels-windows.yml - - examples/**/* - - pyproject.toml - - setup.py - tags: - - ciflow/binaries/* 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]+ - - ciflow/binaries/* + # 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 @@ -29,22 +25,16 @@ jobs: 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"]' - + with-xpu: enable build: needs: generate-matrix - permissions: - id-token: write - contents: read strategy: fail-fast: false matrix: include: - repository: pytorch/executorch pre-script: .ci/scripts/wheel/pre_build_script.sh - env-script: .ci\scripts\wheel\run_with_symlink_windows.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 @@ -56,9 +46,8 @@ jobs: test-infra-repository: pytorch/test-infra test-infra-ref: main build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - submodules: true - env-script: ${{ matrix.env-script }} 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 }} From 3128d72063298109591ffb15fc668ecc84c2f2a3 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 4 Sep 2025 16:24:12 -0700 Subject: [PATCH 091/134] Update [ghstack-poisoned] --- .github/workflows/build-wheels-windows.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index 1a2c1123d8e..2e00343a184 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -25,7 +25,10 @@ jobs: os: windows test-infra-repository: pytorch/test-infra test-infra-ref: main - with-xpu: enable + with-cuda: disabled + with-rocm: disabled + python-versions: '["3.10", "3.11", "3.12"] + build: needs: generate-matrix strategy: @@ -52,3 +55,4 @@ jobs: package-name: ${{ matrix.package-name }} smoke-test-script: ${{ matrix.smoke-test-script }} trigger-event: ${{ github.event_name }} + submodules: true From a74df905dbb5181cf94dfd2bb144af5ec935f3a3 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 4 Sep 2025 16:31:53 -0700 Subject: [PATCH 092/134] Update [ghstack-poisoned] --- .github/workflows/build-wheels-windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index 2e00343a184..01ef08e0ec9 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -27,7 +27,7 @@ jobs: test-infra-ref: main with-cuda: disabled with-rocm: disabled - python-versions: '["3.10", "3.11", "3.12"] + python-versions: '["3.10", "3.11", "3.12"]' build: needs: generate-matrix From 6efefde56ff846c8deeaca69731a67dc168d9a7c Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Thu, 4 Sep 2025 16:57:21 -0700 Subject: [PATCH 093/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/vc_env_helper.bat | 2 +- third-party/CMakeLists.txt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.ci/scripts/wheel/vc_env_helper.bat b/.ci/scripts/wheel/vc_env_helper.bat index 379c1a153a0..91bc105e708 100644 --- a/.ci/scripts/wheel/vc_env_helper.bat +++ b/.ci/scripts/wheel/vc_env_helper.bat @@ -1,4 +1,4 @@ -REM This is based on the torchvision Windows build logic. +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 diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 3c3ad668cfc..a8bcc34bdaf 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -34,7 +34,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 + 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 @@ -87,6 +88,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 From bfe75f225f213bc237829cb9cc9a3dfc403807e3 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 5 Sep 2025 14:41:04 -0700 Subject: [PATCH 094/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/vc_env_helper.bat | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.ci/scripts/wheel/vc_env_helper.bat b/.ci/scripts/wheel/vc_env_helper.bat index 91bc105e708..9f084aaf31e 100644 --- a/.ci/scripts/wheel/vc_env_helper.bat +++ b/.ci/scripts/wheel/vc_env_helper.bat @@ -41,4 +41,10 @@ if "%args%" == "" ( echo e.g. vc_env_helper.bat cl /c test.cpp ) +REM Setup a symlink to shorten the path length. +set work_dir=%CD% +cd %GITHUB_WORKSPACE% +mklink /d et-build %work_dir% +cd et-build + %args% || exit /b 1 From 1ad84b81e8bc2ffd1cf561cfcb2e5fd4b118a426 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 5 Sep 2025 15:02:28 -0700 Subject: [PATCH 095/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/vc_env_helper.bat | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.ci/scripts/wheel/vc_env_helper.bat b/.ci/scripts/wheel/vc_env_helper.bat index 9f084aaf31e..084ba4a9bda 100644 --- a/.ci/scripts/wheel/vc_env_helper.bat +++ b/.ci/scripts/wheel/vc_env_helper.bat @@ -42,9 +42,12 @@ if "%args%" == "" ( ) REM Setup a symlink to shorten the path length. +REM Note that the ET directory has to be named "executorch". set work_dir=%CD% cd %GITHUB_WORKSPACE% -mklink /d et-build %work_dir% -cd et-build +mkdir et +cd et +mklink /d executorch %work_dir% +cd executorch %args% || exit /b 1 From 2bdb390e79eafd1b369a65192b272325f0dcb76e Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 5 Sep 2025 16:31:08 -0700 Subject: [PATCH 096/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/vc_env_helper.bat | 4 +++- setup.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.ci/scripts/wheel/vc_env_helper.bat b/.ci/scripts/wheel/vc_env_helper.bat index 084ba4a9bda..c976769e302 100644 --- a/.ci/scripts/wheel/vc_env_helper.bat +++ b/.ci/scripts/wheel/vc_env_helper.bat @@ -50,4 +50,6 @@ cd et mklink /d executorch %work_dir% cd executorch -%args% || exit /b 1 +REM %args% || exit /b 1 +%args% +timeout 600 diff --git a/setup.py b/setup.py index a112802f2a6..d661597c85f 100644 --- a/setup.py +++ b/setup.py @@ -142,6 +142,9 @@ 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`.""" + + print(f"Writing version.py to {os.getcwd()}", file=sys.stderr) + lines = [ "from typing import Optional", '__all__ = ["__version__", "git_version"]', From 8c9322c4c8c869a28d31fab8fed65119bf35b2ed Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Fri, 5 Sep 2025 16:47:05 -0700 Subject: [PATCH 097/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/vc_env_helper.bat | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.ci/scripts/wheel/vc_env_helper.bat b/.ci/scripts/wheel/vc_env_helper.bat index c976769e302..084ba4a9bda 100644 --- a/.ci/scripts/wheel/vc_env_helper.bat +++ b/.ci/scripts/wheel/vc_env_helper.bat @@ -50,6 +50,4 @@ cd et mklink /d executorch %work_dir% cd executorch -REM %args% || exit /b 1 -%args% -timeout 600 +%args% || exit /b 1 From c88e350881c045017dfb1cc3976f5b0eb25ae04e Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Fri, 5 Sep 2025 17:45:11 -0700 Subject: [PATCH 098/134] Update [ghstack-poisoned] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d661597c85f..fc36fee7958 100644 --- a/setup.py +++ b/setup.py @@ -143,7 +143,7 @@ def string(cls) -> str: def write_to_python_file(cls, path: str) -> None: """Creates a file similar to PyTorch core's `torch/version.py`.""" - print(f"Writing version.py to {os.getcwd()}", file=sys.stderr) + print(f"Writing version.py to {path}", file=sys.stderr) lines = [ "from typing import Optional", From be158fdc419d3610cbd39eb96aaae74c7ad36047 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Fri, 5 Sep 2025 18:53:59 -0700 Subject: [PATCH 099/134] Update [ghstack-poisoned] --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index fc36fee7958..5011ed112eb 100644 --- a/setup.py +++ b/setup.py @@ -154,6 +154,9 @@ def write_to_python_file(cls, path: str) -> None: ] with open(path, "w") as fp: fp.write("\n".join(lines) + "\n") + + file_dir = os.path.dirname() + print(f"Files: {list(os.listdir(file_dir))}", file.stderr) # The build type is determined by the DEBUG environment variable. If DEBUG is From 053b8defcf8a023699e4306010e6ed3f743f735c Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Fri, 5 Sep 2025 19:32:45 -0700 Subject: [PATCH 100/134] Update [ghstack-poisoned] --- setup.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5011ed112eb..f8b450be5fe 100644 --- a/setup.py +++ b/setup.py @@ -145,6 +145,12 @@ def write_to_python_file(cls, path: str) -> None: print(f"Writing version.py to {path}", file=sys.stderr) + path1 = os.path.dirname(path) + path2 = os.path.dirname(path1) + + print(f"Files at {path2}: {list(os.listdir(path2))}") + print(f"Files at {path1}: {list(os.listdir(path1))}") + lines = [ "from typing import Optional", '__all__ = ["__version__", "git_version"]', @@ -155,7 +161,7 @@ def write_to_python_file(cls, path: str) -> None: with open(path, "w") as fp: fp.write("\n".join(lines) + "\n") - file_dir = os.path.dirname() + file_dir = os.path.dirname(path) print(f"Files: {list(os.listdir(file_dir))}", file.stderr) From e8531a4ef2428e0e758953681bddb2c7b14e3913 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Fri, 5 Sep 2025 20:57:56 -0700 Subject: [PATCH 101/134] Update [ghstack-poisoned] --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index f8b450be5fe..d7ef096f345 100644 --- a/setup.py +++ b/setup.py @@ -148,8 +148,8 @@ def write_to_python_file(cls, path: str) -> None: path1 = os.path.dirname(path) path2 = os.path.dirname(path1) - print(f"Files at {path2}: {list(os.listdir(path2))}") - print(f"Files at {path1}: {list(os.listdir(path1))}") + print(f"Files at {path2}: {list(os.listdir(path2))}", file=sys.stderr) + print(f"Files at {path1}: {list(os.listdir(path1))}", file=sys.stderr) lines = [ "from typing import Optional", @@ -162,7 +162,7 @@ def write_to_python_file(cls, path: str) -> None: fp.write("\n".join(lines) + "\n") file_dir = os.path.dirname(path) - print(f"Files: {list(os.listdir(file_dir))}", file.stderr) + print(f"Files: {list(os.listdir(file_dir))}", file=sys.stderr) # The build type is determined by the DEBUG environment variable. If DEBUG is From 04c7a05e23a6f1ef2fd22f4a821283d1a30d26d8 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Fri, 5 Sep 2025 21:33:59 -0700 Subject: [PATCH 102/134] Update [ghstack-poisoned] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d7ef096f345..dce572e882f 100644 --- a/setup.py +++ b/setup.py @@ -143,7 +143,7 @@ def string(cls) -> str: def write_to_python_file(cls, path: str) -> None: """Creates a file similar to PyTorch core's `torch/version.py`.""" - print(f"Writing version.py to {path}", file=sys.stderr) + print(f"Writing version.py to {path}, cwd: {os.getcwd()}", file=sys.stderr) path1 = os.path.dirname(path) path2 = os.path.dirname(path1) From 87bfc3d93f7dec5198465323c741804aac04ee5b Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 6 Sep 2025 12:55:44 -0700 Subject: [PATCH 103/134] Update [ghstack-poisoned] --- setup.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index dce572e882f..33023227978 100644 --- a/setup.py +++ b/setup.py @@ -144,12 +144,16 @@ def write_to_python_file(cls, path: str) -> None: """Creates a file similar to PyTorch core's `torch/version.py`.""" print(f"Writing version.py to {path}, cwd: {os.getcwd()}", file=sys.stderr) + print(f"WD files: {list(os.listdir(os.getcwd()))}") - path1 = os.path.dirname(path) - path2 = os.path.dirname(path1) + try: + path1 = os.path.dirname(path) + path2 = os.path.dirname(path1) - print(f"Files at {path2}: {list(os.listdir(path2))}", file=sys.stderr) - print(f"Files at {path1}: {list(os.listdir(path1))}", file=sys.stderr) + print(f"Files at {path2}: {list(os.listdir(path2))}", file=sys.stderr) + print(f"Files at {path1}: {list(os.listdir(path1))}", file=sys.stderr) + finally: + pass lines = [ "from typing import Optional", From 68a3cdd86c610b56023512efc50767bd41926d7d Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 6 Sep 2025 15:51:04 -0700 Subject: [PATCH 104/134] Update [ghstack-poisoned] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 33023227978..8e8ef1b0cd3 100644 --- a/setup.py +++ b/setup.py @@ -144,7 +144,7 @@ def write_to_python_file(cls, path: str) -> None: """Creates a file similar to PyTorch core's `torch/version.py`.""" print(f"Writing version.py to {path}, cwd: {os.getcwd()}", file=sys.stderr) - print(f"WD files: {list(os.listdir(os.getcwd()))}") + print(f"WD files: {list(os.listdir(os.getcwd()))}", file=sys.stderr) try: path1 = os.path.dirname(path) From 7ddbc04c610286060c249eb22569f6ec9b796b57 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 6 Sep 2025 16:29:18 -0700 Subject: [PATCH 105/134] Update [ghstack-poisoned] --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 8e8ef1b0cd3..fd0a1220262 100644 --- a/setup.py +++ b/setup.py @@ -145,6 +145,7 @@ def write_to_python_file(cls, path: str) -> None: print(f"Writing version.py to {path}, cwd: {os.getcwd()}", file=sys.stderr) print(f"WD files: {list(os.listdir(os.getcwd()))}", file=sys.stderr) + print(f"Pip out: {list(os.listdir(os.getcwd() + "/pip-out"))}", file=sys.stderr) try: path1 = os.path.dirname(path) From 82f54e4e2f976486d215a3b8906ac00fa3b5bdf9 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 6 Sep 2025 18:33:46 -0700 Subject: [PATCH 106/134] Update [ghstack-poisoned] --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fd0a1220262..c62a06cf819 100644 --- a/setup.py +++ b/setup.py @@ -147,6 +147,8 @@ def write_to_python_file(cls, path: str) -> None: print(f"WD files: {list(os.listdir(os.getcwd()))}", file=sys.stderr) print(f"Pip out: {list(os.listdir(os.getcwd() + "/pip-out"))}", file=sys.stderr) + os.makedirs(os.path.dirname(path), exist_ok=True) + try: path1 = os.path.dirname(path) path2 = os.path.dirname(path1) @@ -155,7 +157,7 @@ def write_to_python_file(cls, path: str) -> None: print(f"Files at {path1}: {list(os.listdir(path1))}", file=sys.stderr) finally: pass - + lines = [ "from typing import Optional", '__all__ = ["__version__", "git_version"]', From 074dcf06013177a3f101ed6b7cd828e214cd085c Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 6 Sep 2025 19:36:06 -0700 Subject: [PATCH 107/134] Update [ghstack-poisoned] --- third-party/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index a8bcc34bdaf..c5e2596330b 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -34,8 +34,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_ep - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/flatc_ep/src/build + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatc_proj + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/flatc_proj/src/build SOURCE_DIR ${PROJECT_SOURCE_DIR}/third-party/flatbuffers CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON -DFLATBUFFERS_INSTALL=ON From d78f7954ec6db2421b421f6d227b893b1a3f5ca9 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sat, 6 Sep 2025 20:02:30 -0700 Subject: [PATCH 108/134] Update [ghstack-poisoned] --- setup.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/setup.py b/setup.py index c62a06cf819..cb2cd5a7a74 100644 --- a/setup.py +++ b/setup.py @@ -144,8 +144,6 @@ def write_to_python_file(cls, path: str) -> None: """Creates a file similar to PyTorch core's `torch/version.py`.""" print(f"Writing version.py to {path}, cwd: {os.getcwd()}", file=sys.stderr) - print(f"WD files: {list(os.listdir(os.getcwd()))}", file=sys.stderr) - print(f"Pip out: {list(os.listdir(os.getcwd() + "/pip-out"))}", file=sys.stderr) os.makedirs(os.path.dirname(path), exist_ok=True) From 2220f86e66dc2d62b1836e5e08326cecf2b321a7 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sun, 7 Sep 2025 12:05:24 -0700 Subject: [PATCH 109/134] Update [ghstack-poisoned] --- setup.py | 2 +- third-party/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index cb2cd5a7a74..c2017329576 100644 --- a/setup.py +++ b/setup.py @@ -790,7 +790,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, diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index c5e2596330b..a8bcc34bdaf 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -34,8 +34,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 - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/flatc_proj/src/build + 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 From 2692f944f482d9f83b60a21584fa419c54503f42 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sun, 7 Sep 2025 12:46:42 -0700 Subject: [PATCH 110/134] Update [ghstack-poisoned] --- .github/workflows/build-wheels-windows.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index 01ef08e0ec9..be01da1283c 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -36,10 +36,10 @@ jobs: 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 + 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 From ed00d711ab6f6ed28bb597e72be05093c62f84f5 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sun, 7 Sep 2025 13:30:21 -0700 Subject: [PATCH 111/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/vc_env_helper.bat | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.ci/scripts/wheel/vc_env_helper.bat b/.ci/scripts/wheel/vc_env_helper.bat index 084ba4a9bda..c072ae3d03d 100644 --- a/.ci/scripts/wheel/vc_env_helper.bat +++ b/.ci/scripts/wheel/vc_env_helper.bat @@ -45,9 +45,13 @@ REM Setup a symlink to shorten the path length. REM Note that the ET directory has to be named "executorch". set work_dir=%CD% cd %GITHUB_WORKSPACE% -mkdir et +if not exist et ( + mkdir et +) cd et -mklink /d executorch %work_dir% +if not exist executorch ( + mklink /d executorch %work_dir% +) cd executorch %args% || exit /b 1 From 661f4a78f50763327c7275029830407cc6c91f4d Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sun, 7 Sep 2025 23:41:45 -0700 Subject: [PATCH 112/134] Update [ghstack-poisoned] --- .github/workflows/build-wheels-windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index be01da1283c..184ab8352f1 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -39,7 +39,7 @@ jobs: 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 + 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 From 46cf0e6ffea8ffa77f77cfb7c2dcbcd52cebadca Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Mon, 8 Sep 2025 00:21:57 -0700 Subject: [PATCH 113/134] Update [ghstack-poisoned] --- .github/workflows/build-wheels-windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index 184ab8352f1..279f29cb31a 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -39,7 +39,7 @@ jobs: 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 + 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 From 44df1d6d0e1d5dd37874288f9800a8869a0c689c Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Mon, 8 Sep 2025 01:01:32 -0700 Subject: [PATCH 114/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/vc_env_helper.bat | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/.ci/scripts/wheel/vc_env_helper.bat b/.ci/scripts/wheel/vc_env_helper.bat index c072ae3d03d..317f2f582e6 100644 --- a/.ci/scripts/wheel/vc_env_helper.bat +++ b/.ci/scripts/wheel/vc_env_helper.bat @@ -41,17 +41,22 @@ if "%args%" == "" ( echo e.g. vc_env_helper.bat cl /c test.cpp ) -REM Setup a symlink to shorten the path length. -REM Note that the ET directory has to be named "executorch". -set work_dir=%CD% -cd %GITHUB_WORKSPACE% -if not exist et ( - mkdir et -) -cd et -if not exist executorch ( - mklink /d executorch %work_dir% +echo "Evaluating symlink status. CWD: %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". + set work_dir=%CD% + cd %GITHUB_WORKSPACE% + if not exist et ( + mkdir et + ) + cd et + if not exist executorch ( + mklink /d executorch %work_dir% + ) + cd executorch ) -cd executorch +echo "Post symlink CWD: %CD%" %args% || exit /b 1 From 82fc79294e53912df61daa198e8abf1860b227e7 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Mon, 8 Sep 2025 13:47:32 -0700 Subject: [PATCH 115/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/vc_env_helper.bat | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.ci/scripts/wheel/vc_env_helper.bat b/.ci/scripts/wheel/vc_env_helper.bat index 317f2f582e6..d24fe399248 100644 --- a/.ci/scripts/wheel/vc_env_helper.bat +++ b/.ci/scripts/wheel/vc_env_helper.bat @@ -42,6 +42,7 @@ if "%args%" == "" ( ) echo "Evaluating symlink status. CWD: %CD%" +echo ON if exist setup.py ( echo "Creating symlink..." REM Setup a symlink to shorten the path length. @@ -58,5 +59,6 @@ if exist setup.py ( cd executorch ) echo "Post symlink CWD: %CD%" +echo OFF %args% || exit /b 1 From 023baef9102d6f5ec549ff6860da9e0e57d4bb1e Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Mon, 8 Sep 2025 14:18:30 -0700 Subject: [PATCH 116/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/vc_env_helper.bat | 8 +++----- setup.py | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.ci/scripts/wheel/vc_env_helper.bat b/.ci/scripts/wheel/vc_env_helper.bat index d24fe399248..5fe50df95ba 100644 --- a/.ci/scripts/wheel/vc_env_helper.bat +++ b/.ci/scripts/wheel/vc_env_helper.bat @@ -42,23 +42,21 @@ if "%args%" == "" ( ) echo "Evaluating symlink status. CWD: %CD%" -echo ON +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". - set work_dir=%CD% cd %GITHUB_WORKSPACE% - if not exist et ( + if not exist et\ ( mkdir et ) cd et - if not exist executorch ( + if not exist executorch\ ( mklink /d executorch %work_dir% ) cd executorch ) echo "Post symlink CWD: %CD%" -echo OFF %args% || exit /b 1 diff --git a/setup.py b/setup.py index c2017329576..49cdf18f96c 100644 --- a/setup.py +++ b/setup.py @@ -155,7 +155,7 @@ def write_to_python_file(cls, path: str) -> None: print(f"Files at {path1}: {list(os.listdir(path1))}", file=sys.stderr) finally: pass - + lines = [ "from typing import Optional", '__all__ = ["__version__", "git_version"]', @@ -165,7 +165,7 @@ def write_to_python_file(cls, path: str) -> None: ] with open(path, "w") as fp: fp.write("\n".join(lines) + "\n") - + file_dir = os.path.dirname(path) print(f"Files: {list(os.listdir(file_dir))}", file=sys.stderr) From 43db3a916398dcc6ab5c55e0acd124531cebbd0a Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Mon, 8 Sep 2025 14:19:51 -0700 Subject: [PATCH 117/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/vc_env_helper.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/wheel/vc_env_helper.bat b/.ci/scripts/wheel/vc_env_helper.bat index 5fe50df95ba..a1341b8127e 100644 --- a/.ci/scripts/wheel/vc_env_helper.bat +++ b/.ci/scripts/wheel/vc_env_helper.bat @@ -53,7 +53,7 @@ if exist setup.py ( ) cd et if not exist executorch\ ( - mklink /d executorch %work_dir% + mklink /d executorch !work_dir! ) cd executorch ) From 7abfa44d2d3c79d441b3eb1ecdc798244582e58e Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Mon, 8 Sep 2025 14:40:55 -0700 Subject: [PATCH 118/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/vc_env_helper.bat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.ci/scripts/wheel/vc_env_helper.bat b/.ci/scripts/wheel/vc_env_helper.bat index a1341b8127e..abd8ec8ce85 100644 --- a/.ci/scripts/wheel/vc_env_helper.bat +++ b/.ci/scripts/wheel/vc_env_helper.bat @@ -52,8 +52,9 @@ if exist setup.py ( mkdir et ) cd et + echo Work dir: %work_dir% if not exist executorch\ ( - mklink /d executorch !work_dir! + mklink /d executorch %work_dir% ) cd executorch ) From 0c7c5d358b2b8a1450d025f5dbc68c408b4e8336 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Mon, 8 Sep 2025 15:22:42 -0700 Subject: [PATCH 119/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/test_windows.py | 32 ++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.ci/scripts/wheel/test_windows.py b/.ci/scripts/wheel/test_windows.py index f02772a3476..c9f45a447aa 100644 --- a/.ci/scripts/wheel/test_windows.py +++ b/.ci/scripts/wheel/test_windows.py @@ -5,13 +5,43 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. +import os +import subprocess import test_base from examples.models import Backend, Model +from test_base import ModelTest +from typing import List + +def map_backend_name(name: str) -> str: + # Map the backend name to the string used by the Windows test jobs, which use + # a slightly different convention. This is an artifact of us being mid-update + # of the model test logic. + # TODO(gjcomer) Clean this up when we update the model test CI. + + if name == "xnnpack-quantization-delegation": + return "xnnpack-q8" + else: + return name + +def run_tests(model_tests: List[ModelTest]) -> None: + for model_test in model_tests: + subprocess.run( + [ + os.path.join(test_base._repository_root_dir(), ".ci/scripts/test_model.ps1"), + "-ModelName", + str(model_test.model), + "-Backend", + map_backend_name(str(model_test.backend)), + ], + check=True, + cwd=test_base._repository_root_dir(), + ) + if __name__ == "__main__": test_base.run_tests( model_tests=[ - test_base.ModelTest( + ModelTest( model=Model.Mv3, backend=Backend.XnnpackQuantizationDelegation, ), From f5319f0fb3456e8c7305d1eeb13866399a115d3c Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Mon, 8 Sep 2025 15:55:12 -0700 Subject: [PATCH 120/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/test_windows.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/wheel/test_windows.py b/.ci/scripts/wheel/test_windows.py index c9f45a447aa..f8cbbe93f5f 100644 --- a/.ci/scripts/wheel/test_windows.py +++ b/.ci/scripts/wheel/test_windows.py @@ -39,7 +39,7 @@ def run_tests(model_tests: List[ModelTest]) -> None: if __name__ == "__main__": - test_base.run_tests( + run_tests( model_tests=[ ModelTest( model=Model.Mv3, From 66bdcfe76509df01e6e0947b8167fabc8d864a0e Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Mon, 8 Sep 2025 17:14:52 -0700 Subject: [PATCH 121/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/test_windows.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.ci/scripts/wheel/test_windows.py b/.ci/scripts/wheel/test_windows.py index f8cbbe93f5f..477ee48c2eb 100644 --- a/.ci/scripts/wheel/test_windows.py +++ b/.ci/scripts/wheel/test_windows.py @@ -27,6 +27,7 @@ def run_tests(model_tests: List[ModelTest]) -> None: for model_test in model_tests: subprocess.run( [ + "powershell.exe", os.path.join(test_base._repository_root_dir(), ".ci/scripts/test_model.ps1"), "-ModelName", str(model_test.model), From 036f302f21e562898fe772ab245bf473d9279c28 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Mon, 8 Sep 2025 17:42:12 -0700 Subject: [PATCH 122/134] Update [ghstack-poisoned] --- .ci/scripts/test_model.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/test_model.ps1 b/.ci/scripts/test_model.ps1 index 2ff2e7c890d..19d70c591ac 100644 --- a/.ci/scripts/test_model.ps1 +++ b/.ci/scripts/test_model.ps1 @@ -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 { From 94760b4b14e700af1b0dae323b2965d4f7f2a0ba Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Mon, 8 Sep 2025 18:59:39 -0700 Subject: [PATCH 123/134] Update [ghstack-poisoned] --- .github/workflows/build-wheels-windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index 279f29cb31a..bc9e975f31a 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -38,7 +38,7 @@ jobs: - 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 + post-script: .ci\\scripts\\wheel\\post_build_script_windows.sh smoke-test-script: .ci/scripts/wheel/test_windows.py package-name: executorch name: ${{ matrix.repository }} From efa5b136866537abc18eb5aca9dab3d20365ff14 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Mon, 8 Sep 2025 20:51:12 -0700 Subject: [PATCH 124/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/post_build_script_windows.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .ci/scripts/wheel/post_build_script_windows.sh diff --git a/.ci/scripts/wheel/post_build_script_windows.sh b/.ci/scripts/wheel/post_build_script_windows.sh new file mode 100644 index 00000000000..9899b038357 --- /dev/null +++ b/.ci/scripts/wheel/post_build_script_windows.sh @@ -0,0 +1,4 @@ +source post_build_script.sh + +# Install build requirements needed for the smoke test. +pip install cmake \ No newline at end of file From eb3715c3f41da5a009a2154b5a7fac292bf806cb Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Mon, 8 Sep 2025 22:20:33 -0700 Subject: [PATCH 125/134] Update [ghstack-poisoned] --- .../wheel/post_build_script_windows.sh | 4 - .ci/scripts/wheel/test_windows.py | 79 ++++++++++++------- .github/workflows/build-wheels-windows.yml | 2 +- examples/models/__init__.py | 1 + 4 files changed, 54 insertions(+), 32 deletions(-) delete mode 100644 .ci/scripts/wheel/post_build_script_windows.sh diff --git a/.ci/scripts/wheel/post_build_script_windows.sh b/.ci/scripts/wheel/post_build_script_windows.sh deleted file mode 100644 index 9899b038357..00000000000 --- a/.ci/scripts/wheel/post_build_script_windows.sh +++ /dev/null @@ -1,4 +0,0 @@ -source post_build_script.sh - -# Install build requirements needed for the smoke test. -pip install cmake \ No newline at end of file diff --git a/.ci/scripts/wheel/test_windows.py b/.ci/scripts/wheel/test_windows.py index 477ee48c2eb..a99f93cdeca 100644 --- a/.ci/scripts/wheel/test_windows.py +++ b/.ci/scripts/wheel/test_windows.py @@ -5,38 +5,63 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -import os -import subprocess -import test_base -from examples.models import Backend, Model -from test_base import ModelTest from typing import List -def map_backend_name(name: str) -> str: - # Map the backend name to the string used by the Windows test jobs, which use - # a slightly different convention. This is an artifact of us being mid-update - # of the model test logic. - # TODO(gjcomer) Clean this up when we update the model test CI. +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)): + assert torch.allclose(ref_outputs[i], et_outputs[i], atol=1e-5) - if name == "xnnpack-quantization-delegation": - return "xnnpack-q8" - else: - return name def run_tests(model_tests: List[ModelTest]) -> None: for model_test in model_tests: - subprocess.run( - [ - "powershell.exe", - os.path.join(test_base._repository_root_dir(), ".ci/scripts/test_model.ps1"), - "-ModelName", - str(model_test.model), - "-Backend", - map_backend_name(str(model_test.backend)), - ], - check=True, - cwd=test_base._repository_root_dir(), - ) + 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__": @@ -44,7 +69,7 @@ def run_tests(model_tests: List[ModelTest]) -> None: model_tests=[ ModelTest( model=Model.Mv3, - backend=Backend.XnnpackQuantizationDelegation, + backend=Backend.Xnnpack, ), ] ) diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index bc9e975f31a..279f29cb31a 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -38,7 +38,7 @@ jobs: - 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_windows.sh + post-script: .ci\\scripts\\wheel\\post_build_script.sh smoke-test-script: .ci/scripts/wheel/test_windows.py package-name: executorch name: ${{ matrix.repository }} diff --git a/examples/models/__init__.py b/examples/models/__init__.py index 82680a05c9d..74ac16996c2 100644 --- a/examples/models/__init__.py +++ b/examples/models/__init__.py @@ -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 From 73265447c02cbc2964637ab29b1e83919830570e Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 9 Sep 2025 10:30:29 -0700 Subject: [PATCH 126/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/test_windows.py | 125 +++++++++++++++++------------- 1 file changed, 69 insertions(+), 56 deletions(-) diff --git a/.ci/scripts/wheel/test_windows.py b/.ci/scripts/wheel/test_windows.py index a99f93cdeca..fcd3d8fd9b8 100644 --- a/.ci/scripts/wheel/test_windows.py +++ b/.ci/scripts/wheel/test_windows.py @@ -5,71 +5,84 @@ # 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)] +try: + from typing import List + + print("Dumping env: ", file=sys.stderr) + import os + for name, value in os.environ.items(): + print(f" {name}: {value}") + + import sys + print("Trying to import ET...", file=sys.stderr) + import executorch + print(f"ET path: {executorch.__path__}", file=sys.stderr) + + 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 - 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 + def test_model_xnnpack(model: Model, quantize: bool) -> None: + model_instance, example_inputs, _, _ = EagerModelFactory.create_model( + *MODEL_NAME_TO_MODEL[str(model)] ) - lowered = to_edge_transform_and_lower( - torch.export.export(model_instance, example_inputs), - partitioner=[XnnpackPartitioner()], - compile_config=EdgeCompileConfig( - _check_ir_validity=False, - ), - ).to_executorch() + 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 + ) - loaded_model = _load_for_executorch_from_buffer(lowered.buffer) - et_outputs = loaded_model([*example_inputs]) + lowered = to_edge_transform_and_lower( + torch.export.export(model_instance, example_inputs), + partitioner=[XnnpackPartitioner()], + compile_config=EdgeCompileConfig( + _check_ir_validity=False, + ), + ).to_executorch() - if isinstance(ref_outputs, torch.Tensor): - ref_outputs = (ref_outputs,) + loaded_model = _load_for_executorch_from_buffer(lowered.buffer) + et_outputs = loaded_model([*example_inputs]) - assert len(ref_outputs) == len(et_outputs) - for i in range(len(ref_outputs)): - assert torch.allclose(ref_outputs[i], et_outputs[i], atol=1e-5) + if isinstance(ref_outputs, torch.Tensor): + ref_outputs = (ref_outputs,) + assert len(ref_outputs) == len(et_outputs) + for i in range(len(ref_outputs)): + assert torch.allclose(ref_outputs[i], et_outputs[i], atol=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}.") + 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, - ), - ] - ) + + if __name__ == "__main__": + run_tests( + model_tests=[ + ModelTest( + model=Model.Mv3, + backend=Backend.Xnnpack, + ), + ] + ) +except: + pass \ No newline at end of file From 205413db87e8542bfdda17ea1666ede2a1b0492a Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 9 Sep 2025 16:15:17 -0700 Subject: [PATCH 127/134] Update [ghstack-poisoned] --- .github/workflows/build-wheels-windows.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index 279f29cb31a..276edfb08d1 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -55,4 +55,5 @@ jobs: package-name: ${{ matrix.package-name }} smoke-test-script: ${{ matrix.smoke-test-script }} trigger-event: ${{ github.event_name }} + wheel-build-params: "--verbose" submodules: true From 1bb4994478a608cb5410ac3fcbef868e52ffc4c0 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 9 Sep 2025 17:09:15 -0700 Subject: [PATCH 128/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/pre_build_script.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.ci/scripts/wheel/pre_build_script.sh b/.ci/scripts/wheel/pre_build_script.sh index b9e93ef3701..58f60b30476 100755 --- a/.ci/scripts/wheel/pre_build_script.sh +++ b/.ci/scripts/wheel/pre_build_script.sh @@ -17,6 +17,15 @@ 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"* ]]; do + 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 From 18f0fe3d14934261292cc29af34644803e4df3bf Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 9 Sep 2025 17:17:59 -0700 Subject: [PATCH 129/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/pre_build_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/wheel/pre_build_script.sh b/.ci/scripts/wheel/pre_build_script.sh index 58f60b30476..54283bd9c0a 100755 --- a/.ci/scripts/wheel/pre_build_script.sh +++ b/.ci/scripts/wheel/pre_build_script.sh @@ -20,7 +20,7 @@ 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"* ]]; do +if [[ $UNAME_S == *"MINGW"* || $UNAME_S == *"MSYS"* ]]; then echo "Enabling symlinks on Windows" git config core.symlinks true git checkout -f HEAD From 377dad42db0505b660c39899ceebfe43859f687c Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 9 Sep 2025 18:58:20 -0700 Subject: [PATCH 130/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/test_windows.py | 128 ++++++++++++++---------------- 1 file changed, 59 insertions(+), 69 deletions(-) diff --git a/.ci/scripts/wheel/test_windows.py b/.ci/scripts/wheel/test_windows.py index fcd3d8fd9b8..12203cfbf32 100644 --- a/.ci/scripts/wheel/test_windows.py +++ b/.ci/scripts/wheel/test_windows.py @@ -5,84 +5,74 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -try: - from typing import List - - print("Dumping env: ", file=sys.stderr) - import os - for name, value in os.environ.items(): - print(f" {name}: {value}") - - import sys - print("Trying to import ET...", file=sys.stderr) - import executorch - print(f"ET path: {executorch.__path__}", file=sys.stderr) - - 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 typing import List + +import sys +import executorch + +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)] ) - from test_base import ModelTest + model_instance.eval() + ref_outputs = model_instance(*example_inputs) - def test_model_xnnpack(model: Model, quantize: bool) -> None: - model_instance, example_inputs, _, _ = EagerModelFactory.create_model( - *MODEL_NAME_TO_MODEL[str(model)] + 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 ) - 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() + 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]) + 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,) + if isinstance(ref_outputs, torch.Tensor): + ref_outputs = (ref_outputs,) - assert len(ref_outputs) == len(et_outputs) - for i in range(len(ref_outputs)): - assert torch.allclose(ref_outputs[i], et_outputs[i], atol=1e-5) + assert len(ref_outputs) == len(et_outputs) + for i in range(len(ref_outputs)): + assert torch.allclose(ref_outputs[i], et_outputs[i], atol=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}.") +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, - ), - ] - ) -except: - pass \ No newline at end of file +if __name__ == "__main__": + run_tests( + model_tests=[ + ModelTest( + model=Model.Mv3, + backend=Backend.Xnnpack, + ), + ] + ) \ No newline at end of file From 5e177d43ff7e63f358f7f2633e290032aa21a9a5 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 9 Sep 2025 19:30:35 -0700 Subject: [PATCH 131/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/test_windows.py | 2 +- .ci/scripts/wheel/vc_env_helper.bat | 2 -- examples/models/__init__.py | 2 +- setup.py | 14 -------------- third-party/CMakeLists.txt | 5 ----- 5 files changed, 2 insertions(+), 23 deletions(-) diff --git a/.ci/scripts/wheel/test_windows.py b/.ci/scripts/wheel/test_windows.py index 12203cfbf32..2e94d281475 100644 --- a/.ci/scripts/wheel/test_windows.py +++ b/.ci/scripts/wheel/test_windows.py @@ -56,7 +56,7 @@ def test_model_xnnpack(model: Model, quantize: bool) -> None: assert len(ref_outputs) == len(et_outputs) for i in range(len(ref_outputs)): - assert torch.allclose(ref_outputs[i], et_outputs[i], atol=1e-5) + assert torch.allclose(ref_outputs[i], et_outputs[i], atol=1e-4) def run_tests(model_tests: List[ModelTest]) -> None: diff --git a/.ci/scripts/wheel/vc_env_helper.bat b/.ci/scripts/wheel/vc_env_helper.bat index abd8ec8ce85..d7fa2c1a596 100644 --- a/.ci/scripts/wheel/vc_env_helper.bat +++ b/.ci/scripts/wheel/vc_env_helper.bat @@ -41,7 +41,6 @@ if "%args%" == "" ( echo e.g. vc_env_helper.bat cl /c test.cpp ) -echo "Evaluating symlink status. CWD: %CD%" set work_dir=%CD% if exist setup.py ( echo "Creating symlink..." @@ -58,6 +57,5 @@ if exist setup.py ( ) cd executorch ) -echo "Post symlink CWD: %CD%" %args% || exit /b 1 diff --git a/examples/models/__init__.py b/examples/models/__init__.py index 74ac16996c2..d100a69380f 100644 --- a/examples/models/__init__.py +++ b/examples/models/__init__.py @@ -44,7 +44,7 @@ def __str__(self) -> str: class Backend(str, Enum): - Xnnpack = ("xnnpack",) + Xnnpack = "xnnpack" XnnpackQuantizationDelegation = "xnnpack-quantization-delegation" CoreMlExportOnly = "coreml" CoreMlExportAndTest = "coreml-test" # AOT export + test with runner diff --git a/setup.py b/setup.py index 49cdf18f96c..f7d3cdefc77 100644 --- a/setup.py +++ b/setup.py @@ -143,19 +143,8 @@ def string(cls) -> str: def write_to_python_file(cls, path: str) -> None: """Creates a file similar to PyTorch core's `torch/version.py`.""" - print(f"Writing version.py to {path}, cwd: {os.getcwd()}", file=sys.stderr) - os.makedirs(os.path.dirname(path), exist_ok=True) - try: - path1 = os.path.dirname(path) - path2 = os.path.dirname(path1) - - print(f"Files at {path2}: {list(os.listdir(path2))}", file=sys.stderr) - print(f"Files at {path1}: {list(os.listdir(path1))}", file=sys.stderr) - finally: - pass - lines = [ "from typing import Optional", '__all__ = ["__version__", "git_version"]', @@ -166,9 +155,6 @@ def write_to_python_file(cls, path: str) -> None: with open(path, "w") as fp: fp.write("\n".join(lines) + "\n") - file_dir = os.path.dirname(path) - print(f"Files: {list(os.listdir(file_dir))}", file=sys.stderr) - # The build type is determined by the DEBUG environment variable. If DEBUG is # set to a non-empty value, the build type is Debug. Otherwise, the build type diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index a8bcc34bdaf..767ac367e19 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -25,11 +25,6 @@ else() set(_executorch_external_project_additional_args CMAKE_GENERATOR "Unix Makefiles") endif() -# DEBUG -if(WIN32) - set_directory_properties(PROPERTIES EP_BASE "C:\\actions-runner\\_work\\") -endif() - # We use ExternalProject to build flatc from source to force it target the host. # Otherwise, flatc will target the project's toolchain (i.e. iOS, or Android). ExternalProject_Add( From 56f6ea66dabcbfc7889558a73f670a867047553d Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 9 Sep 2025 20:34:41 -0700 Subject: [PATCH 132/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/test_windows.py | 3 --- setup.py | 2 -- 2 files changed, 5 deletions(-) diff --git a/.ci/scripts/wheel/test_windows.py b/.ci/scripts/wheel/test_windows.py index c6ce9351cc1..a71a1aed92e 100644 --- a/.ci/scripts/wheel/test_windows.py +++ b/.ci/scripts/wheel/test_windows.py @@ -5,11 +5,8 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -import sys from typing import List -import executorch - import torch from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner from executorch.examples.models import Backend, Model, MODEL_NAME_TO_MODEL diff --git a/setup.py b/setup.py index f7d3cdefc77..514d1af7726 100644 --- a/setup.py +++ b/setup.py @@ -143,8 +143,6 @@ def string(cls) -> str: def write_to_python_file(cls, path: str) -> None: """Creates a file similar to PyTorch core's `torch/version.py`.""" - os.makedirs(os.path.dirname(path), exist_ok=True) - lines = [ "from typing import Optional", '__all__ = ["__version__", "git_version"]', From 4e75b92cd3ba1d4cab4a2adac177f43fab5e7e03 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 10 Sep 2025 18:21:43 -0700 Subject: [PATCH 133/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/test_windows.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/wheel/test_windows.py b/.ci/scripts/wheel/test_windows.py index a71a1aed92e..b057895bccc 100644 --- a/.ci/scripts/wheel/test_windows.py +++ b/.ci/scripts/wheel/test_windows.py @@ -53,7 +53,7 @@ def test_model_xnnpack(model: Model, quantize: bool) -> None: assert len(ref_outputs) == len(et_outputs) for i in range(len(ref_outputs)): - assert torch.allclose(ref_outputs[i], et_outputs[i], atol=1e-4) + torch.testing.assert_close(ref_outputs[i], et_outputs[i], atol=1e-4) def run_tests(model_tests: List[ModelTest]) -> None: From 70ab5e51c428fc2cce89dec846fad83a8894d855 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 10 Sep 2025 18:55:27 -0700 Subject: [PATCH 134/134] Update [ghstack-poisoned] --- .ci/scripts/wheel/test_windows.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/wheel/test_windows.py b/.ci/scripts/wheel/test_windows.py index b057895bccc..6ae953b5df5 100644 --- a/.ci/scripts/wheel/test_windows.py +++ b/.ci/scripts/wheel/test_windows.py @@ -53,7 +53,7 @@ def test_model_xnnpack(model: Model, quantize: bool) -> None: 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) + torch.testing.assert_close(ref_outputs[i], et_outputs[i], atol=1e-4, rtol=1e-5) def run_tests(model_tests: List[ModelTest]) -> None: