From d6a70d66a9ca1897446af07392b2c586ec2eeba9 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 26 Aug 2025 15:48:07 -0700 Subject: [PATCH 01/79] 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 02/79] 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 03/79] 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 04/79] 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 05/79] 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 06/79] 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 07/79] 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 08/79] 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 09/79] 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 10/79] 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 11/79] 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 12/79] 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 13/79] 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 14/79] 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 15/79] 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 16/79] 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 17/79] 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 18/79] 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 19/79] 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 20/79] 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 21/79] 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 22/79] 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 23/79] 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 24/79] 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 25/79] 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 26/79] 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 27/79] 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 28/79] 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 29/79] 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 30/79] 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 31/79] 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 32/79] 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 33/79] 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 34/79] 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 35/79] 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 36/79] 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 37/79] 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 38/79] 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 39/79] 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 40/79] 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 41/79] 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 42/79] 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 43/79] 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 44/79] 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 45/79] 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 46/79] 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 47/79] 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 48/79] 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 49/79] 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 50/79] 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 51/79] 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 52/79] 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 53/79] 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 54/79] 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 55/79] 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 56/79] 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 57/79] 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 58/79] 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 59/79] 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 60/79] 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 61/79] 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 62/79] 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 63/79] 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 64/79] 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 65/79] 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 66/79] 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 67/79] 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 68/79] 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 69/79] 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 70/79] 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 71/79] 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 72/79] 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 ae63814c399f06cc0eaf5c5afccf7ae6062d06e8 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 2 Sep 2025 11:53:45 -0700 Subject: [PATCH 73/79] 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 74/79] 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 b41ddee759cb052ec304abad158a28697daeaa08 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Tue, 2 Sep 2025 18:16:06 -0700 Subject: [PATCH 75/79] 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 fd3d9c35795505a85e478b4f9c4c137bf72a82a0 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 2 Sep 2025 21:06:52 -0700 Subject: [PATCH 76/79] 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 8a4a0e32c5b93d77eac2069c2a1726fbc576f586 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Tue, 2 Sep 2025 21:41:51 -0700 Subject: [PATCH 77/79] 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 78/79] 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 79/79] 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