Skip to content

Commit e6186c3

Browse files
author
ssjia
committed
Update base for Update on "[ET][jni] Provide opt-out config for vulkan backend dependency"
## Context IGVR can't use downloadable modules so an opt out path is required to avoid regressing APK size from including the vulkan backend. Differential Revision: [D86547777](https://our.internmc.facebook.com/intern/diff/D86547777/) cc manuelcandales digantdesai cbilgin [ghstack-poisoned]
2 parents e4aba1e + aba44fd commit e6186c3

File tree

21 files changed

+236
-255
lines changed

21 files changed

+236
-255
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4361747abfc55e40e929396ed986efe775d745f9
1+
d03e90c2cd9048e6d9a75285c0355f033cd016fc

.ci/scripts/export_model_cuda_artifact.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Arguments:
1717
hf_model HuggingFace model ID (required)
1818
Supported models:
1919
- mistralai/Voxtral-Mini-3B-2507
20-
- openai/whisper-small
20+
- openai/whisper series (whisper-{small, medium, large, large-v2, large-v3, large-v3-turbo})
2121
- google/gemma-3-4b-it
2222
2323
quant_name Quantization type (optional, default: non-quantized)
@@ -62,13 +62,17 @@ case "$HF_MODEL" in
6262
PREPROCESSOR_FEATURE_SIZE="128"
6363
PREPROCESSOR_OUTPUT="voxtral_preprocessor.pte"
6464
;;
65-
openai/whisper-small)
65+
openai/whisper-*)
6666
MODEL_NAME="whisper"
6767
TASK="automatic-speech-recognition"
6868
MAX_SEQ_LEN=""
6969
EXTRA_PIP="librosa"
70-
PREPROCESSOR_FEATURE_SIZE="80"
7170
PREPROCESSOR_OUTPUT="whisper_preprocessor.pte"
71+
if [[ "$HF_MODEL" == *"large-v3"* ]]; then
72+
PREPROCESSOR_FEATURE_SIZE="128"
73+
else
74+
PREPROCESSOR_FEATURE_SIZE="80"
75+
fi
7276
;;
7377
google/gemma-3-4b-it)
7478
MODEL_NAME="gemma3"
@@ -80,7 +84,7 @@ case "$HF_MODEL" in
8084
;;
8185
*)
8286
echo "Error: Unsupported model '$HF_MODEL'"
83-
echo "Supported models: mistralai/Voxtral-Mini-3B-2507, openai/whisper-small, google/gemma-3-4b-it"
87+
echo "Supported models: mistralai/Voxtral-Mini-3B-2507, openai/whisper-{small, medium, large, large-v2, large-v3, large-v3-turbo}, google/gemma-3-4b-it"
8488
exit 1
8589
;;
8690
esac

.ci/scripts/test_model_cuda_e2e.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Arguments:
1717
hf_model HuggingFace model ID (required)
1818
Supported models:
1919
- mistralai/Voxtral-Mini-3B-2507
20-
- openai/whisper-small
20+
- openai/whisper series (whisper-{small, medium, large, large-v2, large-v3, large-v3-turbo})
2121
- google/gemma-3-4b-it
2222
2323
quant_name Quantization type (required)
@@ -91,13 +91,13 @@ case "$HF_MODEL" in
9191
AUDIO_FILE="poem.wav"
9292
IMAGE_PATH=""
9393
;;
94-
openai/whisper-small)
95-
MODEL_NAME="whisper"
94+
openai/whisper-*)
95+
MODEL_NAME="${HF_MODEL#openai/}"
9696
RUNNER_TARGET="whisper_runner"
9797
RUNNER_PATH="whisper"
9898
EXPECTED_OUTPUT="Mr. Quilter is the apostle of the middle classes"
9999
PREPROCESSOR="whisper_preprocessor.pte"
100-
TOKENIZER_URL="https://huggingface.co/openai/whisper-small/resolve/main" # @lint-ignore
100+
TOKENIZER_URL="https://huggingface.co/${HF_MODEL}/resolve/main" # @lint-ignore
101101
TOKENIZER_FILE=""
102102
AUDIO_URL=""
103103
AUDIO_FILE="output.wav"
@@ -117,7 +117,7 @@ case "$HF_MODEL" in
117117
;;
118118
*)
119119
echo "Error: Unsupported model '$HF_MODEL'"
120-
echo "Supported models: mistralai/Voxtral-Mini-3B-2507, openai/whisper-small, google/gemma-3-4b-it"
120+
echo "Supported models: mistralai/Voxtral-Mini-3B-2507, openai/whisper series (whisper-{small, medium, large, large-v2, large-v3, large-v3-turbo}), google/gemma-3-4b-it"
121121
exit 1
122122
;;
123123
esac
@@ -142,7 +142,7 @@ fi
142142
# Download test files
143143
if [ "$AUDIO_URL" != "" ]; then
144144
curl -L $AUDIO_URL -o ${MODEL_DIR}/$AUDIO_FILE
145-
elif [ "$MODEL_NAME" = "whisper" ]; then
145+
elif [[ "$MODEL_NAME" == *whisper* ]]; then
146146
conda install -y -c conda-forge "ffmpeg<8"
147147
pip install datasets soundfile torchcodec
148148
python -c "from datasets import load_dataset;import soundfile as sf;sample = load_dataset('distil-whisper/librispeech_long', 'clean', split='validation')[0]['audio'];sf.write('${MODEL_DIR}/$AUDIO_FILE', sample['array'][:sample['sampling_rate']*30], sample['sampling_rate'])"
@@ -179,8 +179,8 @@ case "$MODEL_NAME" in
179179
voxtral)
180180
RUNNER_ARGS="$RUNNER_ARGS --tokenizer_path ${MODEL_DIR}/$TOKENIZER_FILE --audio_path ${MODEL_DIR}/$AUDIO_FILE --processor_path ${MODEL_DIR}/$PREPROCESSOR"
181181
;;
182-
whisper)
183-
RUNNER_ARGS="$RUNNER_ARGS --tokenizer_path ${MODEL_DIR}/ --audio_path ${MODEL_DIR}/$AUDIO_FILE --processor_path ${MODEL_DIR}/$PREPROCESSOR"
182+
whisper-*)
183+
RUNNER_ARGS="$RUNNER_ARGS --tokenizer_path ${MODEL_DIR}/ --audio_path ${MODEL_DIR}/$AUDIO_FILE --processor_path ${MODEL_DIR}/$PREPROCESSOR --model_name ${MODEL_NAME}"
184184
;;
185185
gemma3)
186186
RUNNER_ARGS="$RUNNER_ARGS --tokenizer_path ${MODEL_DIR}/ --image_path $IMAGE_PATH"

.github/workflows/cuda.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ jobs:
104104
name: "Voxtral-Mini-3B-2507"
105105
- repo: "openai"
106106
name: "whisper-small"
107+
- repo: "openai"
108+
name: "whisper-large-v3-turbo"
107109
- repo: "google"
108110
name: "gemma-3-4b-it"
109111
quant:
@@ -223,6 +225,8 @@ jobs:
223225
name: "Voxtral-Mini-3B-2507"
224226
- repo: "openai"
225227
name: "whisper-small"
228+
- repo: "openai"
229+
name: "whisper-large-v3-turbo"
226230
- repo: "google"
227231
name: "gemma-3-4b-it"
228232
quant:

backends/arm/CMakeLists.txt

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -48,44 +48,17 @@ endif()
4848

4949
# VGF backend builds
5050
if(EXECUTORCH_BUILD_VGF)
51+
52+
# include libvgf
53+
set(LIBVGF_PATH
54+
"${EXECUTORCH_ROOT}/examples/arm/ethos-u-scratch/ml-sdk-for-vulkan-manifest/sw/vgf-lib/"
55+
)
56+
5157
set(VULKAN_THIRD_PARTY_PATH ${EXECUTORCH_ROOT}/backends/vulkan/third-party)
5258
set(VULKAN_HEADERS_PATH ${VULKAN_THIRD_PARTY_PATH}/Vulkan-Headers/include)
5359
set(VOLK_HEADERS_PATH ${VULKAN_THIRD_PARTY_PATH}/volk)
5460

55-
if(APPLE
56-
OR CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$"
57-
OR EXISTS
58-
"${EXECUTORCH_ROOT}/examples/arm/ethos-u-scratch/ml-sdk-for-vulkan-manifest/"
59-
)
60-
message(STATUS "libvgf sourced from local scratch tree")
61-
62-
# Legacy layout: libvgf sourced from local scratch tree
63-
set(LIBVGF_PATH
64-
"${EXECUTORCH_ROOT}/examples/arm/ethos-u-scratch/ml-sdk-for-vulkan-manifest/sw/vgf-lib/"
65-
)
66-
set(LIBVGF_STATIC "${LIBVGF_PATH}/build/src/libvgf.a")
67-
else()
68-
message(STATUS "libvgf installed from pip package")
69-
70-
set(Python3_FIND_VIRTUALENV FIRST)
71-
if(EXECUTORCH_ROOT AND EXISTS "${EXECUTORCH_ROOT}/env")
72-
set(Python3_EXECUTABLE "${EXECUTORCH_ROOT}/env/bin/python3")
73-
endif()
74-
75-
find_package(Python3 REQUIRED COMPONENTS Interpreter)
76-
77-
# Prefer arch-specific site-packages if present, else pure
78-
set(_vgf_site_arch "${Python3_SITEARCH}/vgf_lib/binaries")
79-
set(_vgf_site_pure "${Python3_SITELIB}/vgf_lib/binaries")
80-
if(EXISTS "${_vgf_site_arch}")
81-
set(LIBVGF_PATH "${_vgf_site_arch}")
82-
else()
83-
set(LIBVGF_PATH "${_vgf_site_pure}")
84-
endif()
85-
86-
set(LIBVGF_STATIC "${LIBVGF_PATH}/lib/libvgf.a")
87-
endif()
88-
61+
set(LIBVGF_STATIC "${LIBVGF_PATH}/build/src/libvgf.a")
8962
set(LIBVGF_INCLUDE "${LIBVGF_PATH}/include/")
9063

9164
add_library(vgf STATIC IMPORTED)

backends/arm/requirements-arm-vgf.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

backends/arm/scripts/mlsdk_utils.sh

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -205,51 +205,7 @@ function setup_path_emulation_layer() {
205205
model_emulation_layer_path="$(cd "${mlsdk_manifest_dir}/sw/emulation-layer/" && pwd)"
206206
prepend_env_in_setup_path LD_LIBRARY_PATH "${model_emulation_layer_path}/deploy/lib"
207207
prepend_env_in_setup_path DYLD_LIBRARY_PATH "${model_emulation_layer_path}/deploy/lib"
208-
prepend_env_in_setup_path VK_LAYER_PATH "${model_emulation_layer_path}/deploy/share/vulkan/explicit_layer.d"
209208
prepend_env_in_setup_path VK_INSTANCE_LAYERS VK_LAYER_ML_Tensor_Emulation
210209
prepend_env_in_setup_path VK_INSTANCE_LAYERS VK_LAYER_ML_Graph_Emulation
211-
}
212-
213-
function setup_path_emulation_layer_from_pip() {
214-
if ! command -v emulation_layer >/dev/null 2>&1; then
215-
echo "[mlsdk_utils] 'emulation_layer' command not found; skipping pip emulation layer path setup"
216-
return
217-
fi
218-
219-
local output
220-
if ! output=$(emulation_layer 2>/dev/null); then
221-
echo "[mlsdk_utils] Failed to query emulation_layer environment; skipping"
222-
return
223-
fi
224-
225-
local exports
226-
exports=$(echo "$output" | grep '^export ' || true)
227-
228-
local ld_line
229-
ld_line=$(echo "$exports" | grep 'LD_LIBRARY_PATH=' || true)
230-
if [[ -n "${ld_line}" ]]; then
231-
local ld_value=${ld_line#export LD_LIBRARY_PATH=}
232-
ld_value=${ld_value%%:\$LD_LIBRARY_PATH*}
233-
if [[ -n "${ld_value}" ]]; then
234-
prepend_env_in_setup_path LD_LIBRARY_PATH "${ld_value}"
235-
fi
236-
fi
237-
238-
local vk_add_line
239-
vk_add_line=$(echo "$exports" | grep 'VK_ADD_LAYER_PATH=' || true)
240-
if [[ -n "${vk_add_line}" ]]; then
241-
local vk_add_value=${vk_add_line#export VK_ADD_LAYER_PATH=}
242-
if [[ -n "${vk_add_value}" ]]; then
243-
prepend_env_in_setup_path VK_ADD_LAYER_PATH "${vk_add_value}"
244-
fi
245-
fi
246-
247-
local vk_instance_line
248-
vk_instance_line=$(echo "$exports" | grep 'VK_INSTANCE_LAYERS=' || true)
249-
if [[ -n "${vk_instance_line}" ]]; then
250-
local vk_instance_value=${vk_instance_line#export VK_INSTANCE_LAYERS=}
251-
if [[ -n "${vk_instance_value}" ]]; then
252-
prepend_env_in_setup_path VK_INSTANCE_LAYERS "${vk_instance_value}"
253-
fi
254-
fi
210+
prepend_env_in_setup_path VK_LAYER_PATH "${model_emulation_layer_path}/deploy/share/vulkan/explicit_layer.d"
255211
}

backends/arm/scripts/run_vkml.sh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,9 @@ if [[ -z ${model} ]]; then echo "Model name needs to be provided"; exit 1; fi
5050

5151
source ${setup_path_script}
5252

53-
if ! command -v "${converter}" >/dev/null 2>&1; then
54-
if command -v model_converter >/dev/null 2>&1; then
55-
converter="model_converter"
56-
fi
57-
fi
58-
59-
command -v "${converter}" >/dev/null 2>&1 \
60-
|| { echo "Could not find a model converter executable (tried model-converter, model_converter). ${_setup_msg}"; exit 1; }
53+
# basic checks before we get started
54+
hash ${converter} \
55+
|| { echo "Could not find ${converter} on PATH, ${_setup_msg}"; exit 1; }
6156

6257

6358

backends/arm/test/ops/test_rsqrt.py

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,23 @@
88

99
from typing import Tuple
1010

11+
import pytest
1112
import torch
13+
from executorch.backends.arm.quantizer.arm_quantizer import (
14+
get_symmetric_a16w8_quantization_config,
15+
TOSAQuantizer,
16+
)
17+
from executorch.backends.arm.test import common, conftest
1218

13-
from executorch.backends.arm.test import common
1419
from executorch.backends.arm.test.tester.test_pipeline import (
1520
EthosU55PipelineINT,
1621
EthosU85PipelineINT,
1722
TosaPipelineFP,
1823
TosaPipelineINT,
1924
VgfPipeline,
2025
)
21-
26+
from executorch.backends.arm.tosa import TosaSpecification
27+
from executorch.backends.xnnpack.test.tester import Quantize
2228

2329
aten_op = "torch.ops.aten.rsqrt.default"
2430
input_t1 = Tuple[torch.Tensor] # Input x
@@ -104,3 +110,99 @@ def test_rsqrt_vgf_INT(test_tensor: torch.Tensor):
104110
tosa_version="TOSA-1.0+INT",
105111
)
106112
pipeline.run()
113+
114+
115+
def get_symmetric_a16w8_rsqrt_quantizer(
116+
u55_config=False, per_channel_quantization=False
117+
):
118+
tosa_version = conftest.get_option("tosa_version")
119+
tosa_profiles = {
120+
"1.0": TosaSpecification.create_from_string("TOSA-1.0+INT+int16"),
121+
}
122+
123+
quantizer = TOSAQuantizer(tosa_profiles[tosa_version])
124+
quantizer.set_global(
125+
get_symmetric_a16w8_quantization_config(is_per_channel=per_channel_quantization)
126+
)
127+
128+
return Quantize(
129+
quantizer,
130+
get_symmetric_a16w8_quantization_config(
131+
is_per_channel=per_channel_quantization
132+
),
133+
)
134+
135+
136+
@common.parametrize("test_tensor", Rsqrt.test_parameters)
137+
@pytest.mark.xfail(
138+
reason="MLETORCH-707: AssertionError: Output 0 does not match reference output."
139+
)
140+
def test_rsqrt_16a8w_tosa_INT(test_tensor: torch.Tensor):
141+
"""Test rsqrt operation with int16 quantization"""
142+
pipeline = TosaPipelineINT[input_t1](
143+
Rsqrt(),
144+
test_tensor(),
145+
aten_op,
146+
exir_op=[],
147+
per_channel_quantization=False,
148+
use_to_edge_transform_and_lower=True,
149+
tosa_extensions=["int16"],
150+
)
151+
152+
pipeline.change_args(
153+
"quantize",
154+
get_symmetric_a16w8_rsqrt_quantizer(per_channel_quantization=False),
155+
)
156+
# Run the pipeline
157+
pipeline.run()
158+
159+
160+
@common.parametrize("test_tensor", Rsqrt.test_parameters)
161+
@common.XfailIfNoCorstone300
162+
@pytest.mark.xfail(
163+
reason="MLETORCH-707: AssertionError: Output 0 does not match reference output."
164+
)
165+
def test_rsqrt_16a8w_u55_INT16(test_tensor: torch.Tensor):
166+
"""Test rsqrt operation with int16 quantization on U55"""
167+
pipeline = EthosU55PipelineINT[input_t1](
168+
Rsqrt(),
169+
test_tensor(),
170+
aten_op,
171+
exir_ops=[],
172+
per_channel_quantization=True,
173+
use_to_edge_transform_and_lower=True,
174+
atol=1e-03,
175+
rtol=1e-03,
176+
run_on_fvp=True,
177+
)
178+
179+
pipeline.change_args(
180+
"quantize",
181+
get_symmetric_a16w8_rsqrt_quantizer(per_channel_quantization=True),
182+
)
183+
pipeline.run()
184+
185+
186+
@common.parametrize("test_tensor", Rsqrt.test_parameters)
187+
@common.XfailIfNoCorstone320
188+
@pytest.mark.xfail(
189+
reason="MLETORCH-707: AssertionError: Output 0 does not match reference output."
190+
)
191+
def test_rsqrt_16a8w_u85_INT16(test_tensor: torch.Tensor):
192+
"""Test rsqrt operation with int16 quantization on U85"""
193+
pipeline = EthosU85PipelineINT[input_t1](
194+
Rsqrt(),
195+
test_tensor(),
196+
aten_op,
197+
exir_ops=[],
198+
use_to_edge_transform_and_lower=True,
199+
atol=1e-03,
200+
rtol=1e-03,
201+
run_on_fvp=True,
202+
)
203+
204+
pipeline.change_args(
205+
"quantize",
206+
get_symmetric_a16w8_rsqrt_quantizer(per_channel_quantization=False),
207+
)
208+
pipeline.run()

backends/arm/test/runner_utils.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
from executorch.backends.arm.tosa.compile_spec import TosaCompileSpec
3232
from executorch.backends.arm.tosa.specification import Tosa_1_00, TosaSpecification
3333
from executorch.backends.arm.vgf import VgfCompileSpec
34-
from executorch.backends.arm.vgf.model_converter import find_model_converter_binary
3534
from executorch.exir import ExecutorchProgramManager, ExportedProgram
3635
from executorch.exir.lowered_backend_module import LoweredBackendModule
3736
from torch.fx.node import Node
@@ -679,15 +678,11 @@ def corstone320_installed() -> bool:
679678

680679

681680
def model_converter_installed() -> bool:
682-
model_converter = find_model_converter_binary()
683-
if model_converter is None:
684-
return False
685-
681+
cmd = ["model-converter", "--version"]
686682
try:
687-
_run_cmd([model_converter, "--version"], check=True)
688-
except Exception:
683+
_run_cmd(cmd, check=True)
684+
except:
689685
return False
690-
691686
return True
692687

693688

0 commit comments

Comments
 (0)