[jit] Fix scalar tensor assert in fusion compiler#10952
[jit] Fix scalar tensor assert in fusion compiler#10952zou3519 wants to merge 6 commits intopytorch:masterfrom
Conversation
facebook-github-bot
left a comment
There was a problem hiding this comment.
zou3519 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
@zou3519 : This fixes the particular |
|
Oh I see, yes I think that is related. Sending a fix... |
|
Thanks! I think that this fixes the scalar issue, and the Hamiltonian Monte Carlo examples pass with this change. The VAE example is now throwing a different error, but I think that might be a separate issue. I'll either create a new one or update #10715. Stack Trace |
|
@neerajprad the stack track you have there is probably a different issue. Let me know (or update/open an issue) if you can find a small example that causes the crash |
Thanks, @zou3519! I'll debug to see if there is a minimal example that we can isolate. |
torch/csrc/jit/fusion_compiler.h
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/csrc/jit/fusion_compiler.cpp
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
I can sit on this until @mruberry's fuser split happens :) |
|
@zou3519 : Regarding my comment above, I think that is most likely a Pyro specific issue pyro-ppl/pyro#1358. |
|
I can rebase my PR with your changes. My PR is still waiting on review and I don't want to hold things up. |
|
Thanks, @mruberry, I'll let you know when this goes in. @neerajprad based on the error message it looks like the tracer is specializing on input sizes -- I think we changed the behavior last week and it shouldn't do that anymore. Could you try pulling from master again and see if your bug still exists? |
I have verified that the PyTorch tracer correctly generalizes to other input sizes (at least for the examples I tried it on), so this is most likely a bug within Pyro (in the way we are using the tracing functionality). This is being tracked in pyro-ppl/pyro#1358. |
torch/csrc/jit/fusion_compiler.cpp
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
facebook-github-bot
left a comment
There was a problem hiding this comment.
zou3519 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
My only concern is that this doesn't really check that the fusion even happened on those scalars, but LGTM. |
facebook-github-bot
left a comment
There was a problem hiding this comment.
zou3519 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Fixes pytorch#8560. Unblocks pytorch#10715. The assert (nDim <= uncompressedDims) was being triggered for a scalar tensor because we compute nDim to be 1 for a scalar tensor but uncompressedDim = 0. This PR changes it so that we compute nDim to be 0 for a scalar tensor. This works because indexing in a kernel depends on nDim. If nDim = 0, then offset is always 0, which is what we want. Some other (small) changes were necessary to make this work: - One cannot define a 0-length array `IndexType arr[0]` so the code guards against that - Needed to change some of the maxTensorInfoSize logic to handle the case when uncompressedDim == 0.
0899410 to
78651c2
Compare
facebook-github-bot
left a comment
There was a problem hiding this comment.
zou3519 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
zou3519 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
* upstream/master: (26 commits) cudnn 7 upgrade with spatialBN fix (pytorch#11291) Ignore FuseGraph Call on Windows (pytorch#11015) defer resolution of mkl to a cmake wrapper library (pytorch#11298) Cleanup dependency of distributed flags (pytorch#11221) Move minimal wrapdim functionality to core, remove THTensor include i… (pytorch#11283) Change includes from ATen/Storage.h to ATen/core/Storage.h (pytorch#11217) Fix scalar tensor assert in fusion compiler (pytorch#10952) Add dead code elimination pass (pytorch#10101) Distributed Data Parallel CPU module for C10D (pytorch#11168) Back out "[pt1][tensor] Add strides to caffe2::Tensor" Fix conv gradient conversion (pytorch#11312) Bag of clang tidy fixes for torch/csrc/ and torch/csrc/autograd (pytorch#11050) Sparse tensor printing; add NotImplemented autograd fn (pytorch#10181) Add convertToCaffe2Proto to python API fix doc for functional.dropout* (pytorch#10417) typo fix Tranpose2D -> Transpose2D (pytorch#11281) Remove THFinalizer Forward declarations of needed curand functions (pytorch#10911) nomnigraph - simplify core graph API and test (pytorch#11256) Small fixes to cppdocs for sync script (pytorch#11300) ...
Summary: Fixes pytorch#8560. Unblocks pytorch#10715. The assert (nDim <= uncompressedDims) was being triggered for a scalar tensor because we compute nDim to be 1 for a scalar tensor but uncompressedDim = 0. This PR changes it so that we compute nDim to be 0 for a scalar tensor. This works because indexing in a kernel depends on nDim. If nDim = 0, then offset is always 0, which is what we want. Some other (small) changes were necessary to make this work: - One cannot define a 0-length array `IndexType arr[0]` so the code guards against that - Needed to change some of the maxTensorInfoSize logic to handle the case when uncompressedDim == 0. cc apaszke zdevito Pull Request resolved: pytorch#10952 Differential Revision: D9544607 Pulled By: zou3519 fbshipit-source-id: 2b873f47e2377125e1f94eb1b310a95cda51476c
Fixes #8560.
Unblocks #10715.
The assert (nDim <= uncompressedDims) was being triggered for a scalar
tensor because we compute nDim to be 1 for a scalar tensor but
uncompressedDim = 0.
This PR changes it so that we compute nDim to be 0 for a scalar tensor. This
works because indexing in a kernel depends on nDim. If nDim = 0, then
offset is always 0, which is what we want.
Some other (small) changes were necessary to make this work:
IndexType arr[0]so the codeguards against that
case when uncompressedDim == 0.
cc @apaszke @zdevito