Add regression test for unlifted get_attr constants - #22022
Conversation
Summary: `is_parameter()` / `get_parameter()` in `backends/qualcomm/builders/utils.py` only recognized lifted constants (`is_param` / `is_buffer` / `is_lifted_tensor_constant`). An UNLIFTED `get_attr` node -- a tensor a pass attached with `setattr` and referenced via a plain `get_attr`, present in neither `state_dict` nor `constants` nor the graph signature -- fell through, so `get_parameter()` tripped its `assert param is not None` and raised `Expect <name> to be parameter, buffer, or lifted tensor constant`. D116957343 fixed that by adding a `node.op == "get_attr"` branch to both functions. OSS CI never caught the original break because every failing path was internal-only (the LPAI `LpaiPartitionFallbackSupport` pass and the internal `examples/models/fb/llama4/...` exports); the OSS `[htp]` path lifts its constants, so it never produces an unlifted `get_attr`. This adds `backends/qualcomm/tests/test_builders_utils.py`, a backend-agnostic, pure-fx-graph unit test that closes that coverage gap. It builds an `ExportedProgram` whose graph carries an unlifted `get_attr` tensor constant and asserts `is_parameter()` returns True, `get_parameter()` returns the tensor cast to `node.meta["val"].dtype`, and that the lookup falls back to `edge_program.graph_module` when `node.graph.owning_module` cannot resolve the target. No QNN SDK, no device, no LPAI backend, no internal models -- it runs anywhere `torch.export` runs, including OSS CI. Note on ordering: this diff contains only the new test, no `utils.py` change. It depends on D116957343 (land enqueued at the time of writing) and will fail until that lands. Differential Revision: D116963247
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22022
Note: Links to docs will display an error until the docs builds have been completed. ❌ 3 New Failures, 6 Unrelated FailuresAs of commit 2cf17e1 with merge base 89e6f90 ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@psiddh has exported this pull request. If you are a Meta employee, you can view the originating Diff in D116963247. |
This PR needs a
|
There was a problem hiding this comment.
LGTM, thanks Sid. Should we add test_builders_utils.py to the CI? I see only test_passes.py is currently there.
On a similar note, we should ideally have testing specifically for these util methods, I'll discuss that internally with the team.
Thanks for bringing this up. I was thinking on the similar lines. Please discuss and let us know how we can increase the OSS CI coverage further. |
Summary:
is_parameter()/get_parameter()inbackends/qualcomm/builders/utils.pyonlyrecognized lifted constants (
is_param/is_buffer/is_lifted_tensor_constant).An UNLIFTED
get_attrnode -- a tensor a pass attached withsetattrand referencedvia a plain
get_attr, present in neitherstate_dictnorconstantsnor the graphsignature -- fell through, so
get_parameter()tripped itsassert param is not Noneand raised
Expect <name> to be parameter, buffer, or lifted tensor constant.#22020 fixed that by adding a
node.op == "get_attr"branch to both functions.OSS CI never caught the original break because every failing path was internal-only
(the LPAI
LpaiPartitionFallbackSupportpass and the internalexamples/models/fb/llama4/...exports); the OSS[htp]path lifts its constants, soit never produces an unlifted
get_attr.This adds
backends/qualcomm/tests/test_builders_utils.py, a backend-agnostic,pure-fx-graph unit test that closes that coverage gap. It builds an
ExportedProgramwhose graph carries an unlifted
get_attrtensor constant and assertsis_parameter()returns True,
get_parameter()returns the tensor cast tonode.meta["val"].dtype, andthat the lookup falls back to
edge_program.graph_modulewhennode.graph.owning_modulecannot resolve the target. No QNN SDK, no device, no LPAIbackend, no internal models -- it runs anywhere
torch.exportruns, including OSS CI.Note on ordering: this diff contains only the new test, no
utils.pychange. It dependson #22020 and will fail until that lands.
Differential Revision: D116963247