From c83b6c5757b11832d608a833acab31eede3e35ac Mon Sep 17 00:00:00 2001 From: Jacob Szwejbka Date: Wed, 22 Oct 2025 16:12:26 -0700 Subject: [PATCH] ci --- .ci/scripts/setup-windows-msvc.ps1 | 52 ++++++++++++++++++++++++++++++ .github/workflows/windows-msvc.yml | 35 ++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 .ci/scripts/setup-windows-msvc.ps1 create mode 100644 .github/workflows/windows-msvc.yml diff --git a/.ci/scripts/setup-windows-msvc.ps1 b/.ci/scripts/setup-windows-msvc.ps1 new file mode 100644 index 00000000000..e15a003d803 --- /dev/null +++ b/.ci/scripts/setup-windows-msvc.ps1 @@ -0,0 +1,52 @@ +conda create --yes --quiet -n et python=3.12 +conda activate et + +# Install cmake +conda install -y cmake + +# Activate the VS environment - this is required for MSVC to work +# 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 CI requirements +pip install -r .ci/docker/requirements-ci.txt + +# Create build directory +$buildDir = "cmake-out-msvc" +if (Test-Path -Path $buildDir) { + Remove-Item -Path $buildDir -Recurse -Force +} +New-Item -Path $buildDir -ItemType Directory + +# Configure CMake with MSVC (not ClangCL) and disable custom/quantized ops +cmake -S . -B $buildDir ` + -DCMAKE_BUILD_TYPE=Release ` + -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON ` + -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON ` + -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON ` + -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON ` + -DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON ` + -DEXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP=ON ` + -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON ` + -DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF ` + -DEXECUTORCH_BUILD_KERNELS_CUSTOM_AOT=OFF ` + -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=OFF ` + -DEXECUTORCH_BUILD_XNNPACK=ON ` + -DEXECUTORCH_BUILD_EXTENSION_LLM=ON ` + -DEXECUTORCH_BUILD_EXTENSION_LLM_RUNNER=ON + +if ($LASTEXITCODE -ne 0) { + Write-Host "CMake configuration failed. Exit code: $LASTEXITCODE." + exit $LASTEXITCODE +} + +# Build with MSVC +cmake --build $buildDir --config Release -j16 + +if ($LASTEXITCODE -ne 0) { + Write-Host "Build failed. Exit code: $LASTEXITCODE." + exit $LASTEXITCODE +} + +Write-Host "MSVC build completed successfully!" diff --git a/.github/workflows/windows-msvc.yml b/.github/workflows/windows-msvc.yml new file mode 100644 index 00000000000..26312b050a4 --- /dev/null +++ b/.github/workflows/windows-msvc.yml @@ -0,0 +1,35 @@ +name: Windows MSVC Build + +on: + push: + branches: + - main + - release/* + tags: + - ciflow/trunk/* + pull_request: + paths: + - .ci/docker/ci_commit_pins/pytorch.txt + - .ci/scripts/** + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }} + cancel-in-progress: true + +jobs: + build-windows-msvc: + name: build-windows-msvc + 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 + script: | + conda init powershell + powershell -Command "& { + Set-PSDebug -Trace 1 + \$ErrorActionPreference = 'Stop' + \$PSNativeCommandUseErrorActionPreference = \$true + .ci/scripts/setup-windows-msvc.ps1 + }"