Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 93 additions & 12 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ on:
required: false
default: false
type: boolean
cross-compile:
description: 'Build ARM64 from an x64 Windows host'
default: false
type: boolean
skip-binary-upload:
description: 'Skip the test-infra binary upload job'
default: false
type: boolean
secrets:
R2_ACCOUNT_ID:
description: Cloudflare R2 account ID
Expand Down Expand Up @@ -186,7 +194,7 @@ jobs:
setup-miniconda: false
python-version: ${{ env.PYTHON_VERSION }}
cuda-version: ${{ env.CU_VERSION }}
arch: ${{ inputs.architecture }}
arch: ${{ inputs.cross-compile && 'arm64' || inputs.architecture }}
- name: Shorten Conda environment path
if: inputs.architecture == 'x64'
run: |
Expand Down Expand Up @@ -233,6 +241,22 @@ jobs:
source "${BUILD_ENV_FILE}"
# shellcheck disable=SC2086
${CONDA_RUN} ${PIP_INSTALL_TORCH}
- name: Install CUDA 13.4 toolkit with ARM64 target libraries
if: inputs.cross-compile
shell: powershell
env:
CUDA_INSTALLER_URL: https://packages.nvidia.com/prerelease/cuda/13.4.0/local_installers/cuda_13.4.0_windows_x86_64.exe
CUDA_ROOT: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.4
run: |
$installer = Join-Path $env:RUNNER_TEMP "cuda_13.4.0_windows_x86_64.exe"
Invoke-WebRequest -Uri $env:CUDA_INSTALLER_URL -OutFile $installer
$process = Start-Process -FilePath $installer -ArgumentList "-s" -Wait -PassThru
if ($process.ExitCode -ne 0) { throw "CUDA 13.4 installer failed with exit code $($process.ExitCode)" }
$cudaArm64Lib = Join-Path $env:CUDA_ROOT "lib\arm64\cudart.lib"
if (-not (Test-Path -LiteralPath $cudaArm64Lib -PathType Leaf)) { throw "CUDA 13.4 ARM64 target library was not installed: $cudaArm64Lib" }
"CUDA_PATH=$env:CUDA_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"CUDA_HOME=$env:CUDA_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
(Join-Path $env:CUDA_ROOT "bin") | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Run Pre-Script with Caching
if: ${{ inputs.pre-script != '' && inputs.architecture == 'x64' }}
uses: ./test-infra/.github/actions/run-script-with-cache
Expand All @@ -242,6 +266,58 @@ jobs:
repository: ${{ inputs.repository }}
script: ${{ inputs.pre-script }}
is_windows: 'enabled'
- name: Prepare ARM64 target sysroot
if: inputs.cross-compile
working-directory: ${{ inputs.repository }}
shell: powershell
run: |
./packaging/prepare_windows_arm64_cross.ps1 `
-TargetRoot '${{ runner.temp }}\torchtrt-windows-arm64' `
-CudaRoot $env:CUDA_PATH `
-PythonExecutable (Join-Path $env:CONDA_ENV 'python.exe')
- name: Ensure MSVC ARM64 cross tools
if: inputs.cross-compile
shell: powershell
run: |
$vswhere = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio/Installer/vswhere.exe"
if (-not (Test-Path -LiteralPath $vswhere -PathType Leaf)) { throw "Visual Studio locator not found: $vswhere" }
$vsInstall = (& $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | Select-Object -First 1).Trim()
if ([string]::IsNullOrWhiteSpace($vsInstall)) { throw "No Visual Studio instance with x64 MSVC tools was found" }
$vcvarsall = [IO.Path]::Combine($vsInstall, "VC", "Auxiliary", "Build", "vcvarsall.bat")
if (-not (Test-Path -LiteralPath $vcvarsall -PathType Leaf)) { throw "vcvarsall.bat not found: $vcvarsall" }
$arm64Compiler = Get-ChildItem -Path (Join-Path $vsInstall "VC/Tools/MSVC/*/bin/Hostx64/arm64/cl.exe") -File -ErrorAction SilentlyContinue | Select-Object -First 1
if (-not $arm64Compiler) {
$installStopwatch = [Diagnostics.Stopwatch]::StartNew()
$setup = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio/Installer/setup.exe"
if (-not (Test-Path -LiteralPath $setup -PathType Leaf)) { throw "Visual Studio Installer not found: $setup" }
& $setup modify --installPath $vsInstall --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --passive --norestart
if ($LASTEXITCODE -ne 0) { throw "Installing the MSVC ARM64 component failed with exit code $LASTEXITCODE" }
$deadline = (Get-Date).AddMinutes(20)
while (-not $arm64Compiler -and (Get-Date) -lt $deadline) {
Write-Host "Waiting for the MSVC ARM64 compiler to be installed ($([Math]::Floor($installStopwatch.Elapsed.TotalSeconds)) seconds elapsed; next check in 30 seconds)..."
Start-Sleep -Seconds 30
$arm64Compiler = Get-ChildItem -Path (Join-Path $vsInstall "VC/Tools/MSVC/*/bin/Hostx64/arm64/cl.exe") -File -ErrorAction SilentlyContinue | Select-Object -First 1
}
$installStopwatch.Stop()
if ($arm64Compiler) { Write-Host "MSVC ARM64 compiler became available after $([Math]::Round($installStopwatch.Elapsed.TotalSeconds, 1)) seconds" }
$arm64Compiler = Get-ChildItem -Path (Join-Path $vsInstall "VC/Tools/MSVC/*/bin/Hostx64/arm64/cl.exe") -File -ErrorAction SilentlyContinue | Select-Object -First 1
}
if (-not $arm64Compiler) { throw "MSVC ARM64 compiler was not installed after $([Math]::Round($installStopwatch.Elapsed.TotalSeconds, 1)) seconds" }
"TORCHTRT_VCVARSALL=$vcvarsall" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Cross-compile Windows ARM64 wheel
if: inputs.cross-compile
working-directory: ${{ inputs.repository }}
shell: cmd
run: |
call "%TORCHTRT_VCVARSALL%" amd64_arm64
%CONDA_RUN% cmd /c packaging\build_windows_arm64_cross.bat
- name: Validate Windows ARM64 wheel
if: inputs.cross-compile
working-directory: ${{ inputs.repository }}
shell: cmd
run: |
call "%TORCHTRT_VCVARSALL%" amd64_arm64
powershell -NoProfile -ExecutionPolicy Bypass -File packaging\validate_windows_arm64_wheel.ps1 -DistDirectory dist
- name: Run Pre-Script Arm64
if: ${{ inputs.pre-script != '' && inputs.architecture == 'arm64' }}
env:
Expand Down Expand Up @@ -278,7 +354,7 @@ jobs:
- name: Build clean
# Only relevant for setup-py builds; python-build-package projects may
# not have a setup.py (e.g. scikit-build-core based builds).
if: inputs.build-platform == 'setup-py' && inputs.architecture == 'x64'
if: inputs.build-platform == 'setup-py' && inputs.architecture == 'x64' && inputs.cross-compile == false
working-directory: ${{ inputs.repository }}
env:
ENV_SCRIPT: ${{ inputs.env-script }}
Expand All @@ -295,7 +371,7 @@ jobs:
fi
fi
- name: Set PYTORCH_VERSION on x64
if: inputs.architecture == 'x64'
if: inputs.architecture == 'x64' && inputs.cross-compile == false
working-directory: ${{ inputs.repository }}
run: |
source "${BUILD_ENV_FILE}"
Expand All @@ -307,7 +383,7 @@ jobs:
export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//')"
fi
- name: Build the wheel (python-build-package) X64
if: ${{ inputs.build-platform == 'python-build-package' && inputs.architecture == 'x64' }}
if: ${{ inputs.build-platform == 'python-build-package' && inputs.architecture == 'x64' && inputs.cross-compile == false }}
working-directory: ${{ inputs.repository }}
env:
ENV_SCRIPT: ${{ inputs.env-script }}
Expand All @@ -322,7 +398,7 @@ jobs:
${CONDA_RUN} ${ENV_SCRIPT} ${{ inputs.build-command }}
fi
- name: Build the wheel (setup-py) X64
if: ${{ inputs.build-platform == 'setup-py' && inputs.architecture == 'x64' }}
if: ${{ inputs.build-platform == 'setup-py' && inputs.architecture == 'x64' && inputs.cross-compile == false }}
working-directory: ${{ inputs.repository }}
env:
ENV_SCRIPT: ${{ inputs.env-script }}
Expand Down Expand Up @@ -398,13 +474,13 @@ jobs:
env:
POST_SCRIPT: ${{ inputs.post-script }}
ENV_SCRIPT: ${{ inputs.env-script }}
if: ${{ inputs.post-script != '' && inputs.architecture == 'x64'}}
if: ${{ inputs.post-script != '' && inputs.architecture == 'x64' && inputs.cross-compile == false }}
run: |
set -euxo pipefail
source "${BUILD_ENV_FILE}"
${CONDA_RUN} ${ENV_SCRIPT} ${POST_SCRIPT}
- name: Smoke Test X64
if: ${{ inputs.architecture == 'x64' && inputs.is-release-tarball == false }}
if: ${{ inputs.architecture == 'x64' && inputs.cross-compile == false && inputs.is-release-tarball == false }}
env:
ENV_SCRIPT: ${{ inputs.env-script }}
PACKAGE_NAME: ${{ inputs.package-name }}
Expand Down Expand Up @@ -454,15 +530,20 @@ jobs:
fi
# NB: Only upload to GitHub after passing smoke tests
- name: Get Artifact name
if: inputs.architecture == 'arm64'
if: inputs.architecture == 'arm64' || inputs.cross-compile
env:
REPOSITORY: ${{ inputs.repository }}
REF: ${{ inputs.ref }}
PYTHON_VERSION: ${{ matrix.python_version }}
CU_VERSION: ${{ env.CU_VERSION }}
ARCH: ${{ inputs.architecture }}
ARCH: ${{ inputs.cross-compile && 'arm64' || inputs.architecture }}
run: |
echo "ARTIFACT_NAME=${REPOSITORY//\//_}_${REF//\//_}_${PYTHON_VERSION}_${CU_VERSION}_${ARCH}" >> "${GITHUB_ENV}"
artifact_cuda_version="${CU_VERSION}"
# The cross-compiled ARM64 sysroot is CUDA 13.4; retain the host CUDA label otherwise.
if [[ "${{ inputs.cross-compile }}" == "true" ]]; then
artifact_cuda_version="cu134"
fi
echo "ARTIFACT_NAME=${REPOSITORY//\//_}_${REF//\//_}_${PYTHON_VERSION}_${artifact_cuda_version}_${ARCH}" >> "${GITHUB_ENV}"
- name: Upload wheel to GitHub
if: ${{ inputs.is-release-tarball == false }}
continue-on-error: true
Expand All @@ -478,14 +559,14 @@ jobs:
name: cxx11-zip-${{ env.PYTHON_VERSION }}-${{ env.CU_VERSION }}
path: ${{ inputs.repository }}/release/tarball/
- uses: ./test-infra/.github/actions/teardown-windows
if: inputs.architecture == 'x64'
if: inputs.architecture == 'x64' || inputs.cross-compile
name: Teardown Windows

upload:
needs: build
uses: pytorch/test-infra/.github/workflows/_binary_upload.yml@main
# if it is the release wheel or tarball, then skip upload to pytorch index(release wheel are uploaded to pypi)
if: ${{ inputs.is-release-wheel == false && inputs.is-release-tarball == false }}
if: ${{ inputs.skip-binary-upload == false && inputs.is-release-wheel == false && inputs.is-release-tarball == false }}
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-linux-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ name: CI Linux x86_64
# come from the shared _decide reusable.

on:
pull_request:
types: [opened, synchronize, reopened, labeled]
#pull_request:
#types: [opened, synchronize, reopened, labeled]
pull_request_review:
types: [submitted]
push:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-sbsa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ name: CI SBSA
# RTX channels build @tensorrt_rtx_sbsa via USE_TRT_RTX=1.)

on:
pull_request:
types: [opened, synchronize, reopened, labeled]
#pull_request:
#types: [opened, synchronize, reopened, labeled]
pull_request_review:
types: [submitted]
push:
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/ci-windows-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI Windows ARM64

on:
pull_request:
types: [opened, synchronize, reopened, labeled]
pull_request_review:
types: [submitted]
push:
branches: [main]
schedule:
- cron: "0 7 * * *"
workflow_dispatch:
concurrency:
# Keep one active ARM64 run per PR/ref; CI-control labels supersede the prior run,
# while unrelated label churn remains isolated.
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}${{ (github.event.action == 'labeled' || github.event.action == 'unlabeled') && !contains(fromJSON('[\"ci: full\", \"ci: nightly\", \"backend: TensorRT\", \"backend: TensorRT-RTX\"]'), github.event.label.name) && format('-label-{0}', github.event.label.name) || '' }}"
cancel-in-progress: true


permissions:
id-token: write
contents: read

jobs:

build:
uses: ./.github/workflows/build_windows.yml
with:
repository: ${{ github.repository }}
ref: ${{ github.sha }}
build-matrix: >-
{"include":[{"build_name":"windows-arm64-cross","python_version":"3.13","desired_cuda":"cu132","validation_runner":"windows.g5.4xlarge.nvidia.gpu"}]}
architecture: x64
cross-compile: true
pre-script: packaging/pre_build_script_windows.sh
use-rtx: true
timeout: 180
skip-binary-upload: true

gate:
needs: [build]
if: always()
runs-on: ubuntu-latest
steps:
- name: Gate Windows ARM64 builds
env:
BUILD_RESULT: ${{ needs.build.result }}
run: |
set -euo pipefail
if [[ "${BUILD_RESULT}" != "success" ]]; then
exit 1
fi
echo "Windows ARM64 RTX cross-build gate passed."
35 changes: 26 additions & 9 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_zip")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")

Expand All @@ -16,8 +16,20 @@ config_setting(
)

config_setting(
name = "rtx_win",
name = "rtx_win_x86_64",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:windows",
],
flag_values = {
"//toolchains/dep_collection:compute_libs": "rtx",
},
)

config_setting(
name = "rtx_win_arm64",
constraint_values = [
"@platforms//cpu:arm64",
"@platforms//os:windows",
],
flag_values = {
Expand Down Expand Up @@ -226,9 +238,10 @@ pkg_tar(
srcs = ["//cpp/bin/torchtrtc"] + select({
":jetpack": [],
":no_package_executorch": [],
":rtx_win": [],
":rtx_x86_64": [],
":rtx_sbsa": [],
":rtx_win_arm64": [],
":rtx_win_x86_64": [],
":rtx_x86_64": [],
":windows": [],
"//conditions:default": [
"//examples/executorch_reference_runner:example_executorch_runner",
Expand Down Expand Up @@ -270,16 +283,18 @@ pkg_tar(
] + select({
":jetpack": [],
":no_package_executorch": [],
":rtx_win": [],
":rtx_x86_64": [],
":rtx_sbsa": [],
":rtx_win_arm64": [],
":rtx_win_x86_64": [],
":rtx_x86_64": [],
":windows": [],
"//conditions:default": [
":executorch_source_package",
":include_executorch",
],
}) + select({
":rtx_win": [],
":rtx_win_arm64": [],
":rtx_win_x86_64": [],
":windows": [],
"//conditions:default": [":bin"],
}),
Expand All @@ -300,7 +315,8 @@ pkg_tar(
alias(
name = "libtorchtrt",
actual = select({
":rtx_win": ":libtorchtrt_zip",
":rtx_win_arm64": ":libtorchtrt_zip",
":rtx_win_x86_64": ":libtorchtrt_zip",
":windows": ":libtorchtrt_zip",
"//conditions:default": ":libtorchtrt_tar",
}),
Expand All @@ -326,7 +342,8 @@ pkg_tar(
alias(
name = "libtorchtrt_runtime",
actual = select({
":rtx_win": ":libtorchtrt_runtime_zip",
":rtx_win_arm64": ":libtorchtrt_runtime_zip",
":rtx_win_x86_64": ":libtorchtrt_runtime_zip",
":windows": ":libtorchtrt_runtime_zip",
"//conditions:default": ":libtorchtrt_runtime_tar",
}),
Expand Down
Loading
Loading