Skip to content

dsl: misc patches from recent updates (interp, sympy args) - #3002

Merged
mloubout merged 7 commits into
mainfrom
patch-sympy-tensor-args
Aug 13, 2026
Merged

dsl: misc patches from recent updates (interp, sympy args)#3002
mloubout merged 7 commits into
mainfrom
patch-sympy-tensor-args

Conversation

@mloubout

@mloubout mloubout commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
  • Fix origin/grid/coord override with new interp precompute
  • Fix sympy tensor args
  • Allow b= input to rotated lap function for born modeling

@mloubout mloubout added the API api (symbolics, types, ...) label Aug 12, 2026
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.63%. Comparing base (bb78b3e) to head (8f12021).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3002      +/-   ##
==========================================
+ Coverage   83.15%   83.63%   +0.48%     
==========================================
  Files         257      257              
  Lines       54185    54221      +36     
  Branches     4626     4629       +3     
==========================================
+ Hits        45056    45349     +293     
+ Misses       8321     8075     -246     
+ Partials      808      797      -11     
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX 68.54% <80.00%> (?)
pytest-gpu-gcc- 78.28% <100.00%> (+0.01%) ⬆️
pytest-gpu-icx- 78.20% <100.00%> (+0.01%) ⬆️
pytest-gpu-nvc-nvidiaX 69.18% <80.00%> (-0.02%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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 patch-sympy-tensor-args branch from e7893c2 to 3ffab6b Compare August 12, 2026 20:28
@mloubout mloubout changed the title dsl: fix processing of tensor args dsl: misc patches from recent updates (interp, sympy args) Aug 13, 2026
Comment thread devito/types/sparse.py
return defaults
key = alias or self
coords = defaults.get(key.coordinates.name, key.coordinates.data)
coords = defaults.get(key.coordinates.name, self.coordinates.data)

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 doesn't seem correct to me?

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.

why? key is the one used to build the operator, self is the runtime one

Comment thread devito/types/sparse.py
# of reference used by the kernel.
# `super` has already tabulated through `_arg_defaults`, in the frame
# of whichever object supplied the runtime values. Only an explicit
# `o_x`/`o_y`/... override moves that frame again, and the tables then

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.

"frame"?

Comment thread devito/types/tensor.py
# From rebuild/tensor property. Indexed as a sympy Matrix. Note that this
# may be a plain Matrix rather than an AbstractTensor, as rebuilding a
# tensor component-wise downgrades it when the components aren't Devito
# objects, which is the case for a Matrix of `Staggering`

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.

But doesn't this matrix contain Devito dimensions or NODE usually? I suppose this is for the tuple case as in staggered=(x, y) on a particular field?

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.

The matrix is not a devito object, not its elements. If it doesn't contain any dimension (so the staggering) it's plain sympy matrix sympy.ImmutableDenseMatrix._fromrep(newobj._rep)

Comment on lines +1008 to +1009
u = TimeFunction(name='u', grid=grid, space_order=8)
src = SparseTimeFunction(name='src', grid=grid, npoint=1, nt=2, **kw)

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 - no need for these to be time-dependent

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.

it mimicks the erroring case from the recipes, why it's time dependent


shift = -100.
u, src = setup((shift, shift))
op.apply(time_M=0, u=u, src=src)

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.

Is it worth also testing directly overriding o_x, o_y, etc? I suppose users don't do it very often, but still...

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.

The plain origin override is tested just above.

Comment thread tests/test_tensors.py
sympify a `Staggering` away, otherwise it can no longer be fed back as the
`staggered` kwarg.
"""
grid = Grid(tuple([5]*3))

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: grid = Grid((5,) * 3)

An Operator compiled against one model and applied to another overrides
every symbol, sparse ones included, and the kernel then runs in the
override's frame. `_arg_values` took the coordinates from the override
but the origin from `self`, tabulating real coordinates against the
compile-time frame. Every point landed off by the difference between the
two origins, silently, since sources and receivers shift together.
Injects through an Operator built on a grid whose origin differs from the
one it is applied to. The linear path regressed here; sinc computes its
positions from the runtime `o_x` and did not.
`_arg_defaults` is already handed the runtime object as `self` and the
compile-time symbols as `alias`, like the rest of the `_arg_*` protocol,
so the frame to tabulate in was there all along. Take the names from
`alias` and the data and Grid from `self`, rather than looking the
override up in kwargs from `_arg_values`.

`_arg_values` now only rebuilds the tables for an explicit `o_x`/`o_y`
override, instead of redoing on every call what `_arg_defaults` has
already tabulated correctly.
It sits next to `test_position`, which covers the same origin shift
through an explicit `o_x`, rather than carrying a class of its own.
@mloubout
mloubout force-pushed the patch-sympy-tensor-args branch from e50ed47 to 8f12021 Compare August 13, 2026 11:30
@mloubout
mloubout merged commit c1d4a35 into main Aug 13, 2026
42 checks passed
@mloubout
mloubout deleted the patch-sympy-tensor-args branch August 13, 2026 13:21
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