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

Fix gradients of variational states with complex parameters #1785

Merged
merged 7 commits into from
May 2, 2024

Conversation

inailuig
Copy link
Collaborator

@inailuig inailuig commented May 2, 2024

Adds the missing factor 2 in force_to_grad for complex parameters.

We need to multiply the gradient of the complex parameters by 2, not only the real ones.
Otherwise the gradient is different between the complex-param model and the equivalent real one.

This in particular affects models with mixed real/complex parameters where so far the learning rate for the complex ones was half the learning rate of the real params.

@inailuig inailuig marked this pull request as draft May 2, 2024 14:22
@PhilipVinc
Copy link
Member

That's amazing! I always suspected this . Thank you!

Can you add a test that would otherwise fail, with mix ed parameters?

@inailuig inailuig force-pushed the fix_grad_prefactor branch 2 times, most recently from b458d24 to 42848be Compare May 2, 2024 16:05
Copy link
Member

@PhilipVinc PhilipVinc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing thanks!

@inailuig inailuig marked this pull request as ready for review May 2, 2024 16:47
@inailuig inailuig changed the title Add the missing factor 2 in force_to_grad for complex parameters Fix gradients of variational states with complex parameters May 2, 2024
@PhilipVinc PhilipVinc merged commit bf7e657 into netket:master May 2, 2024
8 of 11 checks passed
@inailuig inailuig deleted the fix_grad_prefactor branch May 2, 2024 18:51
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

Successfully merging this pull request may close these issues.

None yet

2 participants