Skip to content

Commit 560450a

Browse files
committed
Qualcomm AI Engine Direct - Add the argument to specify soc model
1 parent c5a385e commit 560450a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

examples/models/llama2/export_llama_lib.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,14 @@ def build_args_parser() -> argparse.ArgumentParser:
316316
default=False,
317317
help="Generate logits for all inputs.",
318318
)
319+
320+
parser.add_argument(
321+
"--soc_model",
322+
help="SoC model of current device. e.g. 'SM8650' for Snapdragon 8 Gen 3.",
323+
type=str,
324+
required=False,
325+
default="SM8650",
326+
)
319327
return parser
320328

321329

@@ -533,7 +541,7 @@ def _export_llama(modelname, args) -> LLMEdgeManager: # noqa: C901
533541

534542
partitioners.append(
535543
get_qnn_partitioner(
536-
args.use_kv_cache, args.pt2e_quantize, args.num_sharding
544+
args.use_kv_cache, args.pt2e_quantize, args.num_sharding, args.soc_model
537545
)
538546
)
539547
# pyre-ignore: Undefined import [21]: Could not find a module corresponding to import `executorch.backends.qualcomm.utils.utils`

extension/llm/export/partitioner_lib.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def get_qnn_partitioner(
108108
use_kv_cache: bool = False,
109109
pt2e_quantize: Optional[str] = None,
110110
num_sharding: int = 0,
111+
soc_model: str = "SM8650", # default to SM8650
111112
):
112113
assert (
113114
use_kv_cache is True
@@ -138,9 +139,16 @@ def get_qnn_partitioner(
138139
if pt2e_quantize is not None:
139140
use_fp16 = False
140141

142+
soc_chip_table = {
143+
"SM8650": QcomChipset.SM8650,
144+
"SM8550": QcomChipset.SM8550,
145+
"SM8475": QcomChipset.SM8475,
146+
"SM8450": QcomChipset.SM8450,
147+
}
148+
141149
return QnnPartitioner( # pyre-fixme[16]
142150
generate_qnn_executorch_compiler_spec( # pyre-fixme[16]
143-
soc_model=QcomChipset.SM8650, # default to SM8650 # pyre-fixme[16]
151+
soc_model=soc_chip_table[soc_model], # pyre-fixme[16]
144152
# pyre-fixme[16]
145153
backend_options=generate_htp_compiler_spec(
146154
use_fp16=use_fp16,

0 commit comments

Comments
 (0)