# US 2021/0174190 A1 · Neural network training using a data flow graph and dynamic memory management

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0174190 A1
- Document ID: US20210174190A1
- Status: Published application
- Kind: A1
- Application number: 16/704,240
- Filed: 2019-12-05
- Published: 2021-06-10
- Earliest claimed: 2019-12-05
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Gradus Janssen; Vladimir Zolotov; Tung D. Le
- Web page: https://patentgrep.com/patent/US20210174190A1

## CPC

- G06N 3/08: Learning methods
- G06F 9/5016: {the resource being the memory}
- G06F 9/5022: {Mechanisms to release resources}
- G06F 18/214: Generating training patterns; Bootstrap methods, e.g. bagging or boosting
- G06N 3/04: Architecture, e.g. interconnection topology
- G06N 3/06: Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
- G06N 3/02: Neural networks
- G06N 3/045: Combinations of networks
- G06N 3/063: using electronic means
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Processing a neural network data flow graph having a set of nodes and a set of edges. An insertion point is determined for a memory reduction or memory restoration operation. The determination is based on computing tensor timing slacks (TTS) for a set of input tensors; compiling a candidate list (SI) of input tensors, from the set of input tensors, using input tensors having corresponding TTS values larger than a threshold value (thTTS); filtering the SI to retain input tensors whose size meets a threshold value (thS); and determining an insertion point for the operation using the SI based on the filtering. A new data flow graph is generated or an existing one is modified using this process.

## Claims

### Claim 1

A method for reducing overall GPU memory usage while processing neural networks, the method comprising:
automatically determining insertion points of memory conservation operations in an underlying data flow graph comprising a set of nodes and a set of edges.

### Claim 2 (depends on 1)

The method of claim 1, wherein automatically determining insertion points comprises:
computing tensor timing slacks (TTS) for a set of input tensors;
compiling a candidate list (SI) of input tensors, from the set of input tensors, using input tensors having corresponding TTS values larger than a threshold value (thTTS);
filtering the SI to retain input tensors whose size meets a threshold value (thS); and
determining an insertion point for the operation using the SI based on the filtering.

### Claim 3 (depends on 1)

The method of claim 1, wherein the operation is a combination of a reduction operation and a restoration operation,
wherein the reduction operation comprises either or both of a copy to central processing unit (CPU) memory operation and a compression operation, and
wherein the restoration operation comprises either or both of a copy from CPU memory operation and a decompression operation.

### Claim 4 (depends on 1)

The method of claim 1, wherein computing the TTS comprises performing timing analysis using the input tensors.

### Claim 5 (depends on 1)

The method of claim 1, wherein the timing analysis comprises:
initializing tensor arrival time (TAT), tensor required time (TRT), and tensor timing slack (TTS) values for the input tensors;
for a set of input tensors Q, while Q is not empty, performing steps of:
selecting a node q in Q for exclusion;
excluding q from Q; and
setting, for each successor input tensor s of q, the TAT of s to be equal to TAT of q.

### Claim 6 (depends on 5)

The method of claim 5, wherein the initializing comprises:
initializing TAT, TRT, and TTS values to be of unknown value for all graph nodes and to be zero for all graph inputs collected in Q.

### Claim 7 (depends on 5)

The method of claim 5, wherein all inputs of a node n have a known TAT value, wherein n is a node for which s is an input tensor, and wherein the method further comprises performing, for the set of input tensors Q, further steps of:
setting the TRT of n to be a maximum of the TATs of inputs i of n;
setting the TTS of each input i of n as a difference of n's TRT and the TAT of i;
setting the TAT of n based on n's TRT incremented by a node delay; and
including n back into Q.

### Claim 8 (depends on 1)

The method of claim 1, wherein the data flow graph comprises a pair (N, E), wherein N comprises a set of nodes and E comprises a set of hyperedges, and wherein a given node in N implements one or more operators on one or more tensors.

### Claim 9 (depends on 8)

The method of claim 8, wherein the given node comprises a triplet (f, I, O), wherein f is a function of an operator implemented by the given node, I is a set of input tensors of the given node, and O is a set of outputs of the given node generated based on the operator.

### Claim 10 (depends on 8)

The method of claim 8, wherein a hyperedge defines how a tensor is passed from an operator that generates the tensor, to an operator that uses the tensor as an argument.

### Claim 11 (depends on 8)

The method of claim 8, wherein a hyperedge comprises a pair (s, H), wherein s is a node output, and H is a set of node inputs.

### Claim 12 (depends on 1)

The method of claim 1, further comprising:
inserting in the data flow graph a subgraph node corresponding to the operation.

### Claim 13 (depends on 12)

The method of claim 12, wherein the inserting generates a new data flow graph or modifies an existing data flow graph.

### Claim 14 (depends on 13)

The method of claim 13, wherein the inserting generates a new data flow graph, wherein the new data flow graph comprises a complete data flow graph or a partial data flow graph.

### Claim 15 (depends on 12)

The method of claim 12, further comprising:
processing the set of input tensors using the data flow graph based on the inserting; and
generating outputs based on the processing.

### Claim 16 (depends on 1)

The method of claim 1, wherein the operation is a memory reduction operation, the method further comprising:
inserting a memory reduction subgraph node corresponding to the memory reduction operation.

### Claim 17 (depends on 12)

The method of claim 12, wherein the inserting further comprises:
connecting, via a first hyperedge, a first node to the memory reduction subgraph node, the first node corresponding to a source node; and
connecting, via a second hyperedge, the memory reduction subgraph node to the second node, wherein the second hyperedge comprises a serialization hyperedge and the second node corresponds to an intermediary node or to a destination node.

### Claim 18 (depends on 12)

The method of claim 12, wherein the inserting further comprises:
connecting, via a third hyperedge, the first node to a second node.

### Claim 19 (depends on 1)

The method of claim 1, wherein the operation is a memory restoration operation, the method further comprising:
inserting a memory restoration subgraph node corresponding to the memory restoration operation.

### Claim 20 (depends on 19)

The method of claim 19, wherein the inserting further comprises:
connecting, via a first hyperedge, a first node to the memory restoration subgraph node, wherein the second hyperedge comprises a serialization hyperedge or a prefetching hyperedge;
connecting, via a second hyperedge, the memory restoration subgraph node to a second node, the second node corresponding to a destination node; and
connecting, via a third hyperedge, a memory reduction subgraph node to the memory restoration subgraph node.

### Claim 21 (depends on 1)

The method of claim 1, further comprising connecting two nodes of the data flow graph via a hyperedge, wherein the connecting comprises either of:
a direct connection via the hyperedge between the two nodes; and
an indirect connection via one or more additional nodes and hyperedges between the two nodes.

### Claim 22 (depends on 1)

The method of claim 1, wherein steps of the method are performed iteratively to insert into the flow graph a set of subgraph nodes for performing at least one memory reduction operation and at least one memory restoration operation.

### Claim 23 (depends on 22)

The method of claim 22, wherein performing steps of the method iteratively comprises inserting a set of hyperedges in the flow graph, the set of hyperedges comprising at least one serialization hyperedge, or at least one prefetching hyperedge, or at least one serialization hyperedge and at least one prefetching hyperedge.

### Claim 24

A method comprising:
selecting an insertion point in a data flow graph, for an operation, based on a set of tensor timing slacks (TTS) and a candidate list of input tensors (SI);
computing the tensor timing slacks (TTS) for a set of input tensors;
compiling the candidate list (SI) of input tensors, from a set of input tensors, using input tensors having corresponding TTS values larger than a threshold value (thTTS);
filtering the SI to retain input tensors whose size meets a threshold value (thS); and
determining an insertion point for a reduction and restoration operation using the SI based on the filtering.

### Claim 25

A method comprising:
determining to apply a memory reduction action with subgraph node A and node P by identifying a memory requirement for output data to be produced by the node P;
transmitting data from a source node to the subgraph node A and the node P;
enabling the subgraph node A to perform the memory reduction action before an execution of the node P, the memory reduction action causing an additional memory space to become available for a graphical processor (GPU) to perform one or more functions;
causing subgraph node B to delay a memory restoration action until node Q has completed its execution; and
transmitting the data from a central processor (CPU) of subgraph node B to the GPU to restore the data to the GPU.
