Skip to content

Commit c974788

Browse files
authored
Merge branch 'main' into tosa_llm_ext
2 parents 9f93123 + 1a086f0 commit c974788

File tree

266 files changed

+10320
-1659
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

266 files changed

+10320
-1659
lines changed

.ci/docker/build.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ case "${IMAGE_NAME}" in
6767
# From https://developer.android.com/ndk/downloads
6868
ANDROID_NDK_VERSION=r28c
6969
;;
70+
executorch-ubuntu-22.04-cuda-windows)
71+
LINTRUNNER=""
72+
GCC_VERSION=11
73+
CUDA_WINDOWS_CROSS_COMPILE=yes
74+
CUDA_VERSION=12.8
75+
SKIP_PYTORCH=yes
76+
;;
7077
*)
7178
echo "Invalid image name ${IMAGE_NAME}"
7279
exit 1
@@ -101,6 +108,8 @@ docker build \
101108
--build-arg "MEDIATEK_SDK=${MEDIATEK_SDK:-}" \
102109
--build-arg "ANDROID_NDK_VERSION=${ANDROID_NDK_VERSION:-}" \
103110
--build-arg "SKIP_PYTORCH=${SKIP_PYTORCH:-}" \
111+
--build-arg "CUDA_WINDOWS_CROSS_COMPILE=${CUDA_WINDOWS_CROSS_COMPILE:-}" \
112+
--build-arg "CUDA_VERSION=${CUDA_VERSION:-}" \
104113
-f "${OS}"/Dockerfile \
105114
"$@" \
106115
.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
732b11313b2006b4d8649500eaf5567ec6ac1e49
1+
f8aa919593cc51301ade73a2ee5491582521ab80

.ci/docker/common/install_cuda.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
# Install Linux CUDA toolkit
9+
# This installs nvcc and other CUDA development tools needed for compiling CUDA code
10+
11+
set -ex
12+
13+
# CUDA version must be specified (e.g., 12.8)
14+
CUDA_VERSION="${CUDA_VERSION:?CUDA_VERSION must be set}"
15+
16+
# Convert version format (e.g., 12.8 -> 12-8 for package names)
17+
CUDA_VERSION_DASH=$(echo "${CUDA_VERSION}" | tr '.' '-')
18+
19+
# Add NVIDIA package repository
20+
apt-get update
21+
apt-get install -y --no-install-recommends \
22+
gnupg2 \
23+
ca-certificates \
24+
wget
25+
26+
# Download and install the CUDA keyring
27+
wget -q "https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb" -O /tmp/cuda-keyring.deb
28+
dpkg -i /tmp/cuda-keyring.deb
29+
rm /tmp/cuda-keyring.deb
30+
31+
apt-get update
32+
33+
# Install CUDA toolkit (nvcc and development libraries)
34+
# We install a minimal set of packages needed for compilation:
35+
# - cuda-nvcc: The CUDA compiler
36+
# - cuda-cudart-dev: CUDA runtime development files
37+
# - cuda-nvrtc-dev: CUDA runtime compilation library
38+
# - libcublas-dev: cuBLAS development files
39+
# - libcusparse-dev: cuSPARSE development files
40+
# - libcufft-dev: cuFFT development files
41+
apt-get install -y --no-install-recommends \
42+
"cuda-nvcc-${CUDA_VERSION_DASH}" \
43+
"cuda-cudart-dev-${CUDA_VERSION_DASH}" \
44+
"cuda-nvrtc-dev-${CUDA_VERSION_DASH}" \
45+
"libcublas-dev-${CUDA_VERSION_DASH}" \
46+
"libcusparse-dev-${CUDA_VERSION_DASH}" \
47+
"libcufft-dev-${CUDA_VERSION_DASH}"
48+
49+
# Clean up
50+
apt-get clean
51+
rm -rf /var/lib/apt/lists/*
52+
53+
# Verify installation
54+
/usr/local/cuda-${CUDA_VERSION}/bin/nvcc --version
55+
56+
echo "CUDA ${CUDA_VERSION} toolkit installation complete"
57+
echo "CUDA_HOME=/usr/local/cuda-${CUDA_VERSION}"
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
# Install mingw-w64 cross-compiler and Windows CUDA toolkit for cross-compilation
9+
10+
set -ex
11+
12+
INSTALL_DIR="${WINDOWS_CUDA_INSTALL_DIR:-/opt/cuda-windows}"
13+
14+
# Mapping of CUDA versions to their corresponding driver versions for Windows installers
15+
# Source: https://developer.nvidia.com/cuda-toolkit-archive
16+
declare -A CUDA_DRIVER_MAP=(
17+
["12.6"]="12.6.3:561.17"
18+
["12.8"]="12.8.1:572.61"
19+
["12.9"]="12.9.1:576.57"
20+
)
21+
22+
install_mingw() {
23+
echo "Installing mingw-w64 cross-compiler..."
24+
25+
apt-get update
26+
# Install the POSIX threads version of mingw-w64 which supports C++11 threading
27+
# primitives (std::mutex, std::condition_variable, std::shared_mutex).
28+
# The default win32 threads version does not support these.
29+
apt-get install -y --no-install-recommends \
30+
g++-mingw-w64-x86-64-posix \
31+
mingw-w64-tools \
32+
p7zip-full \
33+
wget
34+
35+
# Verify installation shows POSIX threads
36+
x86_64-w64-mingw32-g++ --version
37+
38+
# Cleanup
39+
apt-get clean
40+
rm -rf /var/lib/apt/lists/*
41+
42+
echo "mingw-w64 installation complete (POSIX threads version)"
43+
}
44+
45+
get_torch_cuda_version() {
46+
# Query PyTorch for its CUDA version using conda environment
47+
conda run -n "py_${PYTHON_VERSION}" python3 -c "import torch; print(torch.version.cuda)" 2>/dev/null || echo ""
48+
}
49+
50+
install_windows_cuda() {
51+
# Get CUDA version from torch
52+
TORCH_CUDA_VERSION=$(get_torch_cuda_version)
53+
54+
if [ -z "${TORCH_CUDA_VERSION}" ] || [ "${TORCH_CUDA_VERSION}" = "None" ]; then
55+
echo "ERROR: Could not detect CUDA version from PyTorch."
56+
echo "Make sure PyTorch with CUDA support is installed before running this script."
57+
exit 1
58+
fi
59+
60+
echo "Detected PyTorch CUDA version: ${TORCH_CUDA_VERSION}"
61+
62+
# Extract major.minor version (e.g., "12.8" from "12.8.1" or "12.8")
63+
CUDA_MAJOR_MINOR=$(echo "${TORCH_CUDA_VERSION}" | cut -d. -f1,2)
64+
65+
# Look up the full version and driver version
66+
if [ -z "${CUDA_DRIVER_MAP[${CUDA_MAJOR_MINOR}]}" ]; then
67+
echo "ERROR: CUDA version ${CUDA_MAJOR_MINOR} is not in the known version map."
68+
echo "Known versions: ${!CUDA_DRIVER_MAP[*]}"
69+
exit 1
70+
fi
71+
72+
CUDA_INFO="${CUDA_DRIVER_MAP[${CUDA_MAJOR_MINOR}]}"
73+
CUDA_VERSION=$(echo "${CUDA_INFO}" | cut -d: -f1)
74+
CUDA_DRIVER_VERSION=$(echo "${CUDA_INFO}" | cut -d: -f2)
75+
76+
echo "Using CUDA ${CUDA_VERSION} with driver ${CUDA_DRIVER_VERSION}"
77+
78+
echo "Installing Windows CUDA toolkit ${CUDA_VERSION}..."
79+
80+
mkdir -p "${INSTALL_DIR}"
81+
cd "${INSTALL_DIR}"
82+
83+
CUDA_INSTALLER="cuda_${CUDA_VERSION}_${CUDA_DRIVER_VERSION}_windows.exe"
84+
CUDA_URL="https://developer.download.nvidia.com/compute/cuda/${CUDA_VERSION}/local_installers/${CUDA_INSTALLER}"
85+
86+
# Check if already downloaded and extracted
87+
if [ -d "${INSTALL_DIR}/extracted/cuda_cudart" ]; then
88+
echo "Windows CUDA toolkit already installed, skipping download..."
89+
return 0
90+
fi
91+
92+
echo "Downloading CUDA installer from ${CUDA_URL}..."
93+
wget -q "${CUDA_URL}" -O "${CUDA_INSTALLER}"
94+
95+
echo "Extracting CUDA toolkit..."
96+
7z x "${CUDA_INSTALLER}" -o"extracted" -y
97+
98+
# Fix permissions so ci-user can access the files
99+
chmod -R a+rX "${INSTALL_DIR}"
100+
101+
# Clean up installer to save space
102+
rm -f "${CUDA_INSTALLER}"
103+
104+
echo "Windows CUDA toolkit installation complete"
105+
echo "WINDOWS_CUDA_HOME=${INSTALL_DIR}/extracted/cuda_cudart/cudart"
106+
}
107+
108+
# Parse command line arguments
109+
INSTALL_MINGW=false
110+
INSTALL_CUDA=false
111+
112+
while [[ $# -gt 0 ]]; do
113+
case $1 in
114+
--mingw)
115+
INSTALL_MINGW=true
116+
shift
117+
;;
118+
--cuda)
119+
INSTALL_CUDA=true
120+
shift
121+
;;
122+
--all)
123+
INSTALL_MINGW=true
124+
INSTALL_CUDA=true
125+
shift
126+
;;
127+
*)
128+
echo "Unknown option: $1"
129+
echo "Usage: $0 [--mingw] [--cuda] [--all]"
130+
exit 1
131+
;;
132+
esac
133+
done
134+
135+
# Default to installing everything if no options specified
136+
if [ "${INSTALL_MINGW}" = false ] && [ "${INSTALL_CUDA}" = false ]; then
137+
INSTALL_MINGW=true
138+
INSTALL_CUDA=true
139+
fi
140+
141+
if [ "${INSTALL_MINGW}" = true ]; then
142+
install_mingw
143+
fi
144+
145+
if [ "${INSTALL_CUDA}" = true ]; then
146+
install_windows_cuda
147+
fi
148+
149+
echo "Installation complete"

.ci/docker/common/install_zephyr.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#!/bin/bash
33
# Copyright (c) Meta Platforms, Inc. and affiliates.
44
# All rights reserved.
5+
# Copyright 2026 Arm Limited and/or its affiliates.
56
#
67
# This source code is licensed under the BSD-style license found in the
78
# LICENSE file in the root directory of this source tree.
@@ -82,6 +83,13 @@ install_prerequiresites() {
8283
rm -f kitware-archive.sh
8384
pip_install --no-cache-dir west
8485
pip_install pyelftools
86+
87+
# Zephyr SDK
88+
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.4/zephyr-sdk-0.17.4_linux-x86_64.tar.xz
89+
tar -xf zephyr-sdk-0.17.4_linux-x86_64.tar.xz
90+
rm -f zephyr-sdk-0.17.4_linux-x86_64.tar.xz*
91+
# Save setup to later and this get symlinked in to another folder in the test in trunk.yml
92+
#./zephyr-sdk-0.17.4/setup.sh -c -t arm-zephyr-eabi
8593
}
8694

8795
install_prerequiresites

.ci/docker/ubuntu/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,23 @@ ARG QNN_SDK
9898

9999
ARG MEDIATEK_SDK
100100

101+
ARG CUDA_WINDOWS_CROSS_COMPILE
102+
ARG CUDA_VERSION
103+
COPY ./common/install_cuda.sh install_cuda.sh
104+
COPY ./common/install_cuda_windows_cross_compile.sh install_cuda_windows_cross_compile.sh
105+
COPY ./common/utils.sh utils.sh
106+
RUN if [ -n "${CUDA_WINDOWS_CROSS_COMPILE}" ]; then \
107+
CUDA_VERSION=${CUDA_VERSION} bash ./install_cuda.sh && \
108+
bash ./install_cuda_windows_cross_compile.sh; \
109+
fi
110+
RUN rm -f install_cuda.sh install_cuda_windows_cross_compile.sh utils.sh
111+
# Set up CUDA environment for Linux compilation (nvcc, etc.)
112+
ENV CUDA_HOME=/usr/local/cuda
113+
ENV PATH=${CUDA_HOME}/bin:${PATH}
114+
# Ensure system libstdc++ is found before conda's (GLIBCXX_3.4.30 compatibility)
115+
ENV LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
116+
# Windows CUDA for cross-compilation
117+
ENV WINDOWS_CUDA_HOME=/opt/cuda-windows/extracted/cuda_cudart/cudart
118+
101119
USER ci-user
102120
CMD ["bash"]

.ci/scripts/export_model_artifact.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ OUTPUT_DIR="${4:-.}"
6060
case "$DEVICE" in
6161
cuda)
6262
;;
63+
cuda-windows)
64+
;;
6365
metal)
6466
;;
6567
*)
6668
echo "Error: Unsupported device '$DEVICE'"
67-
echo "Supported devices: cuda, metal"
69+
echo "Supported devices: cuda, cuda-windows, metal"
6870
exit 1
6971
;;
7072
esac
@@ -104,10 +106,6 @@ case "$HF_MODEL" in
104106
PREPROCESSOR_OUTPUT=""
105107
;;
106108
nvidia/parakeet-tdt)
107-
if [ "$DEVICE" = "metal" ]; then
108-
echo "Error: Export for device 'metal' is not yet tested for model '$HF_MODEL'"
109-
exit 1
110-
fi
111109
MODEL_NAME="parakeet"
112110
TASK=""
113111
MAX_SEQ_LEN=""
@@ -181,7 +179,7 @@ if [ -n "$MAX_SEQ_LEN" ]; then
181179
fi
182180

183181
DEVICE_ARG=""
184-
if [ "$DEVICE" = "cuda" ]; then
182+
if [ "$DEVICE" = "cuda" ] || [ "$DEVICE" = "cuda-windows" ]; then
185183
DEVICE_ARG="--device cuda"
186184
fi
187185

@@ -203,10 +201,17 @@ if [ -n "$PREPROCESSOR_OUTPUT" ]; then
203201
--output_file $PREPROCESSOR_OUTPUT
204202
fi
205203

204+
# Determine blob file name - cuda and cuda-windows both use aoti_cuda_blob.ptd
205+
if [ "$DEVICE" = "cuda" ] || [ "$DEVICE" = "cuda-windows" ]; then
206+
BLOB_FILE="aoti_cuda_blob.ptd"
207+
else
208+
BLOB_FILE="aoti_${DEVICE}_blob.ptd"
209+
fi
210+
206211
test -f model.pte
207212
# CUDA saves named data to separate .ptd file, Metal embeds in .pte
208-
if [ "$DEVICE" = "cuda" ]; then
209-
test -f aoti_cuda_blob.ptd
213+
if [ "$DEVICE" = "cuda" ] || [ "$DEVICE" = "cuda-windows" ]; then
214+
test -f $BLOB_FILE
210215
fi
211216
if [ -n "$PREPROCESSOR_OUTPUT" ]; then
212217
test -f $PREPROCESSOR_OUTPUT
@@ -217,8 +222,8 @@ echo "::group::Store $MODEL_NAME Artifacts"
217222
mkdir -p "${OUTPUT_DIR}"
218223
mv model.pte "${OUTPUT_DIR}/"
219224
# CUDA saves named data to separate .ptd file, Metal embeds in .pte
220-
if [ "$DEVICE" = "cuda" ]; then
221-
mv aoti_cuda_blob.ptd "${OUTPUT_DIR}/"
225+
if [ "$DEVICE" = "cuda" ] || [ "$DEVICE" = "cuda-windows" ]; then
226+
mv $BLOB_FILE "${OUTPUT_DIR}/"
222227
fi
223228
if [ -n "$PREPROCESSOR_OUTPUT" ]; then
224229
mv $PREPROCESSOR_OUTPUT "${OUTPUT_DIR}/"
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#!/bin/bash
2-
# Copyright 2024 Arm Limited and/or its affiliates.
2+
# Copyright 2024,2026 Arm Limited and/or its affiliates.
33
#
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

77
# NB: This function could be used to install Arm dependencies
88
# Setup arm example environment (including TOSA tools)
9-
git config --global user.email "github_executorch@arm.com"
10-
git config --global user.name "Github Executorch"
9+
# Configure git user only if not already set
10+
if ! git config --get user.name >/dev/null 2>&1; then
11+
git config --global user.name "Github Executorch"
12+
fi
13+
if ! git config --get user.email >/dev/null 2>&1; then
14+
git config --global user.email "github_executorch@arm.com"
15+
fi
1116
bash examples/arm/setup.sh --i-agree-to-the-contained-eula ${@:-}

0 commit comments

Comments
 (0)