From 435283847b5337ce30f02b67a66d0b85c2f658ef Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 20 Aug 2025 19:04:37 -0700 Subject: [PATCH 1/5] Update [ghstack-poisoned] --- .ci/scripts/unittest-windows.ps1 | 15 +++++++++++++++ .github/workflows/_unittest.yml | 9 +++++++++ 2 files changed, 24 insertions(+) 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..aadde5b4881 --- /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 From fe0672edec2bf87a3bc99339eef2e1fd0c6bd13e Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 20 Aug 2025 19:08:25 -0700 Subject: [PATCH 2/5] 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 aadde5b4881..9c0e7c073ed 100644 --- a/.ci/scripts/unittest-windows.ps1 +++ b/.ci/scripts/unittest-windows.ps1 @@ -1,6 +1,6 @@ Set-PSDebug -Trace 1 $ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = \$true +$PSNativeCommandUseErrorActionPreference = $true conda create --yes --quiet -n et python=3.12 conda activate et From 59e12573d569853bd583f19aff45b572c441ecc5 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 20 Aug 2025 23:17:19 -0700 Subject: [PATCH 3/5] Update [ghstack-poisoned] --- install_requirements.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/install_requirements.py b/install_requirements.py index 15b4a23a879..d5d9a2f31f3 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -110,10 +110,16 @@ def install_requirements(use_pytorch_nightly): check=True, ) - LOCAL_REQUIREMENTS = [ - "third-party/ao", # We need the latest kernels for fast iteration, so not relying on pypi. - "extension/llm/tokenizers", # TODO(larryliu0820): Setup a pypi package for this. - ] + LOCAL_REQUIREMENTS = ( + [ + "third-party/ao", # We need the latest kernels for fast iteration, so not relying on pypi. + ] + + [ + "extension/llm/tokenizers", # TODO(larryliu0820): Setup a pypi package for this. + ] + if sys.platform != "win32" + else [] + ) # TODO(gjcomer): Re-enable when buildable on Windows. # Install packages directly from local copy instead of pypi. # This is usually not recommended. From 537e26674af2a3c188df53e4e367121a07547de7 Mon Sep 17 00:00:00 2001 From: Gregory James Comer Date: Wed, 20 Aug 2025 23:42:12 -0700 Subject: [PATCH 4/5] Update [ghstack-poisoned] --- install_requirements.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/install_requirements.py b/install_requirements.py index d5d9a2f31f3..3bd75cad6a3 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -110,11 +110,10 @@ def install_requirements(use_pytorch_nightly): check=True, ) - LOCAL_REQUIREMENTS = ( + LOCAL_REQUIREMENTS = [ + "third-party/ao", # We need the latest kernels for fast iteration, so not relying on pypi. + ] + ( [ - "third-party/ao", # We need the latest kernels for fast iteration, so not relying on pypi. - ] - + [ "extension/llm/tokenizers", # TODO(larryliu0820): Setup a pypi package for this. ] if sys.platform != "win32" From d7ad074ce8001148e29785b8d92113fa5038f9e4 Mon Sep 17 00:00:00 2001 From: Gregory Comer Date: Sun, 24 Aug 2025 17:32:42 -0700 Subject: [PATCH 5/5] Update [ghstack-poisoned] --- backends/xnnpack/CMakeLists.txt | 2 +- install_executorch.py | 5 ----- setup.py | 7 ++++++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/backends/xnnpack/CMakeLists.txt b/backends/xnnpack/CMakeLists.txt index 028709fcedc..6c28a3d8c70 100644 --- a/backends/xnnpack/CMakeLists.txt +++ b/backends/xnnpack/CMakeLists.txt @@ -62,7 +62,7 @@ endforeach() if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") 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"], ),