Skip to content

feat: Add expected_outputs for conditional output computation#12282

Open
bigcat88 wants to merge 5 commits intomasterfrom
feat/core/expected_outputs
Open

feat: Add expected_outputs for conditional output computation#12282
bigcat88 wants to merge 5 commits intomasterfrom
feat/core/expected_outputs

Conversation

@bigcat88
Copy link
Copy Markdown
Contributor

@bigcat88 bigcat88 commented Feb 4, 2026

This PR adds the ability for nodes to know at runtime which of their outputs are actually connected downstream. This enables nodes to skip computing expensive outputs that won't be used.

Motivation

Some nodes (especially API nodes) produce multiple outputs in different formats (e.g., GLB, FBX, OBJ for 3D models). Currently, all outputs are computed even if only one is connected. This wastes time and bandwidth downloading unused files.

  • During execution, expected_outputs is computed by scanning which outputs have downstream connections
  • Nodes access this via get_executing_context().expected_outputs
  • Outputs NOT in the set are definitely unused and safe to skip
  • Outputs IN the set might be used

Example of usage:

from comfy_execution.utils import is_output_needed

...


# Output indices: 0=GLB, 1=FBX
glb_file = None
fbx_file = None
if is_output_needed(0):
    glb_file = await download_url_to_file_3d(result.model_urls.glb, "glb", task_id=task_id)
if is_output_needed(1):
    fbx_file = await download_url_to_file_3d(result.model_urls.fbx, "fbx", task_id=task_id)
return IO.NodeOutput(glb_file, fbx_file)     

This feature may also be useful for non-API nodes as nodes can now even change their behavior based on unconnected outputs.

@bigcat88 bigcat88 force-pushed the feat/core/expected_outputs branch from 54321a5 to 50975a7 Compare February 5, 2026 07:06
Comment thread comfy_execution/graph.py Outdated
Comment thread comfy_execution/graph.py
pass


def get_expected_outputs_for_node(dynprompt, node_id: str) -> frozenset:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Instead of get_expected_outputs_for_node (and using the word expected in general), what do you think of get_possible_outputs_for_node or something like that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Possible outputs" sounds like it describes the node capability - which output slots it could produce. A node with 3 output slots always has 3 possible outputs, regardless of connectivity.

@bigcat88 bigcat88 added the Core Core team dependency label Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Core Core team dependency

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants