Conversation
…y its tag Eleven sites held a local `Dimension` and needed its `ConnectivityType` (`max_neighbors`, `skip_value`), and each recovered it by using `dim.value` as an offset-provider key. That is what forces a `FieldOffset`'s tag, its declared local dimension, the connectivity's own local dimension and the provider key to be one string. It is not a `FieldOffset` constraint: a sparse field argument reduced with `neighbor_sum(s, axis=Local)` and no `FieldOffset` anywhere fails the same way. `common.get_offset_by_neighbor_dim` finds the element whose `neighbor_dim` is the given dimension, raising if it is ambiguous. `embedded._List` and `SparseListIterator` now carry the dimension rather than a tag, so `_List.__gt_type__` needs no lookup at all; the dace lowering reads `conn_type.neighbor_dim` where it previously rebuilt a dimension from the tag. `transform_utils._check_offset_declarations`, called from `past_to_gtir` beside `_deduce_grid_type`, checks each `FieldOffset`'s `source`/`target` against the connectivity supplied under its name. This is required rather than incidental: the lookup change removes the accidental `KeyError` that used to catch a declaration disagreeing with its connectivity, and gtfn would otherwise run such a program silently. `itir_to_gtfn_ir` already emitted both C++ tag structs when the names differed (GridTools#1789); nothing else was prepared. Claude-Session: https://claude.ai/code/session_01Mg1pdvaBDqG1meMcWjvWH7
havogt
force-pushed
the
fieldoffset-dims
branch
from
September 4, 2026 08:35
ed9939e to
54f87a9
Compare
havogt
changed the base branch from
offset_type_name-rebased
to
offset_type_name
September 4, 2026 08:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on GridTools#2730 (
refactor[next]: carry the connectivity name inOffsetType``). Opened here in the fork so the diff is only the incremental commit; base isoffset_type_name, GridTools#2730's own branch, into which `main` has been merged (`e9f588886`). Not for upstream review as-is — GridTools#2730 lands first.Why
A
FieldOffset's tag, its declared local dimension, the connectivity's own local dimension and the offset-provider key all have to be the same string. This is not aFieldOffsetconstraint — a sparse field argument with noFieldOffsetanywhere fails identically:Eleven sites hold a local
Dimension, need itsConnectivityType(max_neighbors,skip_value), and recover it by usingdim.valueas an offset-provider key.embedded/nd_array_field.pysays so in a comment (# assumes offset and local dimension have same name, since GridTools#1441);unroll_reduceacquired it in GridTools#2267 when it stopped reading theOffsetLiteraloff the IR and started readingarg.type.offset_type.value.GridTools#2730 fixes the leg where the source-level identifier became the tag. This fixes the leg where the local dimension becomes the tag.
What
common.get_offset_by_neighbor_dim— find the element whoseneighbor_dimis the given dimension; raise naming the tags if ambiguous.embedded._ListandSparseListIteratorcarry theDimensionrather than a tag, so_List.__gt_type__needs no lookup at all.conn_type.neighbor_dimwhere it previously rebuilt aDimensionfrom the tag.transform_utils._check_offset_declarations, called frompast_to_gtirbeside_deduce_grid_type, checks eachFieldOffset'ssource/targetagainst the connectivity supplied for it. Required, not extra scope: the lookup change removes the accidentalKeyErrorthat used to catch a declaration disagreeing with its connectivity, and gtfn would otherwise run such a program silently.itir_to_gtfn_iralready emitted both C++ tag structs when the names differed (GridTools#1789,db5325bf0); nothing else was prepared.Notes for review
get_offset(— they reach the provider via a raw dict index, aSparseTag, or a fabricatedDimension. The new tests found them.test_unroll_reduce.pyneeded updating, and how is itself evidence:dummy_connectivity_typebuilt every connectivity with neighbor dimdummy_neighborwhile registering it under"Dim"/"Dim2". The dimension theListTypecarried and the dimension the connectivity carried were already inconsistent in the fixtures and nothing noticed, because only the key was ever read.past_to_gtir, so the declaration check does not fire there; the pre-existing "Field can not be reduced as it doesn't have dimension" error stands. Both paths fail, only the wording differs.Tests
New
tests/next_tests/integration_tests/feature_tests/ffront_tests/test_offset_naming.py— 36 passing across embedded / roundtrip / gtfn / dace × simple_mesh / skip_value_mesh.mypy src/clean (361 files),ruff check,ruff format --check,tach checkclean.unit_tests2135 passed;multi_feature_tests532 passed; reductions + external_local_field + import_from_mod + scan + offset_naming 517 passed.https://claude.ai/code/session_01Mg1pdvaBDqG1meMcWjvWH7