Skip to content

Commit 2c3e231

Browse files
authored
Fix llama_qnn Buck target import failures
Summary: `//executorch/examples/qualcomm/oss_scripts/llama:llama_qnn` currently fails at import time for every model, before any argument is parsed, with `ModuleNotFoundError: No module named 'executorch.examples.models.gemma4'` and then `... granite_speech`. The Buck targets drifted from the sources synced from upstream: the Gemma4 enablement (#20979) added an unconditional `executorch.examples.models.gemma4` import with no owning target for `gemma4/__init__.py`, Granite-Speech added `model/audio_encoder.py` plus a `granite_speech` import, and QAD (#21036) added `quantize/qat.py`, `dataset/{constants,targets}.py` and the `train/` package, none of which are in any target. This adds a `gemma4` library owning `gemma4/__init__.py`, a new `train` library (including its `train/config/*.yaml` resources), the missing sources in `static_llama`, `dataset` and `quantize`, and the `gemma4` and `granite_speech` deps on `llama_lib`. The `fbcode/` and `xplat/` copies are kept byte-identical. Known limitation, not addressed here: under Buck `QNN_SDK_ROOT` is a placeholder, so `is_qnn_sdk_version_less_than("2.35")` cannot detect the SDK version and masked softmax is disabled during export even though the pinned SDK (2.50) supports it. Authored with Claude Code. cc @cbilgin @psiddh Differential Revision: D127006045 Pull Request resolved: #24100
1 parent 71a713c commit 2c3e231

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

‎examples/models/gemma4/BUCK‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ non_fbcode_target(_kind = define_common_targets,)
88

99
fbcode_target(_kind = define_common_targets,)
1010

11+
fbcode_target(_kind = runtime.python_library,
12+
name = "gemma4",
13+
srcs = ["__init__.py"],
14+
_is_external_target = True,
15+
base_module = "executorch.examples.models.gemma4",
16+
deps = [":text_decoder"],
17+
visibility = ["PUBLIC"],
18+
)
19+
1120
# Text decoder module
1221
fbcode_target(_kind = runtime.python_library,
1322
name = "text_decoder",

‎examples/qualcomm/oss_scripts/llama/targets.bzl‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def define_common_targets(is_fbcode = False):
7474
srcs = [
7575
"model/__init__.py",
7676
"model/apply_rope.py",
77+
"model/audio_encoder.py",
7778
"model/embedding.py",
7879
"model/feed_forward.py",
7980
"model/layernorm.py",
@@ -82,6 +83,7 @@ def define_common_targets(is_fbcode = False):
8283
],
8384
deps = [
8485
"//caffe2:torch",
86+
"//executorch/examples/qualcomm:utils",
8587
"//executorch/examples/models/llama:transformer_modules",
8688
"fbsource//third-party/pypi/transformers:transformers",
8789
],
@@ -174,10 +176,12 @@ def define_common_targets(is_fbcode = False):
174176
"dataset/builders.py",
175177
"dataset/collators.py",
176178
"dataset/config.py",
179+
"dataset/constants.py",
177180
"dataset/datasets.py",
178181
"dataset/loaders.py",
179182
"dataset/preprocessors.py",
180183
"dataset/schema.py",
184+
"dataset/targets.py",
181185
],
182186
deps = [
183187
":decoder_constants",
@@ -196,17 +200,41 @@ def define_common_targets(is_fbcode = False):
196200
srcs = [
197201
"quantize/__init__.py",
198202
"quantize/ptq.py",
203+
"quantize/qat.py",
199204
"quantize/strategy.py",
200205
],
201206
deps = [
202207
":decoder_constants",
203208
":inference",
209+
":train",
204210
":utils",
205211
"//caffe2:torch",
206212
"//executorch/backends/qualcomm/_passes:passes",
207213
],
208214
)
209215

216+
runtime.python_library(
217+
name = "train",
218+
srcs = [
219+
"train/__init__.py",
220+
"train/config/__init__.py",
221+
"train/config/config.py",
222+
"train/loss.py",
223+
"train/trainer.py",
224+
"train/utils.py",
225+
],
226+
resources = [
227+
"train/config/lr_config.yaml",
228+
"train/config/qad.yaml",
229+
],
230+
deps = [
231+
":dataset",
232+
"//caffe2:torch",
233+
"fbsource//third-party/pypi/pyyaml:pyyaml",
234+
"fbsource//third-party/pypi/tqdm:tqdm",
235+
],
236+
)
237+
210238
runtime.python_library(
211239
name = "mix_precision_analyzer",
212240
srcs = [
@@ -298,8 +326,10 @@ def define_common_targets(is_fbcode = False):
298326
"//executorch/examples/models/codegen:codegen",
299327
"//executorch/examples/models/gemma:gemma",
300328
"//executorch/examples/models/gemma2:gemma2",
329+
"//executorch/examples/models/gemma4:gemma4",
301330
"//executorch/examples/models/glm:glm",
302331
"//executorch/examples/models/granite:granite",
332+
"//executorch/examples/models/granite_speech:granite_speech",
303333
"//executorch/examples/models/internvl3:internvl3",
304334
"//executorch/examples/models/smolvlm:smolvlm",
305335
"//executorch/examples/models/llama:hf_download",

0 commit comments

Comments
 (0)