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

LP-SparseMap as a Pytorch layer? #1

Open
OhadRubin opened this issue Feb 4, 2020 · 4 comments
Open

LP-SparseMap as a Pytorch layer? #1

OhadRubin opened this issue Feb 4, 2020 · 4 comments

Comments

@OhadRubin
Copy link

Hey,
Recently Tensorflow and Pytorch have implemented a way to pass tensors from one framework to another using DLpack, and I was wondering if it is possible to somehow use your code in a pytorch model with this type of binding.
Thanks,
Ohad

links:
https://tvm.apache.org/2018/08/10/DLPack-Bridge
tensorflow/tensorflow#24453

@vene
Copy link
Contributor

vene commented Feb 6, 2020

Hi,

I haven't looked into DLpack yet, but:

LP-SparseMAP can already be used as a pytorch layer, there is no need for special bindings. The example [1] shows how to compute the solution and a Jacobian-vector product; you can build a pytorch.autograd.Function that calls the solve_qp_ad3 method in the forward pass and the jacobian_vec method in the backward pass. (The input tensors need to be mapped to cpu before calling, though.)

I'm a bit busy at the moment but I can provide an example in a few days.

[1] https://github.com/deep-spin/lp-sparsemap/blob/master/examples/sequence.py

@OhadRubin
Copy link
Author

I understand.
Will there be a GPU based solution in the future?

@vene
Copy link
Contributor

vene commented Feb 8, 2020

This would be great, but seems to me q difficult, since it would require a full rewrite of AD3 for the GPU: including MAP/QP algorithms for the factors, the active set algorithm, and ADMM. These algorithms are not very well suited for GPU computing. Moreover, if trying to solve a batch of different factor graphs at the same time, vectorization would be nontrivial beyond special cases, so a general solution might be trickier than it seems.

Have you already determined that SparseMAP on the CPU is your bottleneck?

@OhadRubin
Copy link
Author

Well no, but your method is said to be end-to-end and usually that means that all the computation is done on the GPU, one of the many bottlenecks for RL for example is the fact that you have to step inside the environment (using the CPU).

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