Skip to content

Do not assert on a graph output that carries no tensors - #22479

Open
msluszniak wants to merge 1 commit into
pytorch:mainfrom
msluszniak:ms/memory-planning-tensorless-output
Open

Do not assert on a graph output that carries no tensors#22479
msluszniak wants to merge 1 commit into
pytorch:mainfrom
msluszniak:ms/memory-planning-tensorless-output

Conversation

@msluszniak

Copy link
Copy Markdown
Contributor

Fixes #22477.

The memory planning verifier skips nodes with no tensor specs before it sets graph_output_allocated, so a graph whose output node carries only non-tensor values leaves the flag at None and trips assert graph_output_allocated is not None despite being fully planned.

An output node like that is legitimate: a Vulkan partition of a dynamic-shape LLM ends up with one whose only results are symints, and every such export currently aborts here. The neighbouring len(specs) == 0 branch already treats "nothing to allocate" as success for the all-const case, so this does the same.

Test: TestTensorlessGraphOutput::test_verifier_accepts_output_carrying_no_tensors reproduces the assertion on main and passes with the change. The rest of exir/tests/test_memory_planning.py (38 tests) still passes.

With this in place, a qwen3 0.6B Vulkan export with enable_dynamic_shape=True lowers and runs.

The memory planning verifier walks the placeholder and output nodes and
records, for each one, whether the planner allocated it. A node with no tensor
specs is skipped, and the skip happens before graph_output_allocated is set, so
a graph whose output node carries only non-tensor values leaves that flag at
None and trips "assert graph_output_allocated is not None".

An output node like that is legitimate. A Vulkan partition of a dynamic-shape
LLM ends up with one whose only results are symints (sym_size /
et_vk.select_as_symint), and the graph is fully planned when the verifier
rejects it. The neighbouring len(specs) == 0 branch already treats "nothing to
allocate" as success for the all-const case; do the same here.

Repro before this change: export any llama-family model with
enable_dynamic_shape=True and backend.vulkan.enabled=True, e.g. qwen3 0.6B, and
lowering fails with "graph_output_allocated not set".
@pytorch-bot

pytorch-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22479

Note: Links to docs will display an error until the docs builds have been completed.

⚠️ 14 Awaiting Approval

As of commit 61227e9 with merge base a6b115b (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory planning asserts graph_output_allocated not set when a graph output carries no tensors

2 participants