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 convergence error handler to prevent exceeding niter_max of 500 #54

Merged
merged 5 commits into from
Dec 8, 2023

Conversation

t-reents
Copy link
Collaborator

@t-reents t-reents commented Dec 6, 2023

This closes #48.

@bastonero To discuss: Once the limit of 500 is reached, should we try to further reduce alpha_mix or just do a last run with niter_max = 500 and the current value of alpha_mix?

@t-reents t-reents linked an issue Dec 6, 2023 that may be closed by this pull request
@bastonero
Copy link
Collaborator

Honestly I don't think increasing niter_max is a good solution either way. Possibly setting its maximum value to e.g. 200 is already enough. Then, we should try to reduce alpha_mix and set nmix to e.g. 8.

@bastonero bastonero self-requested a review December 6, 2023 14:13
@bastonero
Copy link
Collaborator

In the meantime: could you also provide a test for the new logic?

@t-reents
Copy link
Collaborator Author

t-reents commented Dec 6, 2023

So your idea would be keeping the current logic of reducing alpha_mix and adding something like?

if parameters.get('niter_max', 200) < 200: 
    # In case niter_max was specified and smaller than 200, increase it
    parameters['niter_max'] = min(parameters['niter_max'] * self.defaults.delta_factor_niter_max, 200)
elif 'niter_max' in parameters: 
    # This is the case where niter_max is already present and already set to the maximum of 200. 
    # Increase nmix to 8
    parameters['nmix'] = 8
else: 
    # In case niter_max was not specified in the beginning
    parameters['niter_max'] = 200

@bastonero
Copy link
Collaborator

Yeah, something like that. Nevertheless, we don't have sufficient data to prove this will work. You can see also recent discussions for the pw.x counter part in aiida-quantumespresso.

Possibly we can set niter_max=200, nmix=8 and alpha_mix=0.4 in the protocols, and then just reduce the alpha_mix as a solution. We don't have many strategies to play around with, and w/o proofs I think this is by now a safe option.

Pointless to keep increasing the number of iterations if then it doesn't help at all convergence.

Adapt the `convergence_not_reached` handler so that it only adjusts `alpha_mix`. `niter_max` is moved to the protocol.
@t-reents t-reents force-pushed the 48-hpbaseworkchain-convergence-error-handler branch from 5d78dc8 to 6263392 Compare December 7, 2023 13:47
@t-reents
Copy link
Collaborator Author

t-reents commented Dec 7, 2023

Sounds reasonable. I adapted the handler and moved the new parameters to the protocol. The tests fail somehow during the data regression, although they pass locally. I had to adapt the reference files due to the new protocols, so not sure whether the CI compares to the previous version or something like that. @bastonero Would be great if you could have a look

@bastonero
Copy link
Collaborator

bastonero commented Dec 7, 2023

Thanks @t-reents , looks good. I guess for some reason you don't have to specify num_mpiprocs_per_machine: 1 in resources. Try to add them and commit - it should solve the issue.

Copy link
Collaborator

@bastonero bastonero left a comment

Choose a reason for hiding this comment

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

All good, thanks @t-reents , just the two extra lines to remove.

tests/workflows/protocols/test_hubbard/test_default.yml Outdated Show resolved Hide resolved
tests/workflows/protocols/test_hubbard/test_default.yml Outdated Show resolved Hide resolved
@t-reents
Copy link
Collaborator Author

t-reents commented Dec 8, 2023

Thank you @bastonero, tests pass now

@bastonero bastonero merged commit 296ba48 into master Dec 8, 2023
6 checks passed
@bastonero
Copy link
Collaborator

Thanks @t-reents !

@bastonero bastonero deleted the 48-hpbaseworkchain-convergence-error-handler branch December 8, 2023 14:53
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.

HpBaseWorkChain: Convergence error-handler
2 participants