functorch icon indicating copy to clipboard operation
functorch copied to clipboard

Speed up Jacobian in PyTorch

Open caowen1510957 opened this issue 3 years ago • 0 comments

Hello, I saw that here is a place to leave suggestions and use cases.

I am working on solving PDEs (numerical method) using PyTorch, I cannot avoid Jacobian (Newton iteration, used for solving nonlinear equations), namely, the Jacobian matrix of residual vector. But it is too slow. Here is the runtime (get_residual is the function I wrote to construct the equation I need to solve, and Jacobian is the built-in function, imported from PyTorch): image

After I used Functorch, the performance is way better image

I don't know if there is more room to speed up, attach is my code as the use case, when you increase Nx, Ny, and Nz, the runtime is crazy. main.txt

caowen1510957 avatar Aug 11 '22 04:08 caowen1510957