getkeops / keops

KErnel OPerationS, on CPUs and GPUs, with autodiff and without memory overflows
https://www.kernel-operations.io
MIT License
1.03k stars 65 forks source link

[WIP] Implement RKeOps v2+ #279

Closed gdurif closed 1 year ago

gdurif commented 1 year ago

Switch from the old keops engine based on C++/Cmake to the new keopscore framework based on a meta-programming engine.

Implementation : directly use PyKeOps through reticulate to avoid maintaining two different binders for Python and R

TODOs

Note: WIP (not ready to merge)

See also TODOs.md

Edit (2023-03-31): ready to merge

AmelieVernay commented 1 year ago

@gdurif, going from R data to Numpy arrays seems to work. I also reproduced this example with R data to Torch tensors and the idea is the same.

gdurif commented 1 year ago

@AmelieVernay that's great!

From there, we can do the following:

AmelieVernay commented 1 year ago

@gdurif, calling pykeops.numpy.Genred() from keops_kernel() works well, I provided a minimal example in eg_GaussianRBF.R with a comparison with pykeops only. I am not sure it is useful to let RKeOps users choose between pykeops.numpy.Genred() and pykeops.torch.Genred(), what would be the benefit? About gradients, it is ok to compute gradients based on formulae like Grad(formula ,variable_to_differentiate, input_of_the_gradient) (see here) but I had trouble with the keops_grad() syntax like in the second example here because the new variable at which the gradient is computed is not given in args and pykeops does not handle this (as far as I know). We could add it inside keops_kernel() but It would mean inferring the type (Vi, Vj...) and the inner_dim. Maybe you have an idea?

gdurif commented 1 year ago

Merged into main. CI error related to lint error outside rkeops.