forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
318 lines (294 loc) · 13.6 KB
/
Makefile
File metadata and controls
318 lines (294 loc) · 13.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# ==============================================================================
# ExecuTorch Targets Makefile
# ==============================================================================
#
# This Makefile provides convenient targets for building ExecuTorch model runners
# with different backend configurations (CPU, CUDA, Metal), as well as other
# binary targets.
#
# WHAT THIS BUILDS:
# -----------------
# Each target builds:
# 1. ExecuTorch core libraries with the specified backend (CPU, CUDA, or Metal)
# 2. The model-specific runner executable in cmake-out/examples/models/<model>/
#
# SUPPORTED MODELS:
# -----------------
# - voxtral: Multimodal voice + text model (CPU, CUDA, Metal)
# - voxtral_realtime: Realtime speech-to-text model (CPU)
# - whisper: Speech recognition model (CPU, CUDA, Metal)
# - parakeet: Speech recognition model (CPU, CUDA, Metal)
# - sortformer: Speaker diarization model (CPU)
# - silero_vad: Voice activity detection model (CPU)
# - llama: Text generation model (CPU)
# - llava: Vision + language model (CPU)
# - gemma3: Text generation model (CPU, CUDA)
#
# USAGE:
# ------
# make <model>-<backend> # Build a specific model with a backend
# make help # Show all available targets
# make clean # Remove all build artifacts
#
# Examples:
# make voxtral-cuda # Build Voxtral with CUDA backend
# make llama-cpu # Build Llama with CPU backend
# make whisper-metal # Build Whisper with Metal backend (macOS)
#
# HOW TO ADD A NEW MODEL:
# -----------------------
# To add a new model (e.g., "mymodel"), follow these steps:
#
# 1. Create a CMakePresets.json in examples/models/mymodel/:
# - Define configurePresets for each backend (base, cpu, cuda, metal)
# - Define buildPresets with the target name from CMakeLists.txt
# - Define workflowPresets that combine configure + build steps
# - See examples/models/voxtral/CMakePresets.json for multi-backend reference
# - Or see examples/models/llama/CMakePresets.json for simple single-preset reference
#
# 2. Add targets to this Makefile:
# a) Add to .PHONY declaration: mymodel-cuda mymodel-cpu mymodel-metal
# b) Add help text in the help target
# c) Add target implementations following this pattern:
#
# mymodel-cuda:
# @echo "==> Building and installing ExecuTorch with CUDA..."
# cmake --workflow --preset llm-release-cuda
# @echo "==> Building MyModel runner with CUDA..."
# cd examples/models/mymodel && cmake --workflow --preset mymodel-cuda
# @echo ""
# @echo "✓ Build complete!"
# @echo " Binary: cmake-out/examples/models/mymodel/mymodel_runner"
#
# mymodel-cpu:
# @echo "==> Building and installing ExecuTorch..."
# cmake --workflow --preset llm-release
# @echo "==> Building MyModel runner (CPU)..."
# cd examples/models/mymodel && cmake --workflow --preset mymodel-cpu
# @echo ""
# @echo "✓ Build complete!"
# @echo " Binary: cmake-out/examples/models/mymodel/mymodel_runner"
#
# mymodel-metal:
# @echo "==> Building and installing ExecuTorch with Metal..."
# cmake --workflow --preset llm-release-metal
# @echo "==> Building MyModel runner with Metal..."
# cd examples/models/mymodel && cmake --workflow --preset mymodel-metal
# @echo ""
# @echo "✓ Build complete!"
# @echo " Binary: cmake-out/examples/models/mymodel/mymodel_runner"
#
# 3. Test your new targets:
# make mymodel-cpu # or mymodel-cuda, mymodel-metal
#
# NOTES:
# ------
# - CUDA backend is only available on Linux systems
# - Metal backend is only available on macOS (Darwin) systems
# - Some models may not support all backends (check model documentation)
# - Binary outputs are located in cmake-out/examples/models/<model>/
# - The preset names in CMakePresets.json must match the names used in Makefile
#
# ==============================================================================
.PHONY: voxtral-cuda voxtral-cpu voxtral-metal voxtral_realtime-cpu voxtral_realtime-metal whisper-cuda whisper-cuda-debug whisper-cpu whisper-metal parakeet-cuda parakeet-cuda-debug parakeet-cpu parakeet-metal sortformer-cpu silero-vad-cpu llama-cuda llama-cuda-debug llama-cpu llava-cpu gemma3-cuda gemma3-cpu clean help
help:
@echo "This Makefile adds targets to build runners for various models on various backends. Run using \`make <target>\`. Available targets:"
@echo " voxtral-cuda - Build Voxtral runner with CUDA backend"
@echo " voxtral-cpu - Build Voxtral runner with CPU backend"
@echo " voxtral-metal - Build Voxtral runner with Metal backend (macOS only)"
@echo " voxtral_realtime-cpu - Build Voxtral Realtime runner with CPU backend"
@echo " voxtral_realtime-metal - Build Voxtral Realtime runner with Metal backend (macOS only)"
@echo " whisper-cuda - Build Whisper runner with CUDA backend"
@echo " whisper-cuda-debug - Build Whisper runner with CUDA backend (debug mode)"
@echo " whisper-cpu - Build Whisper runner with CPU backend"
@echo " whisper-metal - Build Whisper runner with Metal backend (macOS only)"
@echo " parakeet-cuda - Build Parakeet runner with CUDA backend"
@echo " parakeet-cuda-debug - Build Parakeet runner with CUDA backend (debug mode)"
@echo " parakeet-cpu - Build Parakeet runner with CPU backend"
@echo " parakeet-metal - Build Parakeet runner with Metal backend (macOS only)"
@echo " sortformer-cpu - Build Sortformer runner with CPU backend"
@echo " silero-vad-cpu - Build Silero VAD runner with CPU backend"
@echo " llama-cuda - Build Llama runner with CUDA backend"
@echo " llama-cuda-debug - Build Llama runner with CUDA backend (debug mode)"
@echo " llama-cpu - Build Llama runner with CPU backend"
@echo " llava-cpu - Build Llava runner with CPU backend"
@echo " gemma3-cuda - Build Gemma3 runner with CUDA backend"
@echo " gemma3-cpu - Build Gemma3 runner with CPU backend"
@echo " clean - Clean build artifacts"
voxtral-cuda:
@echo "==> Building and installing ExecuTorch with CUDA..."
cmake --workflow --preset llm-release-cuda
@echo "==> Building Voxtral runner with CUDA..."
cd examples/models/voxtral && cmake --workflow --preset voxtral-cuda
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/voxtral/voxtral_runner"
voxtral-cpu:
@echo "==> Building and installing ExecuTorch..."
cmake --workflow --preset llm-release
@echo "==> Building Voxtral runner (CPU)..."
cd examples/models/voxtral && cmake --workflow --preset voxtral-cpu
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/voxtral/voxtral_runner"
voxtral-metal:
@echo "==> Building and installing ExecuTorch with Metal..."
cmake --workflow --preset llm-release-metal
@echo "==> Building Voxtral runner with Metal..."
cd examples/models/voxtral && cmake --workflow --preset voxtral-metal
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/voxtral/voxtral_runner"
whisper-cuda:
@echo "==> Building and installing ExecuTorch with CUDA..."
cmake --workflow --preset llm-release-cuda
@echo "==> Building Whisper runner with CUDA..."
cd examples/models/whisper && cmake --workflow --preset whisper-cuda
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/whisper/whisper_runner"
whisper-cuda-debug:
@echo "==> Building and installing ExecuTorch with CUDA (debug mode)..."
cmake --workflow --preset llm-debug-cuda
@echo "==> Building Whisper runner with CUDA (debug mode)..."
cd examples/models/whisper && cmake --workflow --preset whisper-cuda-debug
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/whisper/whisper_runner"
whisper-cpu:
@echo "==> Building and installing ExecuTorch..."
cmake --workflow --preset llm-release
@echo "==> Building Whisper runner (CPU)..."
cd examples/models/whisper && cmake --workflow --preset whisper-cpu
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/whisper/whisper_runner"
whisper-metal:
@echo "==> Building and installing ExecuTorch with Metal..."
cmake --workflow --preset llm-release-metal
@echo "==> Building Whisper runner with Metal..."
cd examples/models/whisper && cmake --workflow --preset whisper-metal
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/whisper/whisper_runner"
parakeet-cuda:
@echo "==> Building and installing ExecuTorch with CUDA..."
cmake --workflow --preset llm-release-cuda
@echo "==> Building Parakeet runner with CUDA..."
cd examples/models/parakeet && cmake --workflow --preset parakeet-cuda
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/parakeet/parakeet_runner"
parakeet-cuda-debug:
@echo "==> Building and installing ExecuTorch with CUDA (debug mode)..."
cmake --workflow --preset llm-debug-cuda
@echo "==> Building Parakeet runner with CUDA (debug mode)..."
cd examples/models/parakeet && cmake --workflow --preset parakeet-cuda-debug
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/parakeet/parakeet_runner"
parakeet-cpu:
@echo "==> Building and installing ExecuTorch..."
cmake --workflow --preset llm-release
@echo "==> Building Parakeet runner (CPU)..."
cd examples/models/parakeet && cmake --workflow --preset parakeet-cpu
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/parakeet/parakeet_runner"
parakeet-metal:
@echo "==> Building and installing ExecuTorch with Metal (stats enabled)..."
cmake --workflow --preset llm-metal-stats
@echo "==> Building Parakeet runner with Metal..."
cd examples/models/parakeet && cmake --workflow --preset parakeet-metal
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/parakeet/parakeet_runner"
sortformer-cpu:
@echo "==> Building and installing ExecuTorch..."
cmake --workflow --preset llm-release
@echo "==> Building Sortformer runner (CPU)..."
cd examples/models/sortformer && cmake --workflow --preset sortformer-cpu
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/sortformer/sortformer_runner"
voxtral_realtime-cpu:
@echo "==> Building and installing ExecuTorch..."
cmake --workflow --preset llm-release
@echo "==> Building Voxtral Realtime runner (CPU)..."
cd examples/models/voxtral_realtime && cmake --workflow --preset voxtral-realtime-cpu
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/voxtral_realtime/voxtral_realtime_runner"
voxtral_realtime-metal:
@echo "==> Building and installing ExecuTorch with Metal (stats enabled)..."
cmake --workflow --preset llm-metal-stats
@echo "==> Building Voxtral Realtime runner with Metal..."
cd examples/models/voxtral_realtime && cmake --workflow --preset voxtral-realtime-metal
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/voxtral_realtime/voxtral_realtime_runner"
silero-vad-cpu:
@echo "==> Building and installing ExecuTorch..."
cmake --workflow --preset llm-release
@echo "==> Building Silero VAD runner (CPU)..."
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH=$(CURDIR)/cmake-out \
-DCMAKE_PREFIX_PATH=$(CURDIR)/cmake-out \
-S examples/models/silero_vad \
-B cmake-out/examples/models/silero_vad
cmake --build cmake-out/examples/models/silero_vad --target silero_vad_runner
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/silero_vad/silero_vad_runner"
llama-cpu:
@echo "==> Building and installing ExecuTorch..."
cmake --workflow --preset llm-release
@echo "==> Building Llama runner (CPU)..."
cd examples/models/llama && cmake --workflow --preset llama-release
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/llama/llama_main"
llama-cuda:
@echo "==> Building and installing ExecuTorch with CUDA..."
cmake --workflow --preset llm-release-cuda
@echo "==> Building Llama runner with CUDA..."
cd examples/models/llama && cmake --workflow --preset llama-cuda
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/llama/llama_main"
llama-cuda-debug:
@echo "==> Building and installing ExecuTorch with CUDA (debug mode)..."
cmake --workflow --preset llm-debug-cuda
@echo "==> Building Llama runner with CUDA (debug mode)..."
cd examples/models/llama && cmake --workflow --preset llama-cuda-debug
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/llama/llama_main"
llava-cpu:
@echo "==> Building and installing ExecuTorch..."
cmake --workflow --preset llm-release
@echo "==> Building Llava runner (CPU)..."
cd examples/models/llava && cmake --workflow --preset llava
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/llava/llava_main"
gemma3-cuda:
@echo "==> Building and installing ExecuTorch with CUDA..."
cmake --workflow --preset llm-release-cuda
@echo "==> Building Gemma3 runner with CUDA..."
cd examples/models/gemma3 && cmake --workflow --preset gemma3-cuda
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/gemma3/gemma3_e2e_runner"
gemma3-cpu:
@echo "==> Building and installing ExecuTorch..."
cmake --workflow --preset llm-release
@echo "==> Building Gemma3 runner (CPU)..."
cd examples/models/gemma3 && cmake --workflow --preset gemma3-cpu
@echo ""
@echo "✓ Build complete!"
@echo " Binary: cmake-out/examples/models/gemma3/gemma3_e2e_runner"
clean:
rm -rf cmake-out \
extension/llm/tokenizers/build \
extension/llm/tokenizers/pytorch_tokenizers.egg-info