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

[WIP] Download IDAKLU from pybammsolvers #4487

Draft
wants to merge 21 commits into
base: develop
Choose a base branch
from

Conversation

kratman
Copy link
Contributor

@kratman kratman commented Oct 3, 2024

Description

This will separate the IDAKLU C++ code from pybamm.

Fixes #3564

Type of change

This should speed up CI by skipping the build of the C++ code.

  • Optimization (back-end change that speeds up the code)

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 tests pass: $ python run-tests.py --all (or $ nox -s tests)
  • The documentation builds: $ python run-tests.py --doctest (or $ nox -s doctests)

You can run integration tests, unit tests, and doctests together at once, using $ python run-tests.py --quick (or $ nox -s quick).

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@kratman kratman self-assigned this Oct 3, 2024
@kratman
Copy link
Contributor Author

kratman commented Oct 3, 2024

A new link error cropped up, but it looks like we could get a lot of savings on time with this update.

Edit: Most of the run time appears to be in the integration tests, so unfortunately the time savings are not as good as I would have hoped.

@agriyakhetarpal
Copy link
Member

The linkage error is the same one as #3783, coming from CasADi's plugin system. I am not sure if it's worth fixing it, since it was fixed by @martinjrobins for the linear interpolant case by dropping down to Python but IIRC there wasn't a way in CasADi for doing it for the cubic

@kratman
Copy link
Contributor Author

kratman commented Oct 3, 2024

@agriyakhetarpal Yeah I was looking at that issue as well. As far as I can tell CasADI sets a path for plugins. I am trying to see if there is a decent workaround since this was part of #4464

My guess is that the wheels for the next release will be broken as well, but I have not confirmed it yet

@agriyakhetarpal
Copy link
Member

agriyakhetarpal commented Oct 3, 2024

There is a workaround for Linux and macOS, but not for Windows (different toolchain); sadly, it's not decent enough to include. I think I'll raise a PR upstream in CasADi to get one part of the linkage going and see if we can migrate to a non-MSVC toolchain (which can potentially help provide that workaround for this on Windows later on). It's been on my list of things to do for a while, but I've yet to do it.

@kratman
Copy link
Contributor Author

kratman commented Oct 3, 2024

This is fixed locally with this: export CASADIPATH=.venv/lib/python3.12/site-packages/casadi

Copy link

codecov bot commented Oct 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.68%. Comparing base (4223be8) to head (772e782).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4487      +/-   ##
===========================================
- Coverage    99.26%   98.68%   -0.59%     
===========================================
  Files          302      302              
  Lines        22889    22879      -10     
===========================================
- Hits         22721    22577     -144     
- Misses         168      302     +134     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@agriyakhetarpal
Copy link
Member

This is fixed locally with this: export CASADIPATH=.venv/lib/python3.12/site-packages/casadi

Yes, won't work with Windows

@martinjrobins
Copy link
Contributor

martinjrobins commented Nov 6, 2024

I had a look at this. The linker error is the same as I came across for the case of linear interpolation. The solution there was to swap to using the direct casadi function rather than their plugin system, which won't work if the casadi function is evaluated in C++ for windows as we compile everything statically.

I think I might be able to access the direct bspline interface by calculating the spline coefficients in scipy and then use the casadi Function.bspline function to construct a bspline. Cross fingers this doesn't use the plugin system anywhere! Going to try this out in #4570

@kratman
Copy link
Contributor Author

kratman commented Nov 6, 2024

I had a look at this. The linker error is the same as I came across for the case of linear interpolation. The solution there was to swap to using the direct casadi function rather than their plugin system, which won't work if the casadi function is evaluated in C++ for windows as we compile everything statically.

I think I might be able to access the direct bspline interface by calculating the spline coefficients in scipy and then use the casadi Function.bspline function to construct a bspline. Cross fingers this doesn't use the plugin system anywhere!

Yeah I was going to approach this by seeing if I could just change the build itself. It is something that should work if we are compiling and delivering everything correctly. If that does not work, then I will look at workarounds for interpolation

@kratman
Copy link
Contributor Author

kratman commented Nov 6, 2024

I expect to work on this again next week, I have been caught up with other stuff

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.

Tracking issue: migrate to scikit-build-core
3 participants