Skip to content

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

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

msluszniak wants to merge 4 commits into
pytorch:mainfrom
msluszniak:ms/memory-planning-tensorless-output

Conversation

@msluszniak

@msluszniak msluszniak commented Sep 2, 2026 •

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.

cc @JacobSzwejbka @angelayi

@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.

✅ No Failures

As of commit dabfb40 with merge base bf9bef3 (image):
💚 Looks good so far! There are no failures yet. 💚

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
@SS-JIA

SS-JIA commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

cc: @JacobSzwejbka since these changes touch memory planning.

From my side, changes LGTM

@msluszniak

Copy link
Copy Markdown
Contributor Author

Nothing outstanding from my side here; @nil-is-all could you help this one find a second reviewer?

@msluszniak

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "module: exir"

@pytorch-bot pytorch-bot Bot added the module: exir Issues related to Export IR and the code under exir/ label Sep 14, 2026
@nil-is-all nil-is-all added the release notes: exir Changes to any dialects and passes on these dialects, such as memory planning label Sep 14, 2026
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".
@msluszniak
msluszniak force-pushed the ms/memory-planning-tensorless-output branch from 61227e9 to ae8d1e0 Compare September 15, 2026 11:03
@executorch-triage executorch-triage Bot added the community: contribution PRs coming from community (excluding hardware partners) label Sep 22, 2026
@nil-is-all

Copy link
Copy Markdown
Contributor

@msluszniak I think we should be good to merge once the branch is updated. Thanks

This branch has not been deployed

No deployments
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. community: contribution PRs coming from community (excluding hardware partners) module: exir Issues related to Export IR and the code under exir/ release notes: exir Changes to any dialects and passes on these dialects, such as memory planning

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

4 participants