Skip to content

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

Description

@msluszniak

馃悰 Describe the bug

Verifier.verify_graph_input_output in exir/memory_planning.py walks the placeholder and output nodes and records whether the planner allocated each one. A node with no tensor specs is skipped, and the skip happens before graph_output_allocated is assigned:

for nd in graph_module.graph.nodes:
    if nd.op in check_list:
        if not (specs := get_node_tensor_specs(nd)):
            continue

So a graph whose output node carries only non-tensor values never sets the flag, and lowering fails on:

AssertionError: graph_output_allocated not set

even though the graph is fully planned. There is nothing to allocate for that node. The neighbouring len(specs) == 0 branch already treats "nothing to allocate" as success for the all-const case.

This is reachable from a normal export. Lowering a llama-family model to Vulkan with dynamic shapes produces a partition whose only outputs are symints (sym_size / et_vk.select_as_symint), and every such export aborts here.

Versions

Reproduces on main (a6b115b).

Repro:

from executorch.examples.models.llama.export_llama_lib import export_llama
from executorch.extension.llm.export.config.llm_config import LlmConfig

cfg = LlmConfig()
# ... qwen3 0.6B checkpoint/params ...
cfg.model.use_kv_cache = True
cfg.model.use_sdpa_with_kv_cache = True
cfg.model.enable_dynamic_shape = True
cfg.backend.vulkan.enabled = True
export_llama(cfg)

A standalone unit repro, no backend needed:

from torch.fx import Graph, GraphModule
from executorch.exir.memory_planning import Verifier

graph = Graph()
sym = graph.placeholder("sym")
graph.output((sym,))
Verifier(
    GraphModule({}, graph),
    alloc_graph_input=True,
    alloc_graph_output=True,
    alloc_mutable_buffers=True,
).verify_graph_input_output()

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions