Skip to content

Reduce over the interior of fields - #6228

Merged
giordano merged 3 commits into
mainfrom
mg/fields-reductions
Oct 11, 2026
Merged

giordano merged 3 commits into
mainfrom
mg/fields-reductions

Conversation

@giordano

Copy link
Copy Markdown
Member

Guess what? Yes, this is also taken out of #5799

GPUArrays 12 reduces through AcceleratedKernels, which takes a linear
view of the source array (@view src[begin:end]), reshapes it, and
adapts the result for the kernel. Reductions without a condition passed
the Field itself, and a Field doesn't support any of this:
lastindex is the last index of its halo'd data, a one-index view is
an x-slice, and adapting it returns its data with halos, so the
reshaped array no longer fits. Reductions now get the field's interior,
a 1-based array of the field's own size, as the index reductions
already do.

giordano and others added 3 commits October 11, 2026 08:43
GPUArrays 12 reduces through AcceleratedKernels, which takes a linear
view of the source array (`@view src[begin:end]`), reshapes it, and
adapts the result for the kernel. Reductions without a condition passed
the `Field` itself, and a `Field` doesn't support any of this:
`lastindex` is the last index of its halo'd data, a one-index `view` is
an x-slice, and adapting it returns its data with halos, so the
reshaped array no longer fits. Reductions now get the field's interior,
a 1-based array of the field's own size, as the index reductions
already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EtLmZUPY4g9hi8aJsM4Wrs
The size of an `AbstractField` ignored its indices while its axes
honour them, so for an operation on a windowed field `length` and
`axes` disagreed, and reshaping it, as GPUArrays 12 reductions do,
failed. The size now honours the indices, like a `Field`'s.

Operations also drop the indices of their fields when adapted for a
kernel, which changes their size and breaks the reshape built around
them, so reductions of windowed operations, `dot` included, go through
a view of the window, which keeps its size when adapted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EtLmZUPY4g9hi8aJsM4Wrs
A `TimeDerivative` adapts to its result, a `Field`, and so to the
result's data with halos, which is larger than the derivative. Like a
bare field, it broke GPUArrays 12 reductions, which reshape the source
and then adapt it, e.g. when averaging a time derivative for output.
Reductions now see the interior of its result.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EtLmZUPY4g9hi8aJsM4Wrs
@giordano
giordano requested review from glwagner and tomchor October 11, 2026 07:46
@giordano
giordano added this pull request to stack #6231 October 11, 2026 08:01
@giordano
giordano merged commit d2ad508 into main Oct 11, 2026
15 of 19 checks passed
@giordano
giordano deleted the mg/fields-reductions branch October 11, 2026 10:47
xkykai pushed a commit that referenced this pull request Oct 13, 2026
Fields and operations drop their indices when adapted for a kernel, so
since #6228 the size of an adapted operation indexed into nothing,
breaking GPU index reductions such as argmin on a ConditionalOperation.
Use axes_indices, as axes already does.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants