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

Model parallelization #645

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

YannickNoelStephanKuhn
Copy link

Description

Makes pybop.Dataset instances and instances of pybop.models.base_echem children both copyable and pickleable, enabling all the usual object-oriented and parallelization patterns.

Issue reference

Fixes #642

Type of change

  • [ ✓ ] Bug Fix: A non-breaking change that addresses an issue.
  • [ ✓ ] Testing: Additional tests to improve coverage or confirm functionality.

Key checklist:

  • [ ✓ ] No style issues: $ pre-commit run (or $ nox -s pre-commit) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)
  • [ ✓ ] All unit tests pass: $ nox -s tests
  • [ ✓ ] The documentation builds: $ nox -s doctest

You can run integration tests, unit tests, and doctests together at once, using $ nox -s quick.

Further checks:

  • [ ✓ ] Code is well-commented, especially in complex or unclear areas.
  • [ ✓ ] Added tests that prove my fix is effective or that my feature works.
  • [ ✓ ] Checked that coverage remains or improves, and added tests if necessary to maintain or increase coverage.

@YannickNoelStephanKuhn
Copy link
Author

There are some integration tests about half-cell models that are failing, all with the following message:

ERROR tests/integration/test_half_cell_model.py::TestHalfCellModel::test_design_costs - AttributeError: module 'pybamm.models.full_battery_models.lithium_ion.electrode_soh_half_cell' has no attribute 'get_min_max_stoichiometries'

I'm pretty sure my code changes could not have caused this.

@YannickNoelStephanKuhn
Copy link
Author

But I found an issue with pickling models that have been used in predictions, so I will have to issue another commit anyways.

@YannickNoelStephanKuhn
Copy link
Author

Found it: whenever a problem gets evaluated, it consequently stops being pickleable. deepcopying it before evaluating "solves" that issue. So any parallel implementation might need to have a deepcopy step built-in. More details back in #642.

@YannickNoelStephanKuhn
Copy link
Author

There are some tests still failing, but I don't think they relate to changes I did.
I added a new attribute to problem classes, parallelizable, which defaults to the previous behaviour, and if set to True, always deepcopies the self._model when self.model is called.

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.

[Bug]: Non-serializable PyBOP models and datasets can not be copied or parallelized
2 participants