Skip to content

api: add mul interp mode#2788

Open
mloubout wants to merge 6 commits into
mainfrom
strict-mul-eval-at
Open

api: add mul interp mode#2788
mloubout wants to merge 6 commits into
mainfrom
strict-mul-eval-at

Conversation

@mloubout
Copy link
Copy Markdown
Contributor

@mloubout mloubout commented Nov 10, 2025

  • Add a mode for symmetric interpolation (sometime needed for better stability)
  • Added notebook on interp/staggered
  • Added lots of tests for it

@mloubout mloubout added the API api (symbolics, types, ...) label Nov 10, 2025
@mloubout mloubout force-pushed the fd-eval-add branch 6 times, most recently from 80c1334 to 01d3d1a Compare November 14, 2025 12:57
@mloubout mloubout force-pushed the fd-eval-add branch 8 times, most recently from 0823c5f to 7821fc1 Compare November 21, 2025 14:48
@mloubout mloubout force-pushed the fd-eval-add branch 4 times, most recently from f91130f to 136f771 Compare December 1, 2025 12:08
@mloubout mloubout force-pushed the fd-eval-add branch 3 times, most recently from edd10f2 to 26490d4 Compare December 4, 2025 20:24
Base automatically changed from fd-eval-add to main December 8, 2025 17:37
@mloubout mloubout force-pushed the strict-mul-eval-at branch 4 times, most recently from 233c8fb to 99fd21a Compare December 11, 2025 19:36
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 11, 2025

Codecov Report

❌ Patch coverage is 96.73913% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.42%. Comparing base (ddb2459) to head (883d31e).

Files with missing lines Patch % Lines
devito/core/operator.py 61.53% 3 Missing and 2 partials ⚠️
devito/finite_differences/interpolation.py 93.10% 1 Missing and 1 partial ⚠️
devito/operator/operator.py 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2788      +/-   ##
==========================================
+ Coverage   83.35%   83.42%   +0.07%     
==========================================
  Files         248      249       +1     
  Lines       51734    51984     +250     
  Branches     4463     4479      +16     
==========================================
+ Hits        43122    43368     +246     
- Misses       7859     7860       +1     
- Partials      753      756       +3     
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX 68.65% <58.24%> (-0.04%) ⬇️
pytest-gpu-gcc- 78.14% <96.73%> (+0.08%) ⬆️
pytest-gpu-icx- 78.07% <96.73%> (+0.10%) ⬆️
pytest-gpu-nvc-nvidiaX 69.20% <58.24%> (-0.04%) ⬇️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mloubout mloubout force-pushed the strict-mul-eval-at branch from 99fd21a to 198aedc Compare January 7, 2026 03:53
@mloubout mloubout force-pushed the strict-mul-eval-at branch from 198aedc to 8cc5c13 Compare May 11, 2026 23:18
@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@mloubout mloubout force-pushed the strict-mul-eval-at branch 3 times, most recently from 2f6f0cf to 64aca73 Compare May 11, 2026 23:58
@mloubout mloubout marked this pull request as ready for review May 12, 2026 00:14
@mloubout mloubout force-pushed the strict-mul-eval-at branch 3 times, most recently from da47926 to be046cb Compare May 12, 2026 03:23
Comment thread devito/core/cpu.py Outdated

# Code generation options for derivatives
o['expand'] = oo.pop('expand', cls.EXPAND)
o['interp-mode'] = oo.pop('interp-mode', cls.INTERP_MODE)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpicking, this should stay in a separate section being something related to the numerics, rather than performance (which is the case of all other opt-options).
As in, later on, perhaps around line 103, with a suitable comment

I'm also not sure if we really want this to be an Operator opt-option, as opposed to a Function parameter for example or something else

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it also won't play well with the tuner this way, unless we specialise it somehow

Comment thread devito/types/utils.py
return not self or all(s == 0 for s in self)

def __eq__(self, other):
# Two empty-or-all-zero Staggerings are equivalent regardless of arity
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

imho this could/should rather be normalized at __new__

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well not easily no, because you can't have a wide variety of things, like 2D functions in 3D and so on that you can't really normalize.

evalf_table[Pow] = evalf_table[sympy.Pow]


def _interp_mapper(source, target, dims):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

would it be worth moving all of the interpolation-related stuff into a separate module finite_differences/interpolations.py ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seconded - it would make it easier to find things and limit the size of files

Comment thread devito/finite_differences/differentiable.py Outdated
Comment thread devito/core/operator.py Outdated
Interpolation mode used by `Mul._eval_at` when projecting a multi-factor
expression onto a target staggered location:

* `'direct'` (default): each factor is shifted to `func`'s location
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what's func here (and below) ?

Comment thread devito/core/operator.py Outdated
`func`'s, the symmetric form `I * (a * I^T * b)` is built -- all
factors are gathered at the highest-priority "block" location via
`I^T`, multiplied there, and the product is interpolated to `func`
via `I`. Use this for operators whose continuous form decomposes as
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this sentence "Use this ..." doesn't seem to be the complement of the other sentence you used for the "direct" mode above i.e. "the mode to pick unless ..."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nitpick: might as well call it 08_staggered_interpolation for minimum ambiguity. Looks super good though. Is this a Claude job? Less typos than usual 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a side-quest PR, so yeah definitely claude tutorial :D

evalf_table[Pow] = evalf_table[sympy.Pow]


def _interp_mapper(source, target, dims):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seconded - it would make it easier to find things and limit the size of files

@mloubout mloubout force-pushed the strict-mul-eval-at branch 4 times, most recently from cb9b140 to 64ef414 Compare May 12, 2026 16:27
@mloubout mloubout force-pushed the strict-mul-eval-at branch from 64ef414 to 883d31e Compare May 12, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API api (symbolics, types, ...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants