Skip to content

Fold a repeated symbol name in Range.offset and Range.compose - #2560

Open
ThrudPrimrose wants to merge 2 commits into
mainfrom
fix/serialization-roundtrip-offset-and-reduce
Open

Fold a repeated symbol name in Range.offset and Range.compose#2560
ThrudPrimrose wants to merge 2 commits into
mainfrom
fix/serialization-roundtrip-offset-and-reduce

Conversation

@ThrudPrimrose

@ThrudPrimrose ThrudPrimrose commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Adding a bound of one subset to a bound of another brings together two mints of the same name — a map parameter's symbol is int64 and nonnegative, a string-parsed memlet's is neither — and SymPy compares assumptions, so Range.offset left k - k and Range.compose left i + (M - i - 1) standing where both mean something simpler; the expression then does not survive a serialization round trip, since only one of the two atoms is written with its dtype. Both now fold through equalize_symbol, guarded by a name count so the substitution only runs when a name really is repeated, and the GPUAuto reduce expansion reshapes its _in descriptor through set_shape so offset no longer keeps the source array's rank.

Yakup Koray Budanaz added 2 commits September 7, 2026 15:00
Two ways an SDFG stopped surviving a serialization round trip, both found by running the
GPU pipeline over the npbench kernels with `testing.serialization` on.

A memlet parsed from a string mints its symbols with the default dtype and no assumptions,
while a map parameter carries the frontend's -- int64 and nonnegative. SymPy compares
assumptions, so the two `k` atoms stay distinct and offsetting one subset by the other
leaves `k - k` in the range instead of `0`. A symbol in DaCe is its name, so both denote
one value; `Range.offset` and `offset_new` now collapse such a pair, guarded by a name
count so the substitution only runs when a name really is duplicated (vadv).

The GPUAuto reduce expansion reshaped its `_in` descriptor by assigning `shape` alone.
`offset` is rank-dependent, so it stayed at the source array's rank and the descriptor
failed its own `validate` with "Offset must be the same size as shape"; deserialization
then answered with an unregistered placeholder instead of an Array (softmax). It goes
through `set_shape`, which recomputes what the rank decides.
`compose` adds a bound of one subset to a bound of the other, exactly as `offset` does, and
the two can carry different mints of one name: a map parameter's `i` is int64 and
nonnegative, a string-parsed memlet's is neither. SymPy compares assumptions and keeps
both, so `RedundantArray` composing them produced `i + (M - i - 1)` where it means `M - 1`.

Over the npbench kernels this was the only remaining place a single expression carried one
name on two symbols; with both folds in place none of the 37 does, parsed or optimized.
@ThrudPrimrose ThrudPrimrose changed the title Keep offset subsets and reduced descriptors readable back Fold a repeated symbol name in Range.offset and Range.compose Sep 7, 2026
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.

1 participant