Skip to content

Commit 3330024

Browse files
authored
Merge branch 'main' into arm-backend-vgf-kv-cache-export-aliasing
2 parents 4772018 + 3d5172b commit 3330024

1,233 files changed

Lines changed: 111266 additions & 41385 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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ fi
116116
# Copy requirements-lintrunner.txt from root to here
117117
cp ../../requirements-lintrunner.txt ./
118118

119+
# Copy the Arm setup scripts that pin the FVP and toolchain downloads
120+
mkdir -p arm-setup
121+
cp ../../backends/arm/scripts/{utils,fvp_utils,toolchain_utils}.sh arm-setup/
122+
119123
# OSDC runners have no docker daemon, so the build runs on the in-cluster
120124
# BuildKit pool via a remote buildx builder. That builder has nowhere to load
121125
# an image into, so the result has to go straight to the registry.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
# Cache the developer.arm.com downloads of examples/arm/setup.sh, so CI jobs
9+
# copy them from ARM_SETUP_DOWNLOAD_CACHE instead of fetching them each run.
10+
# Jobs download whatever is missing, so a failed download only costs the cache.
11+
12+
set -exu
13+
14+
ARCH="$(uname -m)"
15+
OS="$(uname -s)"
16+
ARM_SETUP_CURL_PROGRESS_ARGS=(--no-progress-meter)
17+
# Fill the cache rather than read from it
18+
cache_dir="${ARM_SETUP_DOWNLOAD_CACHE}"
19+
unset ARM_SETUP_DOWNLOAD_CACHE
20+
source ./arm-setup/fvp_utils.sh
21+
source ./arm-setup/toolchain_utils.sh
22+
23+
cache_download() {
24+
local url=$1
25+
local md5=$2
26+
local output="${cache_dir}/$(basename "${url}")"
27+
download_with_retry "cache" "${url}" "${output}" "${md5}" || rm -f "${output}"
28+
}
29+
30+
mkdir -p "${cache_dir}"
31+
cache_download "${corstone300_url}" "${corstone300_md5_checksum}"
32+
cache_download "${corstone320_url}" "${corstone320_md5_checksum}"
33+
gcc_select_toolchain
34+
cache_download "${toolchain_url}" "${toolchain_md5_checksum}"

‎.ci/docker/requirements-ci.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ torchsr==1.0.4
99
transformers==5.3.0
1010
zstd==1.5.5.1
1111
pandas>=2.2.2; python_version >= '3.10'
12-
pytest==7.2.0
12+
pytest==7.3.0
1313
pytest-cov==4.1.0
1414
expecttest==0.1.6
1515
hypothesis==6.84.2

‎.ci/docker/ubuntu/Dockerfile‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ COPY ./common/utils.sh utils.sh
103103
RUN if [ -n "${ZEPHYR_SDK}" ]; then bash ./install_zephyr.sh; fi
104104
RUN rm install_zephyr.sh zephyr_sdk_release_proxy.py utils.sh
105105

106+
# Cache the developer.arm.com downloads of examples/arm/setup.sh, which the
107+
# Arm and Zephyr jobs run.
108+
ENV ARM_SETUP_DOWNLOAD_CACHE=/opt/arm-download-cache
109+
COPY ./common/install_arm_downloads.sh install_arm_downloads.sh
110+
COPY ./arm-setup arm-setup
111+
RUN if [ -n "${ARM_SDK}${ZEPHYR_SDK}" ]; then \
112+
bash ./install_arm_downloads.sh || echo "Arm download cache not populated"; \
113+
fi
114+
RUN rm -r install_arm_downloads.sh arm-setup
115+
106116
ARG QNN_SDK
107117

108118
ARG MEDIATEK_SDK

‎.ci/scripts/download_hf_hub.sh‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ export HF_HUB_DISABLE_XET=1
77
# Arguments:
88
# 1. model_id: The Hugging Face repository ID (e.g., "organization/model_name")
99
# 2. subdir: The optional subdirectory in the repo to look for files (pass "" if not used)
10-
# 3. file_names: A space-separated list of filenames to be downloaded
10+
# 3. revision: The commit hash to download
11+
# 4. file_names: A space-separated list of filenames to be downloaded
1112
# Returns:
1213
# The directory containing the downloaded files
1314
function download_hf_files() {
1415
local model_id="$1"
1516
local subdir="$2"
16-
shift 2
17+
local revision="$3"
18+
shift 3
1719
local file_names=("$@") # Capture all remaining arguments as an array
1820

1921
local download_dir
@@ -24,7 +26,8 @@ from huggingface_hub import hf_hub_download
2426
# Download the first file and get its directory
2527
path = hf_hub_download(
2628
repo_id='${model_id}',
27-
filename='${subdir:+${subdir}/}${file_names[0]}'
29+
filename='${subdir:+${subdir}/}${file_names[0]}',
30+
revision='${revision}'
2831
)
2932
import os
3033
print(os.path.dirname(path))")
@@ -41,7 +44,8 @@ from huggingface_hub import hf_hub_download
4144
# Download the file
4245
hf_hub_download(
4346
repo_id='${model_id}',
44-
filename='${subdir:+${subdir}/}${file_name}'
47+
filename='${subdir:+${subdir}/}${file_name}',
48+
revision='${revision}'
4549
)"
4650

4751
if [ $? -ne 0 ]; then
@@ -67,6 +71,10 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
6771
SUBDIR="$2"
6872
shift 2
6973
;;
74+
--revision)
75+
REVISION="$2"
76+
shift 2
77+
;;
7078
--files)
7179
shift
7280
FILES_TO_DOWNLOAD=()
@@ -83,13 +91,13 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
8391
done
8492

8593
# Validate required arguments
86-
if [ -z "$MODEL_ID" ] || [ ${#FILES_TO_DOWNLOAD[@]} -eq 0 ]; then
87-
echo "Usage: $0 --model_id <model_id> --subdir <subdir> --files <file1> [<file2> ...]" >&2
94+
if [ -z "$MODEL_ID" ] || [ -z "$REVISION" ] || [ ${#FILES_TO_DOWNLOAD[@]} -eq 0 ]; then
95+
echo "Usage: $0 --model_id <model_id> --revision <commit> --subdir <subdir> --files <file1> [<file2> ...]" >&2
8896
exit 1
8997
fi
9098

9199
# Call the function
92-
DOWNLOAD_DIR=$(download_hf_files "$MODEL_ID" "$SUBDIR" "${FILES_TO_DOWNLOAD[@]}")
100+
DOWNLOAD_DIR=$(download_hf_files "$MODEL_ID" "$SUBDIR" "$REVISION" "${FILES_TO_DOWNLOAD[@]}")
93101
if [ $? -eq 0 ]; then
94102
echo "$DOWNLOAD_DIR"
95103
else

‎.ci/scripts/export_model_artifact.sh‎

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Arguments:
5050
- vr-streaming: Voxtral Realtime streaming mode
5151
- vr-offline: Voxtral Realtime offline mode
5252
- solo-text: Muse Glimmer solo text mode
53-
- solo-text-batching: Muse Glimmer text on the CUDA batching runtime
53+
- dflash-image-batching: Muse Glimmer DFlash text and image on the CUDA batching runtime
5454
- dflash-image: Muse Glimmer DFlash vision mode
5555
5656
Examples:
@@ -105,7 +105,7 @@ if [ -n "$MODE" ]; then
105105
exit 1
106106
fi
107107
;;
108-
solo-text|solo-text-batching|dflash-image)
108+
solo-text|dflash-image-batching|dflash-image)
109109
if [ "$HF_MODEL" != "meta-models/Muse-Glimmer-30B-GGUF" ]; then
110110
echo "Error: Mode '$MODE' can only be used with Muse Glimmer model"
111111
echo "Provided model: $HF_MODEL"
@@ -114,7 +114,7 @@ if [ -n "$MODE" ]; then
114114
;;
115115
*)
116116
echo "Error: Unsupported mode '$MODE'"
117-
echo "Supported modes: vr-streaming, vr-offline, solo-text, solo-text-batching, dflash-image"
117+
echo "Supported modes: vr-streaming, vr-offline, solo-text, dflash-image-batching, dflash-image"
118118
exit 1
119119
;;
120120
esac
@@ -354,8 +354,8 @@ if [ "$MODEL_NAME" = "muse_glimmer" ]; then
354354
echo "Error: Muse Glimmer requires quantization 'kquant-17gb' or 'kquant-dynamic'"
355355
exit 1
356356
fi
357-
if [ "$MODE" != "solo-text" ] && [ "$MODE" != "solo-text-batching" ] && [ "$MODE" != "dflash-image" ]; then
358-
echo "Error: Muse Glimmer requires mode 'solo-text', 'solo-text-batching' or 'dflash-image'"
357+
if [ "$MODE" != "solo-text" ] && [ "$MODE" != "dflash-image-batching" ] && [ "$MODE" != "dflash-image" ]; then
358+
echo "Error: Muse Glimmer requires mode 'solo-text', 'dflash-image-batching' or 'dflash-image'"
359359
exit 1
360360
fi
361361
fi
@@ -707,23 +707,17 @@ if [ "$MODEL_NAME" = "muse_glimmer" ]; then
707707
--backend cuda \
708708
--output-dir "${OUTPUT_DIR}"
709709
;;
710-
solo-text-batching)
711-
# The off-graph cache exports the batching methods CudaExecutor drives:
712-
# Static forward_{N}, dynamic forward_others and the device samplers.
713-
EXPORT_START_SECONDS=$SECONDS
714-
TMPDIR="$INDUCTOR_TMPDIR" \
715-
TORCHINDUCTOR_CACHE_DIR="$INDUCTOR_CACHE" \
716-
python -m executorch.examples.models.muse_glimmer.export.export_solo \
717-
--gguf "$TARGET_GGUF_PATH" \
718-
--backend cuda \
719-
--use-offgraph-kv-cache \
720-
--output-dir "${OUTPUT_DIR}"
721-
;;
722-
dflash-image)
710+
dflash-image|dflash-image-batching)
723711
DRAFT_GGUF_FILE="dflash-Muse-Glimmer-30B-Q4_K_M.gguf"
724712
MMPROJ_GGUF_FILE="mmproj-Muse-Glimmer-30B-Q4_K_M.gguf"
725713
python -c "from huggingface_hub import hf_hub_download; hf_hub_download('${HF_MODEL}', '${DRAFT_GGUF_FILE}', local_dir='${LOCAL_MODEL_DIR}')"
726714
python -c "from huggingface_hub import hf_hub_download; hf_hub_download('${HF_MODEL}', '${MMPROJ_GGUF_FILE}', local_dir='${LOCAL_MODEL_DIR}')"
715+
# The off-graph cache exports the batching methods the CUDA DFlash
716+
# executor drives, plus the vision encoder and forward_from_embeddings.
717+
OFFGRAPH_FLAG=""
718+
if [ "$MODE" = "dflash-image-batching" ]; then
719+
OFFGRAPH_FLAG="--use-offgraph-kv-cache"
720+
fi
727721
EXPORT_START_SECONDS=$SECONDS
728722
TMPDIR="$INDUCTOR_TMPDIR" \
729723
TORCHINDUCTOR_CACHE_DIR="$INDUCTOR_CACHE" \
@@ -732,10 +726,11 @@ if [ "$MODEL_NAME" = "muse_glimmer" ]; then
732726
--draft-gguf "${LOCAL_MODEL_DIR}/${DRAFT_GGUF_FILE}" \
733727
--mmproj "${LOCAL_MODEL_DIR}/${MMPROJ_GGUF_FILE}" \
734728
--backend cuda \
729+
$OFFGRAPH_FLAG \
735730
--output-dir "${OUTPUT_DIR}"
736731
;;
737732
*)
738-
echo "Error: Muse Glimmer requires mode 'solo-text', 'solo-text-batching' or 'dflash-image'"
733+
echo "Error: Muse Glimmer requires mode 'solo-text', 'dflash-image-batching' or 'dflash-image'"
739734
exit 1
740735
;;
741736
esac
@@ -746,7 +741,7 @@ if [ "$MODEL_NAME" = "muse_glimmer" ]; then
746741

747742
test -f "${OUTPUT_DIR}/model.pte"
748743
test -f "${OUTPUT_DIR}/aoti_cuda_blob.ptd"
749-
if [ "$MODE" = "dflash-image" ]; then
744+
if [ "$MODE" = "dflash-image" ] || [ "$MODE" = "dflash-image-batching" ]; then
750745
test -f "${OUTPUT_DIR}/pos_embed.bin"
751746
fi
752747
ls -al "${OUTPUT_DIR}"

‎.ci/scripts/muse_glimmer_batching_smoke.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ DECLARE_string(pte);
2020
DECLARE_string(tokenizer);
2121
DECLARE_string(data_path);
2222
DECLARE_string(backend);
23+
DECLARE_bool(dflash);
2324
DECLARE_int32(max_sessions);
2425
DECLARE_int32(max_session_tokens);
2526
DECLARE_uint64(bos_id);
@@ -64,6 +65,7 @@ int main(int argc, char** argv) {
6465
config.max_sessions = FLAGS_max_sessions;
6566
config.max_session_tokens = FLAGS_max_session_tokens;
6667
config.bos_id = FLAGS_bos_id;
68+
config.use_dflash = FLAGS_dflash;
6769
auto backend = llm::create_muse_glimmer_backend(config);
6870
if (!backend.ok()) {
6971
throw std::runtime_error(

‎.ci/scripts/test-native.sh‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@ case "${component}" in
2020
test_regex='^native_runtime_test$'
2121
;;
2222
cpu)
23+
# The CPU plan test covers ETDump tracing, including operator shapes.
2324
cmake_args+=(
2425
-DEXECUTORCH_BUILD_NATIVE_CPU=ON
2526
-DEXECUTORCH_BUILD_XNNPACK=ON
2627
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON
2728
-DEXECUTORCH_BUILD_NATIVE_VISION_RUNNER=ON
29+
-DEXECUTORCH_BUILD_DEVTOOLS=ON
30+
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON
31+
-DEXECUTORCH_CPU_XNNPACK_OPERATOR_SHAPES=ON
2832
)
29-
targets+=(native_cpu_engine_test run_classification_cpu)
30-
test_regex='^native_cpu_engine_test$'
33+
targets+=(native_cpu_engine_test cpu_plan_test run_classification_cpu)
34+
test_regex='^(native_cpu_engine|cpu_plan)_test$'
3135
;;
3236
ggml)
3337
cmake_args+=(
@@ -36,8 +40,9 @@ case "${component}" in
3640
-DEXECUTORCH_BUILD_NATIVE_VISION_RUNNER=ON
3741
-DGGML_NATIVE=OFF
3842
)
39-
targets+=(run_hf_llm_ggml native_ggml_engine_test native_llm_runner_utils_test run_classification_ggml_cpu)
40-
test_regex='^native_(ggml_engine|llm_runner_utils)_test$'
43+
# TODO: run the other sample tests once they pass.
44+
targets+=(run_hf_llm_ggml native_ggml_engine_test native_llm_runner_utils_test run_classification_ggml_cpu native_output_check_test native_ggml_sample_test)
45+
test_regex='^native_(ggml_engine|llm_runner_utils|output_check)_test$|^native_ggml_sample_test_act_quant$'
4146
;;
4247
vulkan)
4348
cmake_args+=(
@@ -67,7 +72,7 @@ cmake -S . -B "${build_dir}" -G Ninja \
6772
cmake --build "${build_dir}" \
6873
--parallel "${build_jobs}" \
6974
--target "${targets[@]}"
70-
ctest --test-dir "${build_dir}/backends/native/test" \
75+
ctest --test-dir "${build_dir}" \
7176
-R "${test_regex}" --output-on-failure --no-tests=error --timeout 120
7277

7378
if [[ "${component}" == "ggml" ]]; then

‎.ci/scripts/test_backend.sh‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,13 @@ if [[ "$FLOW" == *arm* ]]; then
7676
PYTEST_RETRY_ARGS=(--reruns 2 --reruns-delay 1)
7777
fi
7878

79-
# Setup ARM deps.
79+
# Setup ARM deps. Only the Ethos-U flows run on an FVP.
8080
if [[ "$FLOW" == *vgf* ]]; then
81-
.ci/scripts/setup-arm-baremetal-tools.sh --enable-mlsdk-deps --install-mlsdk-deps-with-pip
82-
else
81+
.ci/scripts/setup-arm-baremetal-tools.sh --disable-ethos-u-deps --enable-mlsdk-deps --install-mlsdk-deps-with-pip
82+
elif [[ "$FLOW" == *ethos_u* ]]; then
8383
.ci/scripts/setup-arm-baremetal-tools.sh
84+
else
85+
.ci/scripts/setup-arm-baremetal-tools.sh --disable-ethos-u-deps
8486
fi
8587
source examples/arm/arm-scratch/setup_path.sh
8688

@@ -98,7 +100,7 @@ fi
98100
if [[ "$FLOW" == *cortex_m* ]]; then
99101
# Cortex-M runs on the Corstone-300 FVP, using the same Arm toolchain as the
100102
# Ethos-U flows but its own semihosting runner.
101-
.ci/scripts/setup-arm-baremetal-tools.sh
103+
.ci/scripts/setup-arm-baremetal-tools.sh --fvp corstone300
102104
source examples/arm/arm-scratch/setup_path.sh
103105

104106
backends/cortex_m/test/build_test_runner.sh

‎.ci/scripts/test_cuda_runtime_windows.ps1‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ $tests = @(
3434
"test_cuda_mutable_state",
3535
"test_cuda_weight_cache",
3636
"test_cuda_output_copy",
37+
"test_cuda_backend_execute",
3738
"test_cuda_sort_rand",
39+
"test_cuda_current_stream",
3840
"test_cuda_guard",
3941
"test_cuda_stream_guard"
4042
)

0 commit comments

Comments
 (0)