Commit 5ed466e
authored
Fix embedding lowering crash when QNN_SDK_ROOT is unset (#21051)
Summary:
D110960687 (#20686) rewrote `Embedding.define_node` to
select between the optimized and legacy pcq-embedding lowerings based on
`is_qnn_sdk_version_less_than("2.48")`. That helper resolves the SDK
version via
`get_sdk_build_id`, which builds a path from
`os.environ["QNN_SDK_ROOT"]`.
`define_node` runs during AOT partitioning (`is_node_supported`), and
AOT-only
environments do not necessarily have `QNN_SDK_ROOT` set. In that case
`os.path.join(os.environ.get("QNN_SDK_ROOT", None), ...)` raised
`TypeError: expected str, bytes or os.PathLike object, not NoneType`,
breaking
every QNN lowering that contains an embedding — including the internal
`test_dummy_llama_qnn_16a4w_aot_and_runtime`.
Fall back to the legacy embedding lowering (valid on all QNN versions)
when
`QNN_SDK_ROOT` is unavailable, so the version-gated optimization is only
taken
when the SDK version can actually be determined. Also make
`get_sdk_build_id`
raise a clear `EnvironmentError` instead of a cryptic `TypeError` when
the
environment variable is missing.
This diff was authored with Claude Code.
Differential Revision: D1129442321 parent 0fc1f61 commit 5ed466e
2 files changed
Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
242 | 243 | | |
243 | 244 | | |
244 | 245 | | |
245 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
246 | 251 | | |
247 | 252 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
29 | 34 | | |
30 | | - | |
| 35 | + | |
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
| |||
0 commit comments