Skip to content

Commit f47dc38

Browse files
authored
Merge branch 'main' into docs-android-kotlin
2 parents 56a54a6 + a2438e4 commit f47dc38

727 files changed

Lines changed: 42621 additions & 8110 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/docker/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ case "${IMAGE_NAME}" in
8989
OS_VERSION=24.04
9090
GCC_VERSION=14
9191
;;
92-
executorch-ubuntu-26.04-gcc15)
92+
executorch-ubuntu-26.04-gcc14)
9393
LINTRUNNER=""
9494
OS_VERSION=26.04
95-
GCC_VERSION=15
95+
GCC_VERSION=14
9696
;;
9797
*)
9898
echo "Invalid image name ${IMAGE_NAME}"

.ci/scripts/export_model_artifact.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,9 @@ if [ "$MODEL_NAME" = "qwen3_5_moe" ]; then
422422
--no-compile
423423
echo "::endgroup::"
424424

425-
# Copy tokenizer for the runner
425+
# Copy tokenizer files for the runner and model-specific serving launcher.
426426
cp "$LOCAL_MODEL_DIR/tokenizer.json" "${OUTPUT_DIR}/tokenizer.json"
427+
cp "$LOCAL_MODEL_DIR/tokenizer_config.json" "${OUTPUT_DIR}/tokenizer_config.json"
427428

428429
# Export to .pte/.ptd (short cache dir avoids objcopy symbol length issues)
429430
echo "::group::Export"

.ci/scripts/setup-vulkan-linux-deps.sh

Lines changed: 121 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#!/bin/bash
32
# Copyright (c) Meta Platforms, Inc. and affiliates.
43
# All rights reserved.
@@ -22,7 +21,7 @@ install_swiftshader() {
2221
tar -C "${_swiftshader_dir}" -xzf "${_tmp_archive}"
2322

2423
export VK_ICD_FILENAMES="${_swiftshader_dir}/swiftshader/build/Linux/vk_swiftshader_icd.json"
25-
export LD_LIBRARY_PATH="${_swiftshader_dir}/swiftshader/build/Linux/"
24+
export LD_LIBRARY_PATH="${_swiftshader_dir}/swiftshader/build/Linux/:${LD_LIBRARY_PATH:-}"
2625
export ETVK_USING_SWIFTSHADER=1
2726
}
2827

@@ -43,7 +42,125 @@ install_vulkan_sdk() {
4342
export PATH="${PATH}:${_vulkan_sdk_dir}/${VULKAN_SDK_VERSION}/x86_64/bin/"
4443
}
4544

45+
_maybe_sudo() {
46+
if [ "$(id -u)" -eq 0 ]; then
47+
"$@"
48+
else
49+
sudo "$@"
50+
fi
51+
}
52+
53+
install_glslc() {
54+
# The glslc shipped in the LunarG SDK is dynamically linked against a newer
55+
# glibc/libstdc++ than the manylinux_2_28 / AlmaLinux 8 CUDA runner image
56+
# provides (glibc 2.28), where it fails to load with "GLIBC_2.29 not found".
57+
# conda-forge's shaderc is built against an old sysroot, runs there, and is
58+
# recent enough for the GL_EXT_integer_dot_product / GL_KHR_cooperative_matrix
59+
# extensions the Vulkan shaders use. Install it into an isolated prefix so the
60+
# base conda env that builds ExecuTorch is left untouched, then put it on PATH.
61+
_glslc_prefix=/tmp/shaderc
62+
conda create -y -p "${_glslc_prefix}" -c conda-forge shaderc
63+
export PATH="${_glslc_prefix}/bin:${PATH}"
64+
}
65+
66+
install_vulkan_loader() {
67+
# libvulkan.so.1 (the Khronos loader that volk dlopen()s at runtime) is not part
68+
# of the NVIDIA driver and is absent from the CUDA builder image; vulkan-tools
69+
# provides vulkaninfo for the device sanity check. Both ship as native el8 RPMs.
70+
if command -v dnf >/dev/null 2>&1; then
71+
_maybe_sudo dnf install -y vulkan-loader vulkan-tools
72+
fi
73+
}
74+
75+
_find_nvidia_vulkan_library() {
76+
# NVIDIA implements its Vulkan ICD inside libGLX_nvidia.so.0. The NVIDIA
77+
# container runtime mounts this library into the container (it is pulled from
78+
# the driver's ldcache when NVIDIA_DRIVER_CAPABILITIES includes graphics/all),
79+
# so prefer ldconfig and fall back to the usual mount locations.
80+
local lib cand
81+
lib="$(ldconfig -p 2>/dev/null | awk '/libGLX_nvidia\.so\.0/ {print $NF; exit}')"
82+
if [ -z "${lib}" ]; then
83+
for cand in /usr/lib64/libGLX_nvidia.so.0 \
84+
/usr/lib/x86_64-linux-gnu/libGLX_nvidia.so.0 \
85+
/usr/lib/libGLX_nvidia.so.0; do
86+
if [ -e "${cand}" ]; then
87+
lib="${cand}"
88+
break
89+
fi
90+
done
91+
fi
92+
printf '%s' "${lib}"
93+
}
94+
95+
_vulkan_has_real_device() {
96+
# True if the loader enumerates a hardware GPU. vulkaninfo can exit non-zero
97+
# for unrelated reasons (no display/WSI), so key off the reported deviceType.
98+
command -v vulkaninfo >/dev/null 2>&1 || return 0
99+
vulkaninfo --summary 2>/dev/null |
100+
grep -qE 'PHYSICAL_DEVICE_TYPE_(DISCRETE|INTEGRATED|VIRTUAL)_GPU'
101+
}
102+
103+
setup_real_gpu_icd() {
104+
# Select a Vulkan ICD so the runtime exercises the real GPU when one is usable.
105+
# Two quirks of the CUDA CI image make this non-trivial:
106+
# 1. The NVIDIA container runtime mounts the driver's Vulkan library but does
107+
# not register its ICD manifest, so the loader never discovers the GPU on
108+
# its own. We synthesize the manifest and pin the loader to it.
109+
# 2. Installing vulkan-loader/vulkan-tools pulls in mesa-vulkan-drivers,
110+
# which drop Intel/AMD/lavapipe manifests for absent hardware. lavapipe
111+
# fails vkCreateInstance on this image and, because the loader walks every
112+
# manifest in icd.d, that poisons device enumeration for the whole
113+
# process. Pinning VK_ICD_FILENAMES makes the loader ignore icd.d, so the
114+
# broken stubs cannot interfere.
115+
local nvidia_lib
116+
nvidia_lib="$(_find_nvidia_vulkan_library)"
117+
if [ -n "${nvidia_lib}" ]; then
118+
local icd=/tmp/nvidia_icd.json
119+
cat >"${icd}" <<JSON
120+
{
121+
"file_format_version": "1.0.0",
122+
"ICD": {
123+
"library_path": "${nvidia_lib}",
124+
"api_version": "1.3.0"
125+
}
126+
}
127+
JSON
128+
export VK_ICD_FILENAMES="${icd}"
129+
unset ETVK_USING_SWIFTSHADER || true
130+
if _vulkan_has_real_device; then
131+
echo "Real NVIDIA GPU selected; pinned Vulkan ICD to ${nvidia_lib}"
132+
return
133+
fi
134+
echo "WARNING: ${nvidia_lib} present but no GPU enumerated; using SwiftShader."
135+
# Surface why the NVIDIA driver did not enumerate (e.g. a missing dependency
136+
# of libGLX_nvidia, or no render node) so the fallback is diagnosable in CI.
137+
if command -v vulkaninfo >/dev/null 2>&1; then
138+
echo "--- NVIDIA Vulkan ICD diagnostic ---"
139+
VK_LOADER_DEBUG=warn vulkaninfo --summary 2>&1 | head -40 || true
140+
echo "--- end diagnostic ---"
141+
fi
142+
unset VK_ICD_FILENAMES
143+
else
144+
echo "WARNING: no NVIDIA Vulkan driver library found; using SwiftShader."
145+
fi
146+
install_swiftshader
147+
}
148+
46149
VULKAN_SDK_VERSION="1.4.321.1"
47150

48-
install_swiftshader
49-
install_vulkan_sdk "${VULKAN_SDK_VERSION}"
151+
# The no-argument default installs SwiftShader so the existing CPU-runner CI is
152+
# unchanged. Pass "real-gpu" to prefer a real system ICD when one is present.
153+
case "${1:-swiftshader}" in
154+
real-gpu)
155+
# Do not download the LunarG SDK here: its prebuilt glslc cannot run on the
156+
# old-glibc CUDA image. glslc comes from conda-forge and the loader from the
157+
# system package manager instead.
158+
install_vulkan_loader
159+
install_glslc
160+
setup_real_gpu_icd
161+
;;
162+
swiftshader | *)
163+
install_swiftshader
164+
install_vulkan_sdk "${VULKAN_SDK_VERSION}"
165+
;;
166+
esac
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# Install glslc (the Vulkan shader compiler) on Windows via conda-forge's
8+
# shaderc package, and make sure it is on PATH. glslc is the only build-time
9+
# Vulkan dependency -- the Vulkan headers and the volk loader come from the
10+
# in-tree submodules -- so this avoids depending on the heavyweight LunarG SDK
11+
# installer. Requires conda to be available (the callers create/activate an env).
12+
13+
$ErrorActionPreference = "Stop"
14+
15+
Write-Host "Installing shaderc (provides glslc) from conda-forge..."
16+
conda install -y -c conda-forge shaderc
17+
if ($LASTEXITCODE -ne 0) {
18+
Write-Error "Failed to install shaderc from conda-forge (exit ${LASTEXITCODE})"
19+
exit 1
20+
}
21+
22+
$glslc = Get-Command glslc -ErrorAction SilentlyContinue
23+
if (-not $glslc) {
24+
Write-Error "glslc not found on PATH after installing shaderc"
25+
exit 1
26+
}
27+
28+
# Expose glslc to the current process and, when running as a GitHub Actions step,
29+
# to subsequent steps.
30+
$glslcDir = Split-Path -Parent $glslc.Source
31+
$env:PATH = "${glslcDir};${env:PATH}"
32+
if ($env:GITHUB_PATH) {
33+
Add-Content -Path $env:GITHUB_PATH -Value $glslcDir
34+
}
35+
36+
Write-Host "glslc available at $($glslc.Source)"
37+
& glslc --version
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# Build-validation for the Vulkan backend under MSVC on Windows. Mirrors
8+
# setup-windows-msvc.ps1 but installs glslc (the Vulkan shader compiler) and
9+
# configures/builds the vulkan_backend target. This is a bring-up job: it exists
10+
# to surface MSVC portability issues in the Vulkan/volk/VMA code, so it may need
11+
# iteration.
12+
13+
conda create --yes --quiet -n et python=3.12
14+
conda activate et
15+
16+
# Install cmake
17+
conda install -y cmake
18+
19+
# Activate the VS environment - this is required for MSVC to work.
20+
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64
21+
22+
# Install glslc (via conda-forge shaderc) and put it on PATH in this process.
23+
.ci/scripts/setup-vulkan-windows-deps.ps1
24+
25+
# Install CI requirements
26+
pip install -r .ci/docker/requirements-ci.txt
27+
28+
$buildDir = "cmake-out-vulkan"
29+
if (Test-Path -Path $buildDir) {
30+
Remove-Item -Path $buildDir -Recurse -Force
31+
}
32+
New-Item -Path $buildDir -ItemType Directory
33+
34+
cmake -S . -B $buildDir `
35+
-DCMAKE_BUILD_TYPE=Release `
36+
-DEXECUTORCH_BUILD_VULKAN=ON `
37+
-DPYTHON_EXECUTABLE=python
38+
39+
if ($LASTEXITCODE -ne 0) {
40+
Write-Host "CMake configuration failed. Exit code: $LASTEXITCODE."
41+
exit $LASTEXITCODE
42+
}
43+
44+
cmake --build $buildDir --config Release --target vulkan_backend -j16
45+
46+
if ($LASTEXITCODE -ne 0) {
47+
Write-Host "Vulkan backend MSVC build failed. Exit code: $LASTEXITCODE."
48+
exit $LASTEXITCODE
49+
}
50+
51+
Write-Host "Vulkan backend MSVC build completed successfully!"

.ci/scripts/test_backend.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,15 @@ if [[ "$FLOW" == *qnn* ]]; then
5151
fi
5252

5353
if [[ "$FLOW" == *vulkan* ]]; then
54-
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate.
55-
source .ci/scripts/setup-vulkan-linux-deps.sh
54+
# Setup the Vulkan SDK and select an ICD: use the real system GPU ICD when one
55+
# is present (real-GPU runner), otherwise fall back to SwiftShader (CPU
56+
# runner). The Vulkan loader searches both standard ICD directories.
57+
if ls /etc/vulkan/icd.d/*.json /usr/share/vulkan/icd.d/*.json \
58+
>/dev/null 2>&1; then
59+
source .ci/scripts/setup-vulkan-linux-deps.sh "real-gpu"
60+
else
61+
source .ci/scripts/setup-vulkan-linux-deps.sh "swiftshader"
62+
fi
5663

5764
EXTRA_BUILD_ARGS+=" -DEXECUTORCH_BUILD_VULKAN=ON"
5865
fi

.ci/scripts/test_model_e2e.sh

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,4 +447,105 @@ case "$MODEL_NAME" in
447447
esac
448448
echo "::endgroup::"
449449

450+
if [ "$DEVICE" = "cuda" ] && [ "$MODEL_NAME" = "qwen3_5_moe" ]; then
451+
echo "::group::Run $MODEL_NAME OpenAI serving smoke"
452+
pip install -r examples/llm_server/python/requirements.txt "transformers==5.0.0rc1"
453+
python -m pip install --no-deps --no-build-isolation --editable . -v
454+
455+
PORT=$(python - <<'PY'
456+
import socket
457+
458+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
459+
s.bind(("127.0.0.1", 0))
460+
print(s.getsockname()[1])
461+
PY
462+
)
463+
SERVER_LOG=$(mktemp)
464+
WORKER_BIN="cmake-out/examples/models/qwen3_5_moe/qwen3_5_moe_worker"
465+
python -u -m executorch.examples.models.qwen3_5_moe.serve \
466+
--model-path "${MODEL_DIR}/model.pte" \
467+
--data-path "${MODEL_DIR}/aoti_cuda_blob.ptd" \
468+
--tokenizer-path "${MODEL_DIR}/tokenizer.json" \
469+
--hf-tokenizer "${MODEL_DIR}" \
470+
--model-id qwen3.5-moe \
471+
--max-context 4096 \
472+
--max-sessions 2 \
473+
--no-think \
474+
--worker-bin "$WORKER_BIN" \
475+
--host 127.0.0.1 \
476+
--port "$PORT" >"$SERVER_LOG" 2>&1 &
477+
SERVER_PID=$!
478+
479+
cleanup_qwen_server() {
480+
if kill -0 "$SERVER_PID" 2>/dev/null; then
481+
kill "$SERVER_PID" 2>/dev/null || true
482+
wait "$SERVER_PID" 2>/dev/null || true
483+
fi
484+
rm -f "$SERVER_LOG"
485+
}
486+
trap cleanup_qwen_server EXIT
487+
488+
if ! python - "$PORT" "$SERVER_LOG" <<'PY'
489+
import json
490+
import sys
491+
import time
492+
import urllib.request
493+
494+
port = sys.argv[1]
495+
log_path = sys.argv[2]
496+
base = f"http://127.0.0.1:{port}"
497+
498+
499+
def request(path, payload=None):
500+
data = None
501+
headers = {}
502+
if payload is not None:
503+
data = json.dumps(payload).encode("utf-8")
504+
headers["Content-Type"] = "application/json"
505+
req = urllib.request.Request(base + path, data=data, headers=headers)
506+
with urllib.request.urlopen(req, timeout=120) as resp:
507+
return json.loads(resp.read().decode("utf-8"))
508+
509+
510+
last = None
511+
for _ in range(180):
512+
try:
513+
request("/health")
514+
break
515+
except Exception as e:
516+
last = e
517+
time.sleep(1)
518+
else:
519+
print(open(log_path, encoding="utf-8", errors="replace").read())
520+
raise RuntimeError(f"server did not become healthy: {last}")
521+
522+
models = request("/v1/models")
523+
ids = {m["id"] for m in models["data"]}
524+
if "qwen3.5-moe" not in ids:
525+
raise AssertionError(f"qwen3.5-moe missing from /v1/models: {ids}")
526+
527+
body = {
528+
"model": "qwen3.5-moe",
529+
"messages": [{"role": "user", "content": "What is the capital of France?"}],
530+
"max_tokens": 32,
531+
"temperature": 0,
532+
}
533+
resp = request("/v1/chat/completions", body)
534+
content = resp["choices"][0]["message"].get("content") or ""
535+
if "Paris" not in content:
536+
raise AssertionError(f"expected Paris in serving response, got: {content!r}")
537+
538+
print("Qwen3.5-MoE serving smoke passed")
539+
PY
540+
then
541+
echo "Qwen3.5-MoE serving smoke failed; server log:"
542+
cat "$SERVER_LOG"
543+
exit 1
544+
fi
545+
546+
cleanup_qwen_server
547+
trap - EXIT
548+
echo "::endgroup::"
549+
fi
550+
450551
popd

0 commit comments

Comments
 (0)