Skip to content

Make PyACECalculator deal with pickle#99

Open
pmrv wants to merge 4 commits into
ICAMS:masterfrom
pmrv:pickle
Open

Make PyACECalculator deal with pickle#99
pmrv wants to merge 4 commits into
ICAMS:masterfrom
pmrv:pickle

Conversation

@pmrv

@pmrv pmrv commented Apr 3, 2026

Copy link
Copy Markdown

Pull Request Template

Thank you for contributing to our project! Please review the checklist and fill out the details below.

Description of Changes

The default reducer puts out the evaluator and a bunch of other C++ extension types that pickle then chokes on. Side step the problem here by providing a reducer that just makes unpickling equivalent to a new instantiation. The only difficulty here is that basis_set stays a file name if initialized like that and that PyACECalculator.init expects it as a positional argument.
Avoid the filename by dumping the whole bbasis config, so that unpickling can happen on other machines or in different locations.

Checklist

  • Code is well-documented.
  • All tests have been run and passed.
  • Relevant documentation has been updated if necessary.

License Agreement

By submitting this pull request, I agree that:

  • The code submitted in this pull request will be distributed under the Academic Software License (free for academic non-commercial use, not free for commercial use), see LICENSE.md for more details.
  • The copyright for the code, including the submitted code, remains with Ruhr University Bochum. Ruhr University Bochum retains the right to transfer or modify the copyright.

Thank you for your contribution!

pmrv and others added 2 commits April 3, 2026 17:41
The default reducer puts out the evaluator and a bunch of
other C++ extension types that pickle then chokes on.
Side step the problem here by providing a reducer that just
makes unpickling equivalent to a new instantiation.
The only difficulty here is that basis_set stays a file name
if initialized like that and that PyACECalculator.__init__
expects it as a positional argument.
Avoid the filename by dumping the whole bbasis config, so that
unpickling can happen on other machines or in different locations.
ACECTildeBasisSet cannot be converted back to a BBasisConfiguration,
so the previous reducer failed for calculators loaded from .ace/.yace
potentials. Pass the Ctilde basis set through as is instead; its
pybind11 binding already provides native pickle support.

While at it, preserve the constructor kwargs (recursive_evaluator,
gamma bounds, etc.) across the pickle round trip via a module-level
helper, and drop the stale todict() state that previously leaked the
original basis_set parameter (e.g. a file name) into the unpickled
instance.

Add round-trip tests for B-basis, Ctilde and recursive Ctilde
calculators.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BHj67uGNHN5bMH7LPoCR1J
claude and others added 2 commits July 15, 2026 17:13
Address review: cover the Al-Ni .yace test potential and compare
energies/forces along a whole BFGS dimer minimization trajectory
between the original and the unpickled calculator.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BHj67uGNHN5bMH7LPoCR1J
Support pickling of calculators with Ctilde basis sets
@pmrv

pmrv commented Jul 15, 2026

Copy link
Copy Markdown
Author

.yace based potentials are also supported now, and there some tests also that pass locally.

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.

2 participants