Repository navigation
fix(idaklu): hand IDAS each parameter's magnitude as pbar - #5783
Merged
Merged
Conversation
IDASetSensParams with each differentiated parameter's magnitude, one row per input set through a keyword-only pbar argument after logger. Bumps pybammsolvers to 0.10.0, which pybamm now requires.
BradyPlanden
force-pushed
the
a2b/idas-sensitivity-scales
branch
from
September 23, 2026 18:54
3400a8e to
8104193
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5783 +/- ##
=======================================
Coverage 98.15% 98.15%
=======================================
Files 341 341
Lines 33902 33908 +6
=======================================
+ Hits 33275 33281 +6
Misses 627 627 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
martinjrobins
approved these changes
Sep 25, 2026
martinjrobins
left a comment
Contributor
There was a problem hiding this comment.
thanks @BradyPlanden, this all looks good to me!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
IDAKLUSolvercomputes forward sensitivities with IDAS but never calledIDASetSensParams, so every sensitivity scalepbarstayed at 1. IDAS holds the scaled sensitivitypbar * dy/dpto the state tolerances. For a parameter as small asChen2020's positive particle diffusivity (4e-15),dy/dpis around 1e14, and the unscaled column breaks the Newton convergence test through rounding alone. A DFN solve for that sensitivity fails withIDA_CONV_FAILat everyrtol = atolfrom 1e-8 to 1e-12. At looser tolerances it survives many convergence failures but runs 4.7x slower than it needs to at the defaults.This PR passes
pbar = |p|per differentiated parameter and input set, which makes the error weighting independent of the parameter's units. Measured against unit scales on the same build:pbar = 1(main) →pbar = |p|rtol = atol1e-8 to 1e-12IDA_CONV_FAIL→ converges, gradient within 3e-7 of finite differencesThe last row is the cost: the sensitivity to a large parameter is now held to the state tolerances as well, which is up to 1.6x slower at the defaults (and faster at tight tolerances, where it is also more accurate).
For pybammsolvers maintainers:
solvegains a keyword-onlypbarargument afterlogger, so existing positional callers are unaffected. Because pybamm always passes it, this bumps pybammsolvers to 0.10.0 and pinspybammsolvers>=0.10.0,<0.11.0. #5782 (solver statistics) makes the identical version bump.|p|per input set, in sensitivity-column order, and passes it to the solver group.pbar's dimensions, rows and columns (raisingValueError). An emptypbarkeeps IDAS's unit default.pbar, and re-applies the scales after everyIDASensReInit, which resets them.This is one of the backend-neutral pre-flight PRs split out of the Rust execution engine (#5732). It has no Rust dependency. It overlaps #5782 (solver statistics) in
IDAKLUSolverGroup.cppand the IDAKLU tests, so whichever lands second needs a rebase.Type of change
Add an entry under
# [Unreleased]in CHANGELOG.md, in one of## Breaking changes,## Deprecated,## Features, or## Bug fixes(include PR number; breaking and deprecation entries need a one-line migration note). Internal-only PRs — refactor, docs, CI, tests — can skip this. See RELEASE.md for the full policy.Important checks:
Please confirm the following before marking the PR as ready for review:
nox -s pre-commitnox -s testsnox -s doctests