Skip to content

Support pickling of calculators with Ctilde basis sets#1

Merged
pmrv merged 2 commits into
picklefrom
claude/pickle-ctilde-potentials-3f3gke
Jul 15, 2026
Merged

Support pickling of calculators with Ctilde basis sets#1
pmrv merged 2 commits into
picklefrom
claude/pickle-ctilde-potentials-3f3gke

Conversation

@pmrv

@pmrv pmrv commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Pull Request Template

Description of Changes

Extends the pickle support from the pickle branch (ICAMS#99) to calculators built from Ctilde potentials, not just B-basis ones.

  • PyACECalculator.__reduce__ previously always called self.basis.to_BBasisConfiguration(), which only exists on ACEBBasisSet, so pickling a calculator loaded from an .ace/.yace potential failed. The reducer now branches on the basis type: B-basis potentials are still dumped as a full BBasisConfiguration (portable across machines and directories), while ACECTildeBasisSet objects are passed through directly, relying on the native pickle support already present in their pybind11 bindings. Ctilde basis sets cannot be converted back to a B-basis representation, so a pass-through is the only option there.
  • Constructor kwargs (recursive_evaluator, recursive, gamma_lower_bound, etc.) are now preserved across the round trip via a module-level _unpickle_calculator helper, so e.g. a recursive Ctilde evaluator is restored as such instead of falling back to the defaults.
  • Drops the stale todict() state from the reduce tuple, which previously leaked the original basis_set parameter (e.g. a file name) into the unpickled instance's __dict__ (the pop result was discarded).

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.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BHj67uGNHN5bMH7LPoCR1J


Generated by Claude Code

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

@pmrv pmrv left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

also test .yace file from the tests direction

run a minimization of the dimer to test a few more forces/energies for consistency.

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
@pmrv pmrv merged commit 39f7d9f into pickle Jul 15, 2026
1 check failed
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