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

Indexing -> torch.gather for better performance? #20

Open
squidrice21 opened this issue May 7, 2024 · 3 comments
Open

Indexing -> torch.gather for better performance? #20

squidrice21 opened this issue May 7, 2024 · 3 comments

Comments

@squidrice21
Copy link

Hi,

Thanks for the great research and sharing the code! I've been using large-steps preconditioning for my project and it's working well. Recently, I worked on improving the performance of my pytorch code and found that changing from pytorch indexing to torch.gather gives me about 30x speed up. I also visualized the computational graph of the part using large-steps preconditioning via torchviz and saw DifferentiableSolveBackward -> IndexBackward0. This indexing seems to come from this repo. I'm pretty satisfied with the speed of the current version but just wondering if it can be further improved by switching to torch.gather.

@bathal1
Copy link
Collaborator

bathal1 commented May 27, 2024

Hi,

Thanks for bringing this up ! Do you have more information regarding where indexing happens in the computation graph?

@squidrice21
Copy link
Author

Thanks for replying. Here's my computation graph (generated using torchviz):
graph

Note the IndexBackwards following the DifferentiableSolveBackward (I'm not sure why there are two streams of operations...). I think they are from the large-steps code. There are also some copyslices, which may introduce some performance overheads.

@bathal1
Copy link
Collaborator

bathal1 commented May 27, 2024

Are you using the renderer implemented in this repo, or only the parameterization provided in the pip package ? If you are only using the parameterization, could you please provide a minimal reproducer for this behavior ?

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

2 participants