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

The return of the NaN #72

Open
jackbaker1001 opened this issue Sep 19, 2023 · 8 comments
Open

The return of the NaN #72

jackbaker1001 opened this issue Sep 19, 2023 · 8 comments
Assignees

Comments

@jackbaker1001
Copy link
Collaborator

I've noticed that for a few basis sets, NaN gradients are appearing again when trained using the DIIS SCF loops but not the linear mixing loops.

I think this is likely because degenerate eigenvectors/eigenvalues are being encountered in the calls to jnp.linalg.eigh routines. We can try switching these out for our custom safe_eigh which will hopefully fix the bug.

@jackbaker1001 jackbaker1001 self-assigned this Sep 19, 2023
@jackbaker1001
Copy link
Collaborator Author

jackbaker1001 commented Sep 19, 2023

Changing to safe_eigh did not fix things! I'm seeing this with diatomic molecules using 6-31G bases. I.e,

Na2_bl = 3.0789
Na2_mol =  pyscf.M(
        atom = 'Na %.5f 0.0 0.0; Na %.5f 0.0 0.0' % (-Na2_bl/2, Na2_bl/2),
        basis = '6-31G'
)

and gd.energy_and_density_loss

@jackbaker1001
Copy link
Collaborator Author

although I have now noticed that it also occurs in gd.mse_energy_loss

@jackbaker1001
Copy link
Collaborator Author

And it is not just the gradients which are NaN, it is also the loss itself!

@PabloAMC
Copy link
Collaborator

PabloAMC commented Sep 20, 2023

@jackbaker1001 I can't replicate the issue with the above molecule in the 4th basic example script. The only change I made was including

from .eigenproblem import safe_fock_solver, safe_eigh

in the utils.__init__.py, as safe_eigh would not import otherwise...

@jackbaker1001
Copy link
Collaborator Author

If you made clips which resolved NaN's here @PabloAMC can you push them to the branch so I can test on my end?

@PabloAMC
Copy link
Collaborator

@jackbaker1001 test the new branch I created https://github.com/XanaduAI/GradDFT/tree/72b-the-return-of-the-nan. The only change is the clip constant lowering to 1e-25. I tested a few extra basis sets, but they seem to work fine.

@jackbaker1001
Copy link
Collaborator Author

@PabloAMC I still get NaNs on this branch running the self-consistent training in the notebook ~examples/intermediate_notebooks/training_methods_03.ipynb when switching the basis sets for all molecules to 6-31G.

Can you tell me if this happens in your local install please?

Screenshot 2023-09-25 at 2 46 32 PM

@PabloAMC
Copy link
Collaborator

Did lowering the clipping constant help? I can't replicate the issue on my end with the current one.

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

When branches are created from issues, their pull requests are automatically linked.

2 participants