Skip to content

feat[next]: open named slices, one const-list dimension and other preparations for dimension classes - #3087

Open
egparedes wants to merge 9 commits into
mainfrom
connectivities-as-types-1-preparation
Open

egparedes wants to merge 9 commits into
mainfrom
connectivities-as-types-1-preparation

Conversation

@egparedes

@egparedes egparedes commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Small, independent changes to gt4py.next that the dimension-classes work (#2899) exposed. Each one stands on its own on main:

  • Open bounds for named slices. field[I(1):] and field[:I(3)] select up to the field's own bound; before, a missing bound raised. Every infinite side of a NamedRange or Domain used as an index is an open bound too (before, it raised IndexOutOfBounds), and named slices can be combined with named indices and ranges in one index. A slice step other than 1 is now rejected instead of silently dropped, and mixing a named slice with relative indices raises.
  • Infinity and UnitRange printing. str(Infinity.POSITIVE) is inf; repr of a UnitRange spells its infinite bounds.
  • One const-list local dimension, declared next to make_const_list in iterator/builtins.py, instead of two equal declarations in iterator/embedded.py and the DaCe lowering.
  • Printed IR round trip: a local axis literal gets its own kind suffix, and dimension and offset names in axis and offset literals that are not ASCII-only parse back.
  • DaCe: the bindings get the offset-provider keys of the connectivity arguments from the translation step (SDFGCodeSpec.connectivity_keys) instead of decoding them from array names.
  • DaCe: an as_map_variable helper replaces three copies of the same conversion, and LoopBlocking accepts a single dimension or map variable name, as MapIterationOrder does.
  • cartesian_shift(dim, offset) gives the index offset and codomain of a Cartesian shift, so the frontend no longer builds a CartesianConnectivity only to read them.

🤖 Written by an agent on my behalf.

A named slice may omit a bound, e.g. `field[I(1):]` or `field[:I(3)]`: the
open side selects up to the field's own bound, and so does every infinite side
of a `NamedRange` or `Domain` used as an index. Closed bounds outside the
field still raise `IndexOutOfBounds`.

A named slice may now be combined with named indices and ranges in one index
tuple, as `NamedRange` already could. A step other than 1 raises instead of
being silently dropped, and so does a slice mixing a named bound with an
integer bound.
`str(Infinity.POSITIVE)` is now `inf` (`-inf` for the negative member), so an
infinite range prints as `(-inf:inf)` in domains and error messages. The repr
is the expression evaluating to the member, `Infinity.POSITIVE`, and
`UnitRange.__repr__` uses it, so `repr` of a range evaluates back to it.
The embedded iterator backend and the DaCe lowering each declared an equal
`_CONST_DIM` for the lists `make_const_list` produces. Both now use
`CONST_LIST_DIM`, declared next to `make_const_list` in `iterator/builtins.py`.
Its value stays `_CONST_DIM`.
…ted IR

An axis literal of a LOCAL dimension (e.g. from `broadcast(a, (Vertex, V2EDim))`)
was printed without a kind suffix and parsed back as a symbol reference. It now
prints with the suffix `ₗ`.

The names in axis and offset literals were restricted to ASCII by the parser,
while the printer emits any dimension or offset name. They now accept any
Python identifier.
…nts to the bindings

The translation records the offset-provider keys of the connectivity tables the
SDFG takes as arguments in `SDFGCodeSpec.connectivity_keys`, and the bindings
look the tables up by these keys instead of decoding them from the array names.
A connectivity argument without a key raises, rather than leaving a stale
table pointer on fast-call.
`LoopBlocking`, `MapIterationOrder` and `VerticalSplitMapRange` each turned a
dimension option into its map variable with their own `isinstance` check; they
now share `as_map_variable`. Like `MapIterationOrder`, `LoopBlocking` accepts a
single dimension or map variable name instead of a sequence (a single name was
iterated character by character).
`common.cartesian_shift(dim, offset)` returns the integral index offset and the
codomain of a Cartesian (possibly half-integer) shift. The frontend type
deduction and the lowering to GTIR use it instead of building a
`CartesianConnectivity` only to read its fields, and
`connectivity_for_cartesian_shift` delegates to it, so the staggering rule
lives in one place.
@egparedes egparedes changed the title refactor[next]: open named slices, one const-list dimension and other preparations for dimension classes feat[next]: open named slices, one const-list dimension and other preparations for dimension classes Dec 4, 2026
@egparedes
egparedes marked this pull request as ready for review December 4, 2026 13:36
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
✅ Merge recommendation: Needs review
🔎 Failure modes

What: A `SDFGCodeSpec` produced before this change (e.g. reused from a persistent build cache, `GT4PY_BUILD_CACHE_DIR`) carries no `connectivity_keys`, so `_parse_gt_connectivities` raises `ValueError: No offset-provider key for connectivity argument ...` (or the new field is simply missing on the deserialized spec) when the stale artifact is fast-called. Uncertainty: this only bites if the OTF cache reuses translation outputs across code versions; clearing the cache avoids it entirely.
Where: src/gt4py/next/program_processors/runners/dace/workflow/bindings.py:_parse_gt_connectivities
Trigger: Fast-calling a dace-compiled unstructured program with connectivity arguments using a build cache populated by the previous gt4py version.
Detected by: The ValueError raised at program call time; nothing in this PR or CI exercises stale cached artifacts from a prior version.
Covered in this PR: No

🏅 Score: 88
🧪 PR contains tests
🔒 No security concerns identified
🔀 Multiple PR themes

Sub-PR theme: Open bounds for named slices, Infinity/UnitRange printing, and cartesian_shift helper

Relevant files:

  • src/gt4py/next/common/init.py
  • src/gt4py/next/common/connectivities.py
  • src/gt4py/next/common/dimensions.py
  • src/gt4py/next/common/ranges.py
  • src/gt4py/next/embedded/common.py
  • src/gt4py/next/embedded/nd_array_field.py
  • src/gt4py/next/ffront/foast_passes/type_deduction.py
  • src/gt4py/next/ffront/foast_to_gtir.py
  • tests/next_tests/unit_tests/embedded_tests/test_common.py
  • tests/next_tests/unit_tests/embedded_tests/test_nd_array_field.py
  • tests/next_tests/unit_tests/test_common.py

Sub-PR theme: Single CONST_LIST_DIM declaration and printed-IR round-trip fixes

Relevant files:

  • src/gt4py/next/iterator/builtins.py
  • src/gt4py/next/iterator/embedded.py
  • src/gt4py/next/iterator/pretty_parser.py
  • src/gt4py/next/iterator/pretty_printer.py
  • src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_lambda.py
  • tests/next_tests/unit_tests/iterator_tests/test_embedded_field_with_list.py
  • tests/next_tests/unit_tests/iterator_tests/test_pretty_parser.py
  • tests/next_tests/unit_tests/iterator_tests/test_pretty_printer.py
  • tests/next_tests/unit_tests/iterator_tests/test_pretty_roundtrip.py

Sub-PR theme: DaCe: pass connectivity keys to bindings and add as_map_variable helper

Relevant files:

  • src/gt4py/next/otf/artifacts.py
  • src/gt4py/next/program_processors/runners/dace/lowering/init.py
  • src/gt4py/next/program_processors/runners/dace/lowering/gtir_to_sdfg_utils.py
  • src/gt4py/next/program_processors/runners/dace/transformations/loop_blocking.py
  • src/gt4py/next/program_processors/runners/dace/transformations/map_fusion_extended.py
  • src/gt4py/next/program_processors/runners/dace/transformations/map_orderer.py
  • src/gt4py/next/program_processors/runners/dace/workflow/bindings.py
  • src/gt4py/next/program_processors/runners/dace/workflow/translation.py
  • tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/test_dace_bindings.py
  • tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/test_dace_translation.py
  • tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/transformation_tests/test_loop_blocking.py

⚡ No major issues detected

⚙️ Agent run details
  • Model: openai/zai-org/GLM-5.3-Flash
  • Tokens: 30,365 in / 36,277 out / 66,642 total
  • Time cost: 209.3s
  • AI calls: 1

This branch was successfully deployed

1 active deployment
pr-agent — 01ca4097 Deployed Dec 4, 2026 by egparedes via pr-agent / pr-agent #313
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