Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Conversation

@yinghai
Copy link
Contributor

@yinghai yinghai commented Feb 29, 2020

Summary:
We will compile and cache the glow fused graph only once, shared across all the module/function from different inference threads. We have a global singleton of CachingGraphRunner keyed on the hash of jit::Graph. For each unique jit::Graph, we have one CachingGraphRunner. Then for each shape specifalization of CachingGraphRunner, we have a unique Glow function.

Strategy on caching CachingGraphRunner:
We will first query by hashing the fused subgraph. If not found, we will query by hashing the node symbol string, which suits the AOT case. Currently, we have to leak the CachingGraphRunner as I don't have a good idea of where the glow op is going to be destroyed and what hook I can add. This is fine for the forseeable future but we probably need more application level (say, predictor) signal to help with this.

Differential Revision: D20174479

@facebook-github-bot
Copy link

This pull request was exported from Phabricator. Differential Revision: D20174479

@yinghai yinghai force-pushed the export-D20174479 branch from 5543d29 to f3a4fc9 Compare March 1, 2020 07:23
@facebook-github-bot
Copy link

This pull request was exported from Phabricator. Differential Revision: D20174479

@yinghai yinghai force-pushed the export-D20174479 branch from f3a4fc9 to 2b8a955 Compare March 1, 2020 07:58
@facebook-github-bot
Copy link

This pull request was exported from Phabricator. Differential Revision: D20174479

@yinghai yinghai force-pushed the export-D20174479 branch from 2b8a955 to 2c59940 Compare March 1, 2020 08:20
@facebook-github-bot
Copy link

This pull request was exported from Phabricator. Differential Revision: D20174479

facebook-github-bot pushed a commit to pytorch/pytorch that referenced this pull request Mar 1, 2020
Summary:
HashNode and CompareNode are useful functions for hanlding jit::Node. This is to unblock pytorch/glow#4235.
Pull Request resolved: #34045

Reviewed By: houseroad

Differential Revision: D20184733

Pulled By: yinghai

fbshipit-source-id: 6c829f2f111a490fd2d85017475c1731cd97fb20
@yinghai yinghai force-pushed the export-D20174479 branch from 2c59940 to e52b271 Compare March 2, 2020 18:02
@facebook-github-bot
Copy link

This pull request was exported from Phabricator. Differential Revision: D20174479

@yinghai yinghai force-pushed the export-D20174479 branch from e52b271 to 05afd0a Compare March 2, 2020 21:49
@facebook-github-bot
Copy link

This pull request was exported from Phabricator. Differential Revision: D20174479

@yinghai yinghai force-pushed the export-D20174479 branch from 05afd0a to c0a50ca Compare March 3, 2020 03:48
@facebook-github-bot
Copy link

This pull request was exported from Phabricator. Differential Revision: D20174479

@yinghai yinghai force-pushed the export-D20174479 branch from c0a50ca to 48ea2d2 Compare March 3, 2020 04:44
@facebook-github-bot
Copy link

This pull request was exported from Phabricator. Differential Revision: D20174479

@yinghai yinghai force-pushed the export-D20174479 branch from 48ea2d2 to 7a3454c Compare March 3, 2020 07:01
@facebook-github-bot
Copy link

This pull request was exported from Phabricator. Differential Revision: D20174479

Summary:
Pull Request resolved: pytorch#4235

We will compile and cache the glow fused graph only once, shared across all the module/function from different inference threads. We have a global singleton of CachingGraphRunner keyed on the hash of jit::Graph. For each unique jit::Graph, we have one CachingGraphRunner. Then for each shape specifalization of CachingGraphRunner, we have a unique Glow function.

Strategy on caching CachingGraphRunner:
We will first query by hashing the fused subgraph. If not found, we will query by hashing the node symbol string, which suits the AOT case. Currently, we have to leak the CachingGraphRunner. This is fine for the forseeable future but we probably need more application level (say, predictor) signal to help with this. For example, if the application framework can save an instance of the CachingGraphRunner as a shared_ptr in AOT case and free it when the model is unloaded, we can then use weak_ptr for the graph runner map and hence will make sure everything will release except for an null weak_ptr.

Reviewed By: jackm321

Differential Revision: D20174479

fbshipit-source-id: aa0a564700ded2a02c988b2cad535d5a10c6cfb8
@yinghai yinghai force-pushed the export-D20174479 branch from 7a3454c to dc5e36d Compare March 3, 2020 07:28
@facebook-github-bot
Copy link

This pull request was exported from Phabricator. Differential Revision: D20174479

@facebook-github-bot
Copy link

This pull request has been merged in dadf6f1.

ttumiel pushed a commit to ttumiel/pytorch that referenced this pull request Mar 4, 2020
Summary:
HashNode and CompareNode are useful functions for hanlding jit::Node. This is to unblock pytorch/glow#4235.
Pull Request resolved: pytorch#34045

Reviewed By: houseroad

Differential Revision: D20184733

Pulled By: yinghai

fbshipit-source-id: 6c829f2f111a490fd2d85017475c1731cd97fb20
vdantu pushed a commit to vdantu/glow that referenced this pull request Jul 12, 2020
Summary:
Pull Request resolved: pytorch#4235

We will compile and cache the glow fused graph only once, shared across all the module/function from different inference threads. We have a global singleton of CachingGraphRunner keyed on the hash of jit::Graph. For each unique jit::Graph, we have one CachingGraphRunner. Then for each shape specifalization of CachingGraphRunner, we have a unique Glow function.

Strategy on caching CachingGraphRunner:
We will first query by hashing the fused subgraph. If not found, we will query by hashing the node symbol string, which suits the AOT case. Currently, we have to leak the CachingGraphRunner. This is fine for the forseeable future but we probably need more application level (say, predictor) signal to help with this. For example, if the application framework can save an instance of the CachingGraphRunner as a shared_ptr in AOT case and free it when the model is unloaded, we can then use weak_ptr for the graph runner map and hence will make sure everything will release except for an null weak_ptr.

Reviewed By: jackm321

Differential Revision: D20174479

fbshipit-source-id: 0c18880fe80c3ad72c9cad3010479fd7a8c2b9d6
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants