Skip to content

WIP: New ies API#13082

Draft
dafeda wants to merge 1 commit intoequinor:mainfrom
dafeda:new-ies-api
Draft

WIP: New ies API#13082
dafeda wants to merge 1 commit intoequinor:mainfrom
dafeda:new-ies-api

Conversation

@dafeda
Copy link
Copy Markdown
Collaborator

@dafeda dafeda commented Mar 10, 2026

Issue
Resolves #12944

The new API fixes a bug in subspace inversion and no longer exposes the argument inversion.
See snapshot test test_update_snapshot.
The old implementation of subspace is only correct when R = I.
Instead, the API exposes the argument truncation where truncation=1.0 is the same as EXACT and anything less than 1.0 is SUBSPACE.

I've made it so the change is backward compatible in the sense that default is truncation=1.0

The new API is stricter with regards to types as it requires that all inputs are of the exact same type.
In ert, we don't know what type the parameters have when initializing strategies.
So, I'm casting everything to float32 before udpating.

  • PR title captures the intent of the changes, and is fitting for release notes.
  • Added appropriate release note label
  • Commit history is consistent and clean, in line with the contribution guidelines.
  • Make sure unit tests pass locally after every commit (git rebase -i main --exec 'just rapid-tests')

When applicable

  • When there are user facing changes: Updated documentation
  • New behavior or changes to existing untested code: Ensured that unit tests are added (See Ground Rules).
  • Large PR: Prepare changes in small commits for more convenient review
  • Bug fix: Add regression test for the bug
  • Bug fix: Add backport label to latest release (format: 'backport release-branch-name')

@dafeda dafeda self-assigned this Mar 10, 2026
@dafeda dafeda force-pushed the new-ies-api branch 4 times, most recently from a1f1076 to 8e8359b Compare March 13, 2026 07:01
Copy link
Copy Markdown
Collaborator

@tommyod tommyod left a comment

Choose a reason for hiding this comment

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

Looked over at it looks good to me! Great work as always!

To reiteratie on float32: this is just a choice, we could use float64. We could also re-write the logic in iterative_ensemble_smoother a bit to facilitate ERT integration in an easier way. The current logic is that the user must give all arrays used for the assimilation in the same dtype. The idea is that it makes little sense to use e.g. float32 for parameters but float64 for observations, or whatever - so dtypes must match or iterative_ensemble_smoother will assume a user error and raise. This is admittedly a bit strict perhaps.

@tommyod
Copy link
Copy Markdown
Collaborator

tommyod commented Mar 13, 2026

Another comment that I want to fill out for future reference: one of the tests has a large diff. This is expected, because we now use a scaled version of subspace inversion. See these PRs for more information:

Essentially we used a version of subspace inversion before that was "unscaled". This version strictly speaking is mathematically WRONG for anything but an identity covariance matrix. In previous readings of the relevant papers I thought that "scaling" refers to numerical scaling, but it does not - if we use the "unscaled" version we actually solve a rough approximation of the equation that we want to solve. Scaling is necessary to achieve good results on almost all problems, but it should probably never have been called "scaling" and an unscaled version should arguably never have been presented in the paper. This lead to a lot of confusion, but is is fixed now. The scaled version has no additional computational cost on diagonal covariance matrices.

@dafeda dafeda force-pushed the new-ies-api branch 6 times, most recently from c142e57 to f20e31d Compare March 27, 2026 09:31
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.23%. Comparing base (36b9fb9) to head (870a5f6).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/ert/analysis/_update_strategies/_distance.py 71.42% 4 Missing ⚠️
src/ert/analysis/_update_strategies/_standard.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13082      +/-   ##
==========================================
- Coverage   90.31%   90.23%   -0.08%     
==========================================
  Files         453      453              
  Lines       31285    31287       +2     
==========================================
- Hits        28256    28233      -23     
- Misses       3029     3054      +25     
Flag Coverage Δ
cli-tests 37.42% <77.14%> (-0.04%) ⬇️
gui-tests 67.37% <74.28%> (-0.10%) ⬇️
performance-and-unit-tests 77.73% <78.57%> (-0.10%) ⬇️
test 46.40% <34.28%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 27, 2026

Merging this PR will improve performance by 43.51%

⚡ 1 improved benchmark
✅ 35 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
test_and_benchmark_adaptive_localization_with_fields 727.4 ms 506.9 ms +43.51%

Comparing dafeda:new-ies-api (870a5f6) with main (36b9fb9)

Open in CodSpeed

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.

New default inversion schema

3 participants