fishjojo / pyscfad

PySCF with auto-differentiation
Other
63 stars 15 forks source link

Conversion function between pyscf and pyscfad #22

Open sunqm opened 6 months ago

sunqm commented 6 months ago

The conversion interface to gpu4pyscf repo is mostly completed. I'm considering to create a similar conversion function for pyscfad. What is your opinion?

fishjojo commented 6 months ago

Currently, the most common practice of AD is something like

mol = gto.Mole()
def fn(mol):
    return RHF(mol).kernel()
g = jax.grad(fn)(mol)

Only the perturbations are defined outside the function being differentiated, and fn in principle should be pure. I guess simply creating a conversion method within Mole may be good enough. And inside the function, we can do something like mol.RHF().kernel(), although I'm not 100% sure if this would work. I'm also adding a Pytorch backend. Maybe we can wait until that is done.