Repository navigation
Commit 61d0880
authored
[Qualcomm] Partitioner falls back on ops without a node visitor (pytorch#21607)
# [Qualcomm] Partitioner falls back on ops without a node visitor (fix
KeyError)
## Summary
`QnnOperatorSupport.is_node_supported` indexed
`self.node_visitors[node.target.__name__]`
directly, so **any op that has no QNN node visitor raised `KeyError` and
aborted the entire
partition** instead of falling back to CPU. XNNPACK's partitioner
returns `False` for unknown
ops; QNN should do the same.
## Symptom
Lowering **Mamba2** to QNN crashes:
```
File ".../backends/qualcomm/partition/qnn_partitioner.py", line 113, in is_node_supported
op_wrapper = self.node_visitors[node.target.__name__].define_node(...)
KeyError: 'aten.bitwise_not.default'
```
Mamba2's causal mask uses `~torch.tril(...)`, which traces to
`aten.bitwise_not.default` — an op
QNN ships no visitor for. This is **not** SSM/conv specific: any graph
containing an op without a
visitor hits it.
## Fix
Guard the lookup and return `False` (→ CPU fallback) for unsupported
ops:
```python
supported = False
if node.target.__name__ not in self.node_visitors:
logger.info(f"[{self.phase}] {node.target.__name__} | No node visitor, unsupported")
return False
op_wrapper = self.node_visitors[node.target.__name__].define_node(...)
```
## Testing
`test_partitioner_falls_back_on_op_without_visitor` (in
`test_passes.py`): lowers a module whose
graph contains `aten.bitwise_not.default` and asserts `to_executorch()`
succeeds. **Fails on the
pre-fix code with the exact `KeyError` above; passes after.** Verified
by file-swap.
## Notes
- Optional follow-up (not in this PR): add `aten.bitwise_not.default` to
the `op_logical_not`
visitor's target list so it delegates to QNN (on a bool tensor it's
equivalent to `logical_not`),
putting more of Mamba2 on the HTP instead of CPU.
- Surfaced by the HuggingFace transformers ExecuTorch-exporter QNN work
(PR #47747), which currently
skips SSM with an inaccurate "CanonicalizeConv unsqueezes a conv bias"
comment — the real cause is
this partitioner KeyError.
cc @cbilgin1 parent e60faa2 commit 61d0880
3 files changed
Lines changed: 46 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
113 | 118 | | |
114 | 119 | | |
115 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
476 | 516 | | |
477 | 517 | | |
478 | 518 | | |
| |||
0 commit comments