Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange runtime results #2

Open
cszer opened this issue Aug 28, 2020 · 10 comments
Open

Strange runtime results #2

cszer opened this issue Aug 28, 2020 · 10 comments

Comments

@cszer
Copy link

cszer commented Aug 28, 2020

Hello , i tested inference speed and compared it with simple torchvision resnet50 .
I used 2080ti and pytorch 1.4
Results are :
torchvision resnet50 - 13-15 ms
axial-resnet-s - 79-81ms
But in the paper authors show that inference speed of L model is comparable with Resnet101

@cszer
Copy link
Author

cszer commented Aug 28, 2020

I tested models on 224х224 torch.rand tensor

@csrhddlam
Copy link
Owner

Hello, thanks for testing it. Please note that this is a re-implementation and we haven't tried to match the inference time as the original code.

I think the main mismatch comes from implementation differences, possibly the positional encoding or batch normalization. In addition, I think the runtime won't increase much if you test it on L models -- we only change the width of the model and keep the depth the same, while ResNet doubles the depth.

@netw0rkf10w
Copy link

@csrhddlam Why don't you share the original TensorFlow implementation but a PyTorch re-implementation instead? I'm a bit confused...

@csrhddlam
Copy link
Owner

csrhddlam commented Aug 30, 2020

It would be almost impossible to release the original code in tensorflow (which runs on TPU), because it is Google property, and it depends on some other packages which are also Google property, e.g. stand-alone self-attention and panoptic-deeplab.

@netw0rkf10w
Copy link

@csrhddlam Hmm... Has Google recently changed their policy? They used to release TensorFlow code for their published papers...

@csrhddlam
Copy link
Owner

No, as far as I know. And sorry for the confusion. As I said, our original code depends heavily on stand-alone self-attention and panoptic-deeplab. However, they have not released their code and we are not authorized to release their code, so we cannot release our original code. Instead of waiting for their releases, we re-implement the work here in PyTorch to let the community access most details of our work as soon as possible.

@netw0rkf10w
Copy link

@csrhddlam I see. Thanks for the reply!
Good work by the way. Congratulations!

@csrhddlam
Copy link
Owner

csrhddlam commented Sep 1, 2020

Just investigated the inference time a bit. Here is my trace on a GPU. I tested it with both pytorch 1.1 and 1.6, and found similar results.
image
You can see that the relative positional embedding is taking way more time than a convolution.
image
In addition, reshaping, squeezing, and permutating are also taking way more time than bmm, where actual computation happens.

There is much room to optimize the code in this repo. Even the original TF code was optimized for TPU and tested directly on GPU. So we would expect that the inference time could be improved a lot when it is well optimized.

@netw0rkf10w
Copy link

einsum seems to have some performance issues, so maybe directly using bmm could be faster.

@csrhddlam
Copy link
Owner

Thanks for the pointer. I wasn't aware of the issue.

einsum in PyTorch looks less optimized than einsum_v2 in TensorFlow. And I agree that directly using bmm, together with some smart permute and view could be faster in PyTorch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants