Skip to content

Commit cdc47c1

Browse files
committed
Update on "[slimtensor] Introduce CUDA guard to aoti/slim/cuda"
Copy CUDAGuard and CUDAStreamGuard from cuda/runtime/ to aoti/slim/cuda/ to support slimtensor requirement while get rid of potential circular dependency: - cuda_backend/main_functionalities -> aoti/slimtensor -> cuda_backend/cuda_guard This change: - copy guard.h, guard.cpp and test files from backend/cuda_backend to backend/aoti/slim/cuda/ Differential Revision: [D91056808](https://our.internmc.facebook.com/intern/diff/D91056808/) [ghstack-poisoned]
2 parents 0d8ade4 + 2b841eb commit cdc47c1

243 files changed

Lines changed: 4654 additions & 1609 deletions

File tree

Some content is hidden

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

.ci/scripts/export_model_artifact.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ if [ "$MODEL_NAME" = "parakeet" ]; then
164164
--output-dir "${OUTPUT_DIR}"
165165

166166
test -f "${OUTPUT_DIR}/model.pte"
167-
test -f "${OUTPUT_DIR}/aoti_${DEVICE}_blob.ptd"
167+
# CUDA saves named data to separate .ptd file, Metal embeds in .pte
168+
if [ "$DEVICE" = "cuda" ]; then
169+
test -f "${OUTPUT_DIR}/aoti_cuda_blob.ptd"
170+
fi
168171
test -f "${OUTPUT_DIR}/tokenizer.model"
169172
ls -al "${OUTPUT_DIR}"
170173
echo "::endgroup::"
@@ -200,7 +203,10 @@ if [ -n "$PREPROCESSOR_OUTPUT" ]; then
200203
fi
201204

202205
test -f model.pte
203-
test -f aoti_${DEVICE}_blob.ptd
206+
# CUDA saves named data to separate .ptd file, Metal embeds in .pte
207+
if [ "$DEVICE" = "cuda" ]; then
208+
test -f aoti_cuda_blob.ptd
209+
fi
204210
if [ -n "$PREPROCESSOR_OUTPUT" ]; then
205211
test -f $PREPROCESSOR_OUTPUT
206212
fi
@@ -209,7 +215,10 @@ echo "::endgroup::"
209215
echo "::group::Store $MODEL_NAME Artifacts"
210216
mkdir -p "${OUTPUT_DIR}"
211217
mv model.pte "${OUTPUT_DIR}/"
212-
mv aoti_${DEVICE}_blob.ptd "${OUTPUT_DIR}/"
218+
# CUDA saves named data to separate .ptd file, Metal embeds in .pte
219+
if [ "$DEVICE" = "cuda" ]; then
220+
mv aoti_cuda_blob.ptd "${OUTPUT_DIR}/"
221+
fi
213222
if [ -n "$PREPROCESSOR_OUTPUT" ]; then
214223
mv $PREPROCESSOR_OUTPUT "${OUTPUT_DIR}/"
215224
fi

.ci/scripts/test_model_e2e.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Arguments:
3030
- quantized-int4-weight-only
3131
3232
model_dir Directory containing model artifacts (optional, default: current directory)
33-
Expected files: model.pte, aoti_cuda_blob.ptd/aoti_metal_blob.ptd
33+
Expected files: model.pte, aoti_cuda_blob.ptd (CUDA only)
3434
Tokenizers and test files will be downloaded to this directory
3535
3636
Examples:
@@ -67,13 +67,14 @@ MODEL_DIR="${4:-.}"
6767

6868
echo "Testing model: $HF_MODEL (quantization: $QUANT_NAME)"
6969

70-
# Make sure model.pte and aoti_${DEVICE}_blob.ptd exist
70+
# Make sure model.pte exists
7171
if [ ! -f "$MODEL_DIR/model.pte" ]; then
7272
echo "Error: model.pte not found in $MODEL_DIR"
7373
exit 1
7474
fi
75-
if [ ! -f "$MODEL_DIR/aoti_${DEVICE}_blob.ptd" ]; then
76-
echo "Error: aoti_${DEVICE}_blob.ptd not found in $MODEL_DIR"
75+
# For CUDA, also check for aoti_cuda_blob.ptd (Metal embeds data in .pte)
76+
if [ "$DEVICE" = "cuda" ] && [ ! -f "$MODEL_DIR/aoti_cuda_blob.ptd" ]; then
77+
echo "Error: aoti_cuda_blob.ptd not found in $MODEL_DIR"
7778
exit 1
7879
fi
7980
# Locate EXECUTORCH_ROOT from the directory of this script
@@ -190,7 +191,11 @@ fi
190191

191192
# Build runner command with common arguments
192193
RUNNER_BIN="cmake-out/examples/models/$RUNNER_PATH/$RUNNER_TARGET"
193-
RUNNER_ARGS="--model_path ${MODEL_DIR}/model.pte --data_path ${MODEL_DIR}/aoti_${DEVICE}_blob.ptd --temperature 0"
194+
RUNNER_ARGS="--model_path ${MODEL_DIR}/model.pte --temperature 0"
195+
# For CUDA, add data_path argument (Metal embeds data in .pte)
196+
if [ "$DEVICE" = "cuda" ]; then
197+
RUNNER_ARGS="$RUNNER_ARGS --data_path ${MODEL_DIR}/aoti_cuda_blob.ptd"
198+
fi
194199

195200
# Add model-specific arguments
196201
case "$MODEL_NAME" in
@@ -204,7 +209,11 @@ case "$MODEL_NAME" in
204209
RUNNER_ARGS="$RUNNER_ARGS --tokenizer_path ${MODEL_DIR}/ --image_path $IMAGE_PATH"
205210
;;
206211
parakeet)
207-
RUNNER_ARGS="--model_path ${MODEL_DIR}/model.pte --data_path ${MODEL_DIR}/aoti_${DEVICE}_blob.ptd --audio_path ${MODEL_DIR}/$AUDIO_FILE --tokenizer_path ${MODEL_DIR}/$TOKENIZER_FILE"
212+
RUNNER_ARGS="--model_path ${MODEL_DIR}/model.pte --audio_path ${MODEL_DIR}/$AUDIO_FILE --tokenizer_path ${MODEL_DIR}/$TOKENIZER_FILE"
213+
# For CUDA, add data_path argument (Metal embeds data in .pte)
214+
if [ "$DEVICE" = "cuda" ]; then
215+
RUNNER_ARGS="$RUNNER_ARGS --data_path ${MODEL_DIR}/aoti_cuda_blob.ptd"
216+
fi
208217
;;
209218
esac
210219

.ci/scripts/zephyr-utils.sh

Lines changed: 165 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,175 @@
11
#!/bin/bash
22
# Copyright (c) Meta Platforms, Inc. and affiliates.
33
# All rights reserved.
4+
# Copyright 2026 Arm Limited and/or its affiliates.
45
#
56
# This source code is licensed under the BSD-style license found in the
67
# LICENSE file in the root directory of this source tree.
78

8-
download_arm_zephyr_sdk () {
9-
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.2/zephyr-sdk-0.17.2_linux-x86_64.tar.xz
10-
tar -xf zephyr-sdk-0.17.2_linux-x86_64.tar.xz
11-
rm -f zephyr-sdk-0.17.2_linux-x86_64.tar.xz
9+
# Run instruction from zephyr/README.md
10+
#
11+
# This contains some CI helper runtime functions to dig out and run commands
12+
# from zephyr/README.md
13+
# It also try to verify that zephyr/executorch.yaml is in sync and the snippets
14+
# in the README are sane with various regexps.
15+
#
16+
# Main functions is run_command_block_from_zephyr_readme it will dig out the code between
17+
# the two ''' after a blockheader text and run it
18+
#
19+
# .e.g. from this README.md snippet
20+
#
21+
# Install requirements
22+
# ```
23+
# pip install something
24+
# pip install something_else
25+
# ```
26+
#
27+
# The blockheader is 'Install requirements' and the code block is 'pip install something ... \npip install something_else'
28+
# so if we run
29+
# run_command_block_from_zephyr_readme 'Install requirements' '^(pip|pip3)[[:space:]]+install([[:space:]].*)?$'
30+
# it will make sure each lite start with pip or pip3 and then run them one by one
31+
32+
33+
34+
# Resolve and cache this script's directory; if sourced, and remember it globally
35+
# So functions in this script can be used even after sourced and still find
36+
# the correct paths
37+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
38+
if [[ "${BASH_SOURCE[0]}" != "$0" ]]; then
39+
export ZEPHYR_UTILS_DIR="${script_dir}"
40+
fi
41+
42+
# Internal utility functions
43+
_zephyr_utils_root_dir () {
44+
local script_dir resolved
45+
46+
if [[ -n "${ZEPHYR_UTILS_DIR:-}" ]]; then
47+
script_dir="${ZEPHYR_UTILS_DIR}"
48+
else
49+
resolved="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
50+
if [[ "${BASH_SOURCE[0]}" != "$0" ]]; then
51+
ZEPHYR_UTILS_DIR="${resolved}"
52+
fi
53+
script_dir="${resolved}"
54+
fi
55+
56+
(cd "${script_dir}/../.." && pwd)
57+
}
58+
59+
_zephyr_utils_readme_path () {
60+
local root_dir
61+
root_dir="$(_zephyr_utils_root_dir)"
62+
printf '%s/zephyr/README.md\n' "${root_dir}"
63+
}
64+
65+
_zephyr_utils_ensure_file () {
66+
local path="$1"
67+
local description="$2"
68+
if [[ ! -f "${path}" ]]; then
69+
echo "ERROR: ${description} not found at ${path}" >&2
70+
return 1
71+
fi
1272
}
1373

14-
setup_zephyr_et_module () {
15-
git clone --branch executorch-module-integration https://github.com/BujSet/zephyr.git
16-
west init -l zephyr
17-
west config manifest.project-filter -- +executorch
18-
west -v update
74+
_zephyr_utils_extract_block () {
75+
local readme_path="$1"
76+
local marker="$2"
77+
awk -v marker="${marker}" '
78+
$0 ~ marker { section=1; next }
79+
section && /^```/ {
80+
if (in_block) { exit }
81+
in_block=1
82+
next
83+
}
84+
in_block && /^```/ { exit }
85+
in_block { sub(/\r$/, ""); print }
86+
' "${readme_path}"
87+
}
88+
89+
_zephyr_utils_run_simple_commands () {
90+
local block="$1"
91+
local allowedpattern="$2"
92+
local description="$3"
93+
temp_dir="$(mktemp -d)"
94+
if [[ ! -d "${temp_dir}" ]]; then
95+
echo "ERROR: Failed to create temporary directory for west init" >&2
96+
return 1
97+
fi
98+
trap "rm -rf '${temp_dir}'; trap - RETURN" RETURN
99+
100+
local ran=0 cmd
101+
while IFS= read -r cmd; do
102+
cmd="${cmd#"${cmd%%[![:space:]]*}"}"
103+
cmd="${cmd%"${cmd##*[![:space:]]}"}"
104+
[[ -z "${cmd}" ]] && continue
105+
106+
if [[ ! "${cmd}" =~ ${allowedpattern} ]]; then
107+
echo "ERROR: Unexpected command in '${description}' readme block: ${cmd} must match pattern: ${allowedpattern}" >&2
108+
return 1
109+
fi
110+
111+
if [[ "${cmd}" == *";"* || "${cmd}" == *"&&"* || "${cmd}" == *"||"* || "${cmd}" == *"|"* ]]; then
112+
echo "ERROR: Command chaining is not allowed in '${description}' readme block: ${cmd}" >&2
113+
return 1
114+
fi
115+
116+
echo "Running: ${cmd}"
117+
if ! eval "${cmd}"; then
118+
return 1
119+
fi
120+
ran=1
121+
done <<< "${block}"
122+
123+
if [[ ${ran} -eq 0 ]]; then
124+
echo "ERROR: No commands found in block after ${description}" >&2
125+
return 1
126+
fi
127+
128+
return 0
129+
}
130+
131+
run_command_block_from_zephyr_readme () {
132+
local blockheader="$1"
133+
local allowedpattern="$2"
134+
135+
echo "Run block '${blockheader}' from zephyr/README.md"
136+
137+
readme_path="$(_zephyr_utils_readme_path)"
138+
_zephyr_utils_ensure_file "${readme_path}" "README.md" || return 1
139+
140+
block="$(_zephyr_utils_extract_block "${readme_path}" "${blockheader}")"
141+
142+
if [[ -z "${block}" ]]; then
143+
echo "ERROR: Failed to locate ${blockheader} block in ${readme_path}" >&2
144+
return 1
145+
fi
146+
_zephyr_utils_run_simple_commands "${block}" "${allowedpattern}" "${blockheader}"
147+
}
148+
149+
# Check that zephyr/executorch.yaml match zephyr/README.md
150+
verify_zephyr_readme () {
151+
local readme_path manifest_path snippet
152+
153+
readme_path="$(_zephyr_utils_readme_path)"
154+
manifest_path="$(_zephyr_utils_root_dir)/zephyr/executorch.yaml"
155+
156+
_zephyr_utils_ensure_file "${readme_path}" "README" || return 1
157+
_zephyr_utils_ensure_file "${manifest_path}" "Manifest" || return 1
158+
159+
snippet="$(
160+
_zephyr_utils_extract_block "${readme_path}" '<zephyr_build_root>/zephyr/submanifests/executorch\.yaml'
161+
)"
162+
163+
if [[ -z "${snippet}" ]]; then
164+
echo "ERROR: Failed to extract executorch.yaml snippet from ${readme_path}" >&2
165+
return 1
166+
fi
167+
168+
if diff -u <(printf '%s\n' "${snippet}") "${manifest_path}"; then
169+
echo "zephyr/README.md executorch.yaml snippet is in sync with zephyr/executorch.yaml" >&2
170+
return 0
171+
fi
172+
173+
echo "ERROR: ${readme_path} executorch.yaml snippet is out of sync with ${manifest_path}" >&2
174+
return 1
19175
}

.github/workflows/add-unanswered-to-project.yml

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,46 @@ jobs:
4242
"agunapal", "SamGondelman", "Ninja91", "ivayloen", "DrJessop", "rodrigos01meta", "akrieger", "cmt0", "yiming0416",
4343
"ethansfng", "ThomasJannaud", "nirvanagth", "marcinkwiatkowski", "3l1", "omerjerk", "nitish2112", "yipjustin",
4444
"ejnguyen", "andrewor14", "phaiting", "mgiordy", "LeeOHzzZ", "adicatana", "Polyomino", "ezrilow", "navsud",
45-
"michaelmaitland", "RahulC7", "seyeong-han", "thdusdl1219", "YifanShenSZ", "RdoubleA", "Olivia-liu", "Abhi-hpp",
46-
"Vysarat", "azad-meta", "junpi", "pytorchbot", "pytorchmergebot", "pytorchupdatebot", "facebook-github-bot",
47-
"app/dependabot", "Erik-Lundell", "zingo", "AdrianLundell", "oscarandersson8218", "per", "Sebastian-Larsson", "SaoirseARM",
48-
"robell", "mansnils", "martinlsm", "freddan80", "YufengShi-dudu", "tom-arm", "perheld", "Jerry-Ge", "gggekov", "fumchin",
49-
"wwwind", "benkli01", "Tessil", "maddun01", "Michiel-Olieslagers", "armwaheed", "agrima1304", "emmakujala", "annietllnd",
50-
"MatthiasHertel80", "AlexTawseArm", "jmahbs", "morgolock", "Christoffer-JL", "ArmRyan", "xingguo01", "tgonzalezorlandoarm",
51-
"haowhsu-quic", "shewu-quic", "winskuo-quic", "chunit-quic", "DannyYuyang-quic", "chuntl", "thchenqti", "jethroqti",
52-
"chenweng-quic", "cymbalrush", "DenisVieriu97", "billmguo", "StrycekSimon", "jirioc", "robert-kalmar", "skywall",
53-
"MartinPavella", "roman-janik-nxp", "novak-vaclav", "neuropilot-captain", "dijopaul", "cad-rlc", "cad-audio", "ynimmaga",
54-
"daniil-lyakhov", "emmanuel-ferdman", "cavusmustafa", "anzr299", "Jiseong-oh", "alexdean08",
45+
"michaelmaitland", "RahulC7", "seyeong-han", "thdusdl1219", "jaejunku", "felixweilbach", "apullin", "trviv", "YifanShenSZ",
46+
"RdoubleA", "Olivia-liu", "Abhi-hpp", "Vysarat", "azad-meta", "junpi", "pytorchbot", "pytorchmergebot", "pytorchupdatebot",
47+
"facebook-github-bot", "app/dependabot", "Erik-Lundell", "zingo", "AdrianLundell", "oscarandersson8218", "per", "Sebastian-Larsson",
48+
"SaoirseARM", "robell", "mansnils", "martinlsm", "freddan80", "YufengShi-dudu", "tom-arm", "perheld", "Jerry-Ge", "gggekov",
49+
"fumchin", "wwwind", "benkli01", "Tessil", "maddun01", "Michiel-Olieslagers", "armwaheed", "agrima1304", "emmakujala",
50+
"annietllnd", "MatthiasHertel80", "AlexTawseArm", "jmahbs", "morgolock", "Christoffer-JL", "ArmRyan", "xingguo01",
51+
"tgonzalezorlandoarm", "chizkiyahu", "sarah-blades", "haowhsu-quic", "shewu-quic", "winskuo-quic", "chunit-quic", "DannyYuyang-quic",
52+
"chuntl", "thchenqti", "jethroqti", "chenweng-quic", "cymbalrush", "DenisVieriu97", "billmguo", "StrycekSimon", "jirioc", "robert-kalmar",
53+
"skywall", "MartinPavella", "roman-janik-nxp", "novak-vaclav", "neuropilot-captain", "dijopaul", "cad-rlc", "cad-audio",
54+
"ynimmaga", "daniil-lyakhov", "emmanuel-ferdman", "cavusmustafa", "anzr299", "Jiseong-oh", "alexdean08",
5555
// explicitly include the dependabot bot login seen in PRs
5656
"dependabot[bot]"
5757
]);
5858
59+
// List of organization logins (lowercased) to exclude members of
60+
const excludedOrgs = new Set([
61+
"meta", "facebook", "pytorch", "arm", "apple", "qualcomm", "nxp", "mediatek", "cadence", "intel", "samsung"
62+
]);
63+
64+
// Simple cache for user -> boolean (member of excluded org)
65+
const orgsCache = new Map();
66+
67+
async function isMemberOfExcludedOrg(user) {
68+
if (!user || !user.login) return false;
69+
const login = user.login;
70+
if (orgsCache.has(login)) return orgsCache.get(login);
71+
try {
72+
const response = await github.rest.orgs.listForUser({ username: login });
73+
const orgs = response && response.data ? response.data : [];
74+
const isMember = orgs.some(o => o && o.login && excludedOrgs.has(o.login.toLowerCase()));
75+
orgsCache.set(login, isMember);
76+
return isMember;
77+
} catch (error) {
78+
// If checking orgs fails (rate limit, permissions etc.), assume not a member to avoid false positives.
79+
console.log(`Error checking orgs for ${login}: ${error.message}`);
80+
orgsCache.set(login, false);
81+
return false;
82+
}
83+
}
84+
5985
function isBotOrExcluded(user) {
6086
if (!user) return false;
6187
// GitHub sometimes marks bots with user.type === "Bot"

.github/workflows/pull.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ jobs:
301301
model: ["gemma3-4b"] # llava gives segfault so not covering.
302302
with:
303303
secrets-env: EXECUTORCH_HF_TOKEN
304-
runner: linux.24xlarge
304+
runner: linux.24xlarge.memory
305305
docker-image: ci-image:executorch-ubuntu-22.04-clang12
306306
submodules: 'recursive'
307307
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}

0 commit comments

Comments
 (0)