Skip to content

Conversation

@houseroad
Copy link
Member

Some models many contain thousands constants (like list of ints) and Constant Pooling and CSE pass will move the constant around and update the constant pooling.

However our existing hash function only consider the node type + input type + output node (https://bddppq.github.io/codebrowser/pytorch/pytorch/torch/csrc/jit/node_hashing.cpp.html#_ZNK5torch3jit8HashNodeclEPKNS0_4NodeE), which will have a lot of conflicts... I have profiled, one insert may take as long as about 0.2 second... And loading the model will take 200 second, which is insane.

So we should fix this performance issue by considering the constant value as well to avoid the conflict.

@houseroad houseroad requested a review from apaszke as a code owner October 11, 2019 05:41
@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Oct 11, 2019
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@houseroad has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@suo
Copy link
Member

suo commented Oct 11, 2019

Cool! Can you paste of a snippet of a graph that would be affected by excessive hash collisions? Also, have you tried this PR on some of the models with really long compile times?

@houseroad houseroad force-pushed the fix_constant_pooling branch from c36eb9c to d8a58b3 Compare October 11, 2019 16:26
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@houseroad has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@houseroad houseroad changed the title [Need more polish] Better hashing for constant pool Better hashing for constant pool Oct 11, 2019
Copy link
Member

@suo suo left a comment

Choose a reason for hiding this comment

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

Well, overall this looks fine to me.

@facebook-github-bot
Copy link
Contributor

@houseroad merged this pull request in eb52223.

thiagocrepaldi pushed a commit to thiagocrepaldi/pytorch that referenced this pull request Feb 4, 2020
Summary:
Some models many contain thousands constants (like list of ints) and Constant Pooling and CSE pass will move the constant around and update the constant pooling.

However our existing hash function only consider the node type + input type + output node (https://bddppq.github.io/codebrowser/pytorch/pytorch/torch/csrc/jit/node_hashing.cpp.html#_ZNK5torch3jit8HashNodeclEPKNS0_4NodeE), which will have a lot of conflicts... I have profiled, one insert may take as long as about 0.2 second...  And loading the model will take 200 second, which is insane.

So we should fix this performance issue by considering the constant value as well to avoid the conflict.
Pull Request resolved: pytorch#27733

Reviewed By: bddppq

Differential Revision: D17873733

Pulled By: houseroad

fbshipit-source-id: 2338d7bf67174a8e56caa19a30401199f68b592a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants