Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Subgraph API creates duplicate inputs and outputs #16108

@samskalicky

Description

@samskalicky

Description

Subgraph API can create duplicated tensors for both inputs to a subgraph and outputs from a subgraph. This happens when there are multiple nodes in a subgraph that consume the same input, or when there are multiple nodes that consume a single subgraph output. This results in tensor duplication, and causes OOM due to excessive memory usage.

Minimum reproducible example

Consider the duplicate input problem first. Lets say we have the following graph:

A --> B
  \
    --> C

In this graph node A has a single output, and nodes B and C consume A's output. If nodes B and C are added to a subgraph, the graph is changed to the following:

A --> S

S [ A0 --> B
     A1 --> C]

Heres, nodes B and C are moved into the subgraph, and their dependency on node A (which is not in the subgraph) is broken, and an input node is created for each: A0, A1. The subgraph will have 2 inputs (A0, A1) and will both have dependencies to node A.

Now lets consider the the duplicate output problem. Consider the same graph as above:

A --> B
  \
    --> C

But this time lets only node A is added to the subgraph, and nodes B and C are left out. Then the graph is changed to the following:

S --> B
  \
    --> C

S [ A]

Here, B and C have dependencies on the output from A inside the subgraph. In this case, the subgraph will have 2 outputs, one for each consumer: B and C. But both outputs will be defined as coming from the same output of node A inside the subgraph.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions