Commit bab4068
Add QNN (Qualcomm Hexagon HTP) execution-provider profile (#370)
## What
Registers a `qnn` execution-provider profile so the ORT-GenAI builder
can target the Qualcomm Hexagon NPU (HTP backend, via the
onnxruntime-qnn QAIRT plugin):
- `_execution_providers.py`: new `EpCapabilities(name="qnn", ...)`.
- `integrations/ort_genai/ep_config.py`: map `qnn` → `QNN` for ORT-GenAI
provider dispatch.
## Why
Bringing up gemma-4-12B (`gemma4_unified`) on Qualcomm Copilot+ devices
(Snapdragon X Elite / X2 Elite). The HTP runs a statically-shaped,
QDQ-quantized graph compiled to a QNN context binary and has no kernels
for ORT contrib fused ops, so the build must emit standard ONNX
primitives the QNN op builders can lower.
## How
The profile **reuses the existing rewrite infrastructure** rather than
adding new passes:
- `supports_fused_rope=False` → `SeparateRoPE` / `UnpackQKV`
- `supports_skip_layer_norm=False` → skip-norm inlined to standard ops
- `supports_packed_multi_head_attention=False` → PackedMHA expanded
- `gqa_dtypes=frozenset()` → no GroupQueryAttention (the gemma-4
multimodal decoder forgoes GQA anyway — bidirectional-vision overlay);
standard Attention is emitted and static-shaped downstream
- `supports_past_present_share_buffer=False` (standard-Attention KV
concat can't alias a shared buffer)
- `provider_options` = onnxruntime-qnn HTP launch defaults; `soc_model`
+ EP-context binary path are device-specific, set at build/validation
time.
## Validation
Building gemma-4-12B with `execution_provider="qnn"` emits pure ai.onnx
(zero `com.microsoft` contrib ops).
## Not in this PR (for discussion)
The HTP-specific lowering we currently do downstream — 4D q/k-norm
RMSNorm reshape, RoPE→`com.microsoft::RotaryEmbedding` op-swap,
fold-shapes / drop-identity / decoder-split / mask-hoist — is a
candidate follow-up PR. Some of it is QNN context-binary **deployment**
rather than model build; happy to bring the in-scope pieces in-tree as
`rewrite_rules`/`_passes` + tests if the team wants them here.
Heads-up: this sets GQA **off** for `qnn`; flagging against
`justinchu/gemma4-12b-text-gqa` in case the attention path needs to
reconcile.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent c4d460f commit bab4068
2 files changed
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
270 | 292 | | |
271 | 293 | | |
272 | 294 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
0 commit comments