Skip to content

Commit 981bc60

Browse files
ssjiaSS-JIA
authored andcommitted
[ET-VK] Add Vulkan backend support for Parakeet runner and export
Pull Request resolved: pytorch#18049 Add Vulkan build support for the Parakeet runner: llm-debug-vulkan preset in root CMakePresets.json, parakeet-vulkan presets in the Parakeet CMakePresets.json, vulkan_backend linkage in CMakeLists.txt, and a `make parakeet-vulkan` Makefile target. Add _create_vulkan_partitioners() and wire it into lower_to_executorch() so that `--backend vulkan` is accepted by export_parakeet_tdt.py. ghstack-source-id: 353546680 @exported-using-ghexport Differential Revision: [D95970157](https://our.internmc.facebook.com/intern/diff/D95970157/)
1 parent 69b1251 commit 981bc60

6 files changed

Lines changed: 121 additions & 6 deletions

File tree

CMakePresets.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,21 @@
217217
"rhs": "Darwin"
218218
}
219219
},
220+
{
221+
"name": "llm-debug-vulkan",
222+
"displayName": "LLM debug build with Vulkan",
223+
"inherits": [
224+
"llm-debug"
225+
],
226+
"cacheVariables": {
227+
"EXECUTORCH_BUILD_VULKAN": "ON"
228+
},
229+
"condition": {
230+
"type": "inList",
231+
"string": "${hostSystemName}",
232+
"list": ["Linux", "Windows"]
233+
}
234+
},
220235
{
221236
"name": "llm-metal-stats",
222237
"displayName": "LLM Metal build with stats collection and logging",
@@ -354,6 +369,15 @@
354369
],
355370
"jobs": 0
356371
},
372+
{
373+
"name": "llm-debug-vulkan-install",
374+
"displayName": "Build and install LLM extension debug artifacts (Vulkan)",
375+
"configurePreset": "llm-debug-vulkan",
376+
"targets": [
377+
"install"
378+
],
379+
"jobs": 0
380+
},
357381
{
358382
"name": "llm-metal-stats-install",
359383
"displayName": "Build and install LLM extension artifacts with Metal stats",
@@ -449,6 +473,20 @@
449473
}
450474
]
451475
},
476+
{
477+
"name": "llm-debug-vulkan",
478+
"displayName": "Configure, build and install ExecuTorch LLM extension with Vulkan enabled (Debug)",
479+
"steps": [
480+
{
481+
"type": "configure",
482+
"name": "llm-debug-vulkan"
483+
},
484+
{
485+
"type": "build",
486+
"name": "llm-debug-vulkan-install"
487+
}
488+
]
489+
},
452490
{
453491
"name": "llm-metal-stats",
454492
"displayName": "Configure, build and install ExecuTorch LLM extension with Metal stats and logging",

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
#
9292
# ==============================================================================
9393

94-
.PHONY: voxtral-cuda voxtral-cpu voxtral-metal voxtral_realtime-cuda voxtral_realtime-cpu voxtral_realtime-metal whisper-cuda whisper-cuda-debug whisper-cpu whisper-metal parakeet-cuda parakeet-cuda-debug parakeet-cpu parakeet-metal dinov2-cuda dinov2-cuda-debug sortformer-cuda sortformer-cpu silero-vad-cpu llama-cuda llama-cuda-debug llama-cpu llava-cpu gemma3-cuda gemma3-cpu clean help
94+
.PHONY: voxtral-cuda voxtral-cpu voxtral-metal voxtral_realtime-cuda voxtral_realtime-cpu voxtral_realtime-metal whisper-cuda whisper-cuda-debug whisper-cpu whisper-metal parakeet-cuda parakeet-cuda-debug parakeet-cpu parakeet-metal parakeet-vulkan dinov2-cuda dinov2-cuda-debug sortformer-cuda sortformer-cpu silero-vad-cpu llama-cuda llama-cuda-debug llama-cpu llava-cpu gemma3-cuda gemma3-cpu clean help
9595

9696
help:
9797
@echo "This Makefile adds targets to build runners for various models on various backends. Run using \`make <target>\`. Available targets:"
@@ -109,6 +109,7 @@ help:
109109
@echo " parakeet-cuda-debug - Build Parakeet runner with CUDA backend (debug mode)"
110110
@echo " parakeet-cpu - Build Parakeet runner with CPU backend"
111111
@echo " parakeet-metal - Build Parakeet runner with Metal backend (macOS only)"
112+
@echo " parakeet-vulkan - Build Parakeet runner with Vulkan backend"
112113
@echo " dinov2-cuda - Build DINOv2 runner with CUDA backend"
113114
@echo " dinov2-cuda-debug - Build DINOv2 runner with CUDA backend (debug mode)"
114115
@echo " sortformer-cuda - Build Sortformer runner with CUDA backend"
@@ -221,6 +222,15 @@ parakeet-metal:
221222
@echo "✓ Build complete!"
222223
@echo " Binary: cmake-out/examples/models/parakeet/parakeet_runner"
223224

225+
parakeet-vulkan:
226+
@echo "==> Building and installing ExecuTorch with Vulkan..."
227+
cmake --workflow --preset llm-debug-vulkan
228+
@echo "==> Building Parakeet runner with Vulkan..."
229+
cd examples/models/parakeet && cmake --workflow --preset parakeet-vulkan
230+
@echo ""
231+
@echo "✓ Build complete!"
232+
@echo " Binary: cmake-out/examples/models/parakeet/parakeet_runner"
233+
224234
dinov2-cuda:
225235
@echo "==> Building and installing ExecuTorch with CUDA..."
226236
cmake --workflow --preset llm-release-cuda

examples/models/parakeet/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ if(EXECUTORCH_BUILD_METAL)
9191
executorch_target_link_options_shared_lib(metal_backend)
9292
endif()
9393

94+
if(EXECUTORCH_BUILD_VULKAN)
95+
list(APPEND link_libraries vulkan_backend)
96+
executorch_target_link_options_shared_lib(vulkan_backend)
97+
endif()
98+
9499
add_executable(parakeet_runner main.cpp timestamp_utils.cpp tokenizer_utils.cpp)
95100
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
96101
target_link_options_gc_sections(parakeet_runner)

examples/models/parakeet/CMakePresets.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,19 @@
5555
"type": "equals",
5656
"rhs": "Darwin"
5757
}
58+
},
59+
{
60+
"name": "parakeet-vulkan",
61+
"displayName": "Parakeet runner (Vulkan)",
62+
"inherits": ["parakeet-base"],
63+
"cacheVariables": {
64+
"EXECUTORCH_BUILD_VULKAN": "ON"
65+
},
66+
"condition": {
67+
"type": "inList",
68+
"string": "${hostSystemName}",
69+
"list": ["Linux", "Windows"]
70+
}
5871
}
5972
],
6073
"buildPresets": [
@@ -85,6 +98,13 @@
8598
"configurePreset": "parakeet-metal",
8699
"configuration": "Release",
87100
"targets": ["parakeet_runner"]
101+
},
102+
{
103+
"name": "parakeet-vulkan",
104+
"displayName": "Build Parakeet runner (Vulkan)",
105+
"configurePreset": "parakeet-vulkan",
106+
"configuration": "Release",
107+
"targets": ["parakeet_runner"]
88108
}
89109
],
90110
"workflowPresets": [
@@ -143,6 +163,20 @@
143163
"name": "parakeet-metal"
144164
}
145165
]
166+
},
167+
{
168+
"name": "parakeet-vulkan",
169+
"displayName": "Configure and build Parakeet runner (Vulkan)",
170+
"steps": [
171+
{
172+
"type": "configure",
173+
"name": "parakeet-vulkan"
174+
},
175+
{
176+
"type": "build",
177+
"name": "parakeet-vulkan"
178+
}
179+
]
146180
}
147181
]
148182
}

examples/models/parakeet/export_parakeet_tdt.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import torch
1111
import torchaudio
12-
1312
from executorch.examples.models.parakeet.quantize import quantize_model_
1413
from executorch.exir import (
1514
EdgeCompileConfig,
@@ -560,7 +559,25 @@ def _create_cuda_partitioners(programs, is_windows=False):
560559
return partitioner, updated_programs
561560

562561

563-
def lower_to_executorch(programs, metadata=None, backend="portable"):
562+
def _create_vulkan_partitioners(programs, vulkan_force_fp16=False):
563+
"""Create Vulkan partitioners for all programs except preprocessor."""
564+
from executorch.backends.vulkan.partitioner.vulkan_partitioner import (
565+
VulkanPartitioner,
566+
)
567+
568+
print("\nLowering to ExecuTorch with Vulkan...")
569+
partitioner = {}
570+
for key in programs.keys():
571+
if key == "preprocessor":
572+
partitioner[key] = []
573+
else:
574+
partitioner[key] = [VulkanPartitioner({"force_fp16": vulkan_force_fp16})]
575+
return partitioner, programs
576+
577+
578+
def lower_to_executorch(
579+
programs, metadata=None, backend="portable", vulkan_force_fp16=False
580+
):
564581
if backend == "xnnpack":
565582
partitioner, programs = _create_xnnpack_partitioners(programs)
566583
elif backend == "metal":
@@ -569,6 +586,10 @@ def lower_to_executorch(programs, metadata=None, backend="portable"):
569586
partitioner, programs = _create_cuda_partitioners(
570587
programs, is_windows=(backend == "cuda-windows")
571588
)
589+
elif backend == "vulkan":
590+
partitioner, programs = _create_vulkan_partitioners(
591+
programs, vulkan_force_fp16=vulkan_force_fp16
592+
)
572593
else:
573594
print("\nLowering to ExecuTorch...")
574595
partitioner = []
@@ -607,7 +628,7 @@ def main():
607628
"--backend",
608629
type=str,
609630
default="xnnpack",
610-
choices=["portable", "xnnpack", "metal", "cuda", "cuda-windows"],
631+
choices=["portable", "xnnpack", "metal", "cuda", "cuda-windows", "vulkan"],
611632
help="Backend for acceleration (default: xnnpack)",
612633
)
613634
parser.add_argument(
@@ -672,6 +693,8 @@ def main():
672693
help="Group size for embedding quantization (default: 0 = per-axis)",
673694
)
674695

696+
parser.add_argument("--vulkan_force_fp16", action="store_true")
697+
675698
args = parser.parse_args()
676699

677700
# Validate dtype
@@ -719,7 +742,12 @@ def main():
719742
qembedding_group_size=args.qembedding_group_size,
720743
)
721744

722-
et = lower_to_executorch(programs, metadata=metadata, backend=args.backend)
745+
et = lower_to_executorch(
746+
programs,
747+
metadata=metadata,
748+
backend=args.backend,
749+
vulkan_force_fp16=args.vulkan_force_fp16,
750+
)
723751

724752
pte_path = os.path.join(args.output_dir, "model.pte")
725753
print(f"\nSaving ExecuTorch program to: {pte_path}")

examples/models/parakeet/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ int main(int argc, char** argv) {
489489
static_cast<long long>(pred_hidden),
490490
static_cast<long long>(sample_rate),
491491
window_stride,
492-
encoder_subsampling_factor);
492+
static_cast<long long>(encoder_subsampling_factor));
493493

494494
ET_LOG(Info, "Running TDT greedy decode...");
495495
auto decoded_tokens = greedy_decode_executorch(

0 commit comments

Comments
 (0)