Fix tensor name/type disagreement on multi-output nodes - #22319
Conversation
Summary:
`define_tensor` decides twice whether the tensor it is defining is a graph
output: once for the tensor *name* (`get_tensor_name` -> `is_graph_output`, which
prefixes `output_`) and once for the tensor *type* (`get_tensor_type` ->
`is_graph_output`, which returns `QNN_TENSOR_TYPE_APP_READ`). Since
`is_graph_output` gained an `output_index` parameter, only the type path has been
passing it:
output_index = wrapper_idx if tensor_source_node is target_build_node else None
The name path still passed the raw `wrapper_idx`. `wrapper_idx` only indexes a
node's own outputs when the tensor being defined belongs to that node; builders
also use it to key scratch tensors sourced from some *other* node (see
`op_scatter_elements`), where it carries no output meaning. For a non-owner
multi-output source node at a partition boundary the two paths therefore answer
differently: the tensor gets an `output_`-prefixed name while its type stays
NATIVE, or gets APP_READ without the name the runtime expects. QNN graph
construction then fails, and because it depends on partitioning order it fails
intermittently -- this is the flake in `test-qnn-testsuite-linux` /
`test-backend-linux (qnn, models)`.
This computes `output_index` once and feeds it to both paths, so naming and
typing can no longer disagree. `get_tensor_name` takes `output_index` as a new
optional argument that defaults to `None`, preserving the behavior of any
external caller that does not pass it.
The `fbcode/` and `xplat/` copies of `node_visitor.py` are byte-identical
mirrors, so both are updated.
Authored with AI assistance (Claude Code).
Differential Revision: D118035167
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22319
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New Failures, 1 Unrelated FailureAs of commit f9e248a with merge base c27baa8 ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following job 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 D118035167. |
This PR needs a
|
Summary:
define_tensordecides twice whether the tensor it is defining is a graphoutput: once for the tensor name (
get_tensor_name->is_graph_output, whichprefixes
output_) and once for the tensor type (get_tensor_type->is_graph_output, which returnsQNN_TENSOR_TYPE_APP_READ). Sinceis_graph_outputgained anoutput_indexparameter, only the type path has beenpassing it:
The name path still passed the raw
wrapper_idx.wrapper_idxonly indexes anode's own outputs when the tensor being defined belongs to that node; builders
also use it to key scratch tensors sourced from some other node (see
op_scatter_elements), where it carries no output meaning. For a non-ownermulti-output source node at a partition boundary the two paths therefore answer
differently: the tensor gets an
output_-prefixed name while its type staysNATIVE, or gets APP_READ without the name the runtime expects. QNN graph
construction then fails, and because it depends on partitioning order it fails
intermittently -- this is the flake in
test-qnn-testsuite-linux/test-backend-linux (qnn, models).This computes
output_indexonce and feeds it to both paths, so naming andtyping can no longer disagree.
get_tensor_nametakesoutput_indexas a newoptional argument that defaults to
None, preserving the behavior of anyexternal caller that does not pass it.
The
fbcode/andxplat/copies ofnode_visitor.pyare byte-identicalmirrors, so both are updated.
Authored with AI assistance (Claude Code).
Differential Revision: D118035167