From f4d23650756a77377a87937524892dc01a7e31de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Gonz=C3=A1lez=20Paredes?= Date: Thu, 3 Dec 2026 16:58:45 +0100 Subject: [PATCH 1/3] =?UTF-8?q?personal/egparedes:=20connectivities=20as?= =?UTF-8?q?=20types=20=E2=80=94=20follow=20the=20design=20of=20gt4py#2899?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../connectivities-as-types.md | 120 ++++++++++-------- .../connectivities-as-types_alternatives.md | 4 +- .../connectivities-as-types_identity.md | 48 ++++--- .../connectivities-as-types_slides.md | 12 +- .../connectivities-as-types_staggering.md | 4 +- content/shared/dimensions-as-types.md | 2 +- 6 files changed, 98 insertions(+), 92 deletions(-) diff --git a/content/personal/egparedes/connectivities-as-types/connectivities-as-types.md b/content/personal/egparedes/connectivities-as-types/connectivities-as-types.md index 4213f5e..7107465 100644 --- a/content/personal/egparedes/connectivities-as-types/connectivities-as-types.md +++ b/content/personal/egparedes/connectivities-as-types/connectivities-as-types.md @@ -3,7 +3,7 @@ title: "Connectivities as types: one declaration for offset, local dimension and author: egparedes tags: [type-system, type-checking, dimensions, local-dimensions, connectivities, offset-provider, unstructured, neighbor-sum, reduction, frontend, foast, gtir, embedded, gtfn, dace, nominal-types, dependent-types, metaclass, serialization, fingerprint, staggering, axis-dimensions, cw-complex, exterior-calculus, domain, dimension-kind, ugrid, sgrid, migration, adr, tech-debt, shared-local-dimensions, implemented] created: 2026-09-17 -updated: 2026-10-02 +updated: 2026-12-03 status: draft --- @@ -12,7 +12,7 @@ status: draft > `FieldOffset` tag, the local `Dimension` name and the `offset_provider` key — > plus a fourth, hidden one: the Python variable the `FieldOffset` is bound to. > Make the connectivity a **class** that *contains* its local dimension, is its -> own provider key, and whose identity — like every dimension's (ADR 0029) — is +> own provider key, and whose identity — like every dimension's (ADR 0030) — is > its qualified Python name. In the IR it is named by its local dimension's > tag, so shifts, reductions and sparse arguments all find the table under one > string: @@ -30,12 +30,12 @@ status: draft > identity constraints in the current tree, six (A1–A5 and A9, the embedded > position-dict key) dissolve by construction, three (A6–A8) collapse into a > single bind-time check, and one (A10, the `AxisLiteral` round-trip) remains, -> re-expressed over `tag` instead of `Dimension.value`. +> re-expressed over `DimensionRef` instead of `Dimension.value`. > **Implementation.** The design below is implemented on the stacked > GridTools/gt4py PRs listed in [Implementation](#implementation) (top branch -> `connectivities-as-types-8-typed-positions`), with ADR 0029 (dimensions as -> nominal types) and ADR 0030 (connectivities as types). The *Problem* section +> `connectivities-as-types-8-typed-positions`), with ADR 0030 (dimensions as +> nominal types) and ADR 0031 (connectivities as types; planned number). The *Problem* section > and the constraint catalogue in the appendix > [[personal/egparedes/connectivities-as-types/connectivities-as-types_research|Tag and name constraints — full catalogue]] > describe gt4py `main` (`b3c53fa7e`, v1.2.2), the tree the stack is based on. @@ -56,7 +56,7 @@ status: draft > [[personal/havogt/dimension-generic-fields/dimension-generic-fields|Generic dimensions and statically > typed staggering]], whose Part II also proposed the `Staggered[D]` shape > used here. It **supersedes** [[shared/dimensions-as-types|Dimensions as -> types]]: the dimension design below (ADR 0029) replaces that note's +> types]]: the dimension design below (ADR 0030) replaces that note's > `(name, kind)` value identity and interning registry with type identity, and > is stated here in full. It overlaps with > [[personal/havogt/mesh-and-first-class-halos/mesh-and-first-class-halos|A mesh concept with @@ -150,7 +150,9 @@ what is one idea — *a mapping between two index spaces, plus a name for it*. | Concept | Role | Replaces | | --- | --- | --- | -| `DimensionIndex` | a dimension is a subclass, an index along it an instance (ADR 0029); the root — mesh locations, axes and local dimensions are all subclasses, so every `type[DimensionIndex]` annotation in the tree keeps its meaning | `Dimension` instances | +| `DimensionIndex` | a dimension is a subclass, an index along it an instance (ADR 0030); the root — mesh locations, axes and local dimensions are all subclasses, so every `type[DimensionIndex]` annotation at the Python edge keeps its meaning | `Dimension` instances | +| `DimensionRef` | an immutable, interned value naming a dimension class (module, qualname, `kind`, whether it is a Cartesian axis, staggered base); what type specifications, the IR and the backends carry instead of the class (see [Identity](#identity-is-the-qualified-python-name)) | `Dimension` instances below the frontend | +| `DimensionRange` | a range on a dimension, `KDim.at(0, 10)`; a point is an index, `KDim(3)`. `field[KDim(5):KDim(10)]` is slice syntax for a range | `NamedRange` (`NamedIndex` for a point) | | `CartesianAxisIndex(AnyCartesianAxisIndex)` | a **declared Cartesian axis**: an index space with integer index arithmetic and exactly one staggered partner (see [Cartesian axis dimensions](#cartesian-axis-dimensions)). `AnyCartesianAxisIndex` is either cell class of such an axis, declared or derived | — (new; today `kind != LOCAL` is the nearest approximation, and it does not separate a Cartesian axis from a mesh location) | | `Staggered[D: CartesianAxisIndex]` | the axis's derived partner, at the half-integer positions of `D`; a real, interned class (see [`Staggered[D]`](#staggeredd)) | the `_Staggered` name prefix | | `LocalDimensionIndex(DimensionIndex)` | a local dimension: **owned** (declared nested in, or adopted by, its connectivity), or **owner-less** (optionally with `size=n`, which sets `max_neighbors = min_neighbors = n`); carries the neighbor counts | `Dimension(..., kind=LOCAL)`, `_CONST_DIM` | @@ -235,11 +237,11 @@ use for `a(V2E)`. The iterator-level `it_ts.OffsetLiteralType` / ### Sketch ```python -# ── dimensions (ADR 0029) ───────────────────────────────────────────────── +# ── dimensions (ADR 0030) ───────────────────────────────────────────────── class DimensionMeta(type): @property def tag(cls) -> Tag: # identity, and the IR spelling - return f"{cls.__module__}.{cls.__qualname__}" + return f"{cls.__module__}:{cls.__qualname__}" kind: DimensionKind __hash__ = type.__hash__ # __eq__ stays for `I == 5` -> Domain def __add__( # I + 1, K + 0.5; a Cartesian axis only @@ -282,7 +284,7 @@ Staggered[KDim] # KDim's derived partner; # Staggered[Staggered[KDim]] is a type error -# ── connectivities (ADR 0030) ───────────────────────────────────────────── +# ── connectivities (ADR 0031) ───────────────────────────────────────────── class ConnectivityMeta(type): tag: Tag # the declaration's qualified name offset_tag: Tag # how the IR names it, see "Identity" @@ -353,7 +355,7 @@ already names a buffer's origin in gt4py (`__gt_origin__`). ### Identity is the qualified Python name A dimension's or connectivity's identity is the Python type; its tag is -`f"{cls.__module__}.{cls.__qualname__}"` (except `Staggered[D]`, whose tag +`f"{cls.__module__}:{cls.__qualname__}"` (except `Staggered[D]`, whose tag embeds its base's full tag, rule 1; a connectivity is *named in the IR* by its `offset_tag`, rule 7). The static view (checkers see nominal types) and the runtime view (equality is `is`) agree by construction, and the tag is a @@ -368,37 +370,38 @@ that aliasing disappears. The cost is that the many function-local dummy dimensions in `tests/next_tests` move to module level. The consequences, stated as rules: -1. **Reconstruction from the IR is an import.** `resolve(tag)` imports the - longest importable module prefix and walks the rest as attributes, the way - `pickle` references a class, so a nested `V2E.Local` resolves naturally and a - redefined declaration resolves to the new class. `AxisLiteral` stores only the - tag; its `kind` and `dim` are read-only properties off the resolved class, and - `kind` is optional because a local dimension's is `None`. Memoization, `resolve_loaded` and the `Staggered[D]` grammar: [[personal/egparedes/connectivities-as-types/connectivities-as-types_identity|the identity appendix]]. -2. **Types reaching the IR must be importable.** `` in a qualname is - rejected at class creation (for dimensions and connectivities); pickle's - own `save_global` stays the authoritative check. Interactive `__main__` - (REPL, notebooks, `python -c`) matters — every notebook declares its +1. **Two levels, and nothing is imported from a tag.** Classes are the identity at the + Python edge: user code, embedded execution and program calls. Below it, type + specifications, the IR and the backends carry a `DimensionRef`, an interned value + equal to another one if all its fields are; `dimension_ref(cls)` is the only + conversion. `AxisLiteral` stores the ref, and its `value` (the tag) and `kind` are + read-only properties of it. Details, and the `Staggered[D]` grammar: [[personal/egparedes/connectivities-as-types/connectivities-as-types_identity|the identity appendix]]. +2. **Types must be importable to be pickled.** Only the connectivities of an offset + provider still carry classes into a compile job. `` in a qualname is + rejected at class creation (for dimensions and connectivities), as an early + heuristic; pickle's own `save_global` stays the authoritative check. Interactive + `__main__` (REPL, notebooks, `python -c`) matters — every notebook declares its dimensions there — so the process-pool runner (`BUILD_JOBS_MODE=process`) detects a job that references such a class and, with a warning, **compiles it in the calling thread** instead of failing in a spawn worker. 3. **No registry.** Classes pickle by reference. The one narrow `copyreg` hook is for `Staggered[D]`, whose bracketed qualname `save_global` cannot look up. -4. **Fingerprints depend on qualified names, plus `kind`.** A dimension is - deconstructed as its by-reference name *and* its `kind`, so redefining one under - the same name with another kind does invalidate artifacts; a staggered dimension +4. **Fingerprints depend on qualified names, plus the `DimensionRef`.** A dimension is + deconstructed as its by-reference name *and* its ref, i.e. also its `kind` and + whether it is a Cartesian axis, so redefining one under the same name with another + kind or axis level does invalidate artifacts; a staggered dimension is fingerprinted through its base. `base` cannot be flipped in place at all — `Staggered[K]` is interned by base identity and its tag embeds the base tag, so a - different base is a different class. The axis level - (`CartesianAxisIndex` versus `DimensionIndex`) is deliberately *not* - fingerprinted: it changes what is accepted, never what is emitted. A connectivity + different base is a different class. The axis level is included because the + frontend cache uses this fingerprint and index arithmetic depends on it. A connectivity declaration is fingerprinted *additionally* by its domain, codomain, `Local` and counts. Either way the ADR 0023 cache invalidates on module renames. 5. **Codegen names need injective mangling.** `codegen_name(tag)` is a prefix - escape (`_`→`_u`, `.`→`_d`, `[`→`_l`, `]`→`_r`); the obvious alternative is + escape (`_`→`_u`, `.`→`_d`, `:`→`_c`, `[`→`_l`, `]`→`_r`); the obvious alternative is not injective. 6. **Staggering is part of the dimension change.** The `_Staggered` name prefix needs the name→class lookup that type identity removes, so `Staggered[D]` is a - real class and part of ADR 0029 (PR A), with its parameter bounded on a + real class and part of ADR 0030 (PR A), with its parameter bounded on a declared [Cartesian axis](#cartesian-axis-dimensions). Rules 3–6 in full — the hook, the fingerprint deconstructors, the exhaustive @@ -418,12 +421,15 @@ stated as rules: truth value. The residual hazard is narrow and accepted: a dict holding both an integer key and a dimension-class key whose hashes collide would reach `bool(Domain)`. Class-keyed providers hold only classes and tag strings, and a - `str` compares unequal to a class, so they cannot. ADR 0029 records this. + `str` compares unequal to a class, so they cannot. 9. **Same-named declarations are different connectivities.** Two declarations with the same qualified name from different modules, or a redefinition, are simply different classes; no warning is issued, and `check_neighbor_table` hints "was the declaration redefined?" when a table - built for one is bound to the other. + built for one is bound to the other. For dimensions, a re-run notebook cell gives + an *equal* ref for a *new* class, so a call compares the classes of its arguments + with the ones the definition declares, by identity and under `__debug__` only; two + different refs with one tag in a program are an error. ### Cartesian axis dimensions @@ -481,7 +487,7 @@ staggered partner is still accepted, raising a `DSLError` in a field operator an `TypeError` in embedded execution (PR C, where `as_offset(dim, field)` lands). Only `+`/`-` and `as_offset` are restricted — comparison still builds a `Domain` on any dimension, which `concat_where` needs over `CellDim`/`EdgeDim`. Hand-written -iterator IR is unchecked, since it names dimensions by tag like the rest of the IR. +iterator IR is unchecked. The self-type costs two definition-site suppressions, one per checker; P4 of [`staggered_probe.py`](staggered_probe.py) pins it down and [[personal/egparedes/connectivities-as-types/connectivities-as-types_typing|the typing appendix]] records both diagnostics. @@ -555,13 +561,14 @@ of [Cartesian axis dimensions](#cartesian-axis-dimensions). `+1` index correction the position convention requires when shifting *out of* an unstaggered dimension: `K + 0.5` maps `K(i)` to `Staggered[K](i+1)` (position `i+½`), `Staggered[K] + 0.5` maps `Staggered[K](i)` to `K(i)`. - The frontend accepts only integer and half-integer literal offsets and - types the shift as an `OffsetType` at type-deduction time; statically, + The frontend accepts only integer and half-integer literal offsets, + computes the shift on refs (`cartesian_shift`) and types it as an `OffsetType` + at type-deduction time; statically, `K + 0.5` is a plain `Connectivity`. `check_dims` rejects a dimension and its staggered counterpart in one field or domain, and `order_dimensions` orders by the base, so a staggered field has the layout of its base. - **IR, serialization and fingerprints.** The tag is - `gt4py.next.common.Staggered[]` — the one tag that is not a + `gt4py.next.common:Staggered[]` — the one tag that is not a qualified name. Its grammar, the `copyreg` hook and fingerprinting through the base are in [[personal/egparedes/connectivities-as-types/connectivities-as-types_identity|the identity appendix]]. - **Backends.** gtfn emits the staggered tag as a C++ alias of its base tag @@ -660,7 +667,7 @@ tables assign different neighbors to the same domain element. The model: in the local dimension, is an `arg-type` error, probe P1b), while a `Local` generated in `__init_subclass__` and annotated `ClassVar[type[LocalDimensionIndex]]` on the base is rejected by - both as *not valid as a type* — the very error class ADR 0029 exists to + both as *not valid as a type* — the very error class ADR 0030 exists to remove. Two lines per connectivity buy a real type; ICON4Py has 16 declarations. Its tag is `.Local`, unique by construction. - `Local` is **not** passed through the base subscription @@ -689,10 +696,10 @@ tables assign different neighbors to the same domain element. The model: ICON4Py's memory layout for those fields. (Backend support for sparse fields over an owner-less axis *other than* `ConstList` is not part of the stack: such a field still needs some bound table over its axis.) -- `_CONST_DIM` is replaced by the owner-less - `common.ConstList(LocalDimensionIndex, size=1)`, one class used by iterator - embedded and the DaCe lowering with identity checks, and refused as an - adopted `Local`. (Type inference still +- `_CONST_DIM` is replaced by `iterator.builtins.ConstList`, one class used by iterator + embedded and the DaCe lowering. #2899 declares it as a `DimensionIndex` of kind + `LOCAL`; #2907 is to make it an owner-less `LocalDimensionIndex, size=1`, refused as + an adopted `Local`. (Type inference still represents a constant list as `ListType(offset_type=None)`.) - `neighbor_sum(..., axis=V2E.Local)` — the local axis stays **explicit**. `axis=V2E` as sugar is deliberately not offered; it would blur the two @@ -725,13 +732,13 @@ tables assign different neighbors to the same domain element. The model: | Frontend declaration | `Dimension(LOCAL)` + `FieldOffset` + provider key | one class | | Frontend types | `ts.OffsetType(source, target)`, tag dropped | `ts.ShiftType(domain, codomain, tag)` produced by the class (`__gt_type__`), `tag` set to `offset_tag`; `V2E.Local` in DSL code types as the local dimension | | FOAST → GTIR | shift tag = **Python variable name** | tag = `offset_tag`; the variable name is irrelevant (GridTools/gt4py#2898) | -| ITIR | `OffsetLiteral(str)` + dict lookup; `AxisLiteral(value, kind)` | `OffsetLiteral(offset_tag)`, unchanged node; `AxisLiteral(value)` with `kind` derived | +| ITIR | `OffsetLiteral(str)` + dict lookup; `AxisLiteral(value, kind)` | `OffsetLiteral(offset_tag)`, unchanged node; `AxisLiteral(dim: DimensionRef)`, with `value` and `kind` derived | | ITIR types | `ListType.offset_type: Dimension` | unchanged (already the local dim) | | Embedded field | `get_offset(provider, axis.value)` | table over the local dimension (`connectivity_key_over`); `V2E.bound_table()` | | Embedded iterator | positions keyed by name strings; `SparseTag` | positions keyed by dimension classes; `SparseAxis(dim)` | | gtfn | `dim.value` lookups; `TagDefinition` per tag and per `neighbor_dim` | still a `TagDefinition` per offset tag (and per differing `neighbor_dim`, i.e. for sharers), named by `codegen_name(tag)`; sparse-argument lookups through `connectivity_key_over` | | DaCe | ~10 `offset_type.value` lookups; `Dimension(offset, LOCAL)` synthesized | `codegen_name` for array/symbol names; `connectivity_key_over`; a local dimension sized from its own table (`local_dimension_size`); no synthesis | -| roundtrip backend | emits `gtx.Dimension("")` / `offset("")` as source text | emits ` = gtx.resolve("")` for axes and ` = offset("")` for offsets | +| roundtrip backend | emits `gtx.Dimension("")` / `offset("")` as source text | binds `` axis names to the classes of the call's fields and connectivities (synthesized from the ref only for a dimension none of them has), and emits ` = offset("")` for offsets | | Provider | `Mapping[str, NeighborTable]`; `offset_provider_type: Mapping[str, NeighborConnectivityType]` | public: `{V2E: table}`, and `table_types={V2E: NeighborTableType(...)}` (`TableTypesLike`, normalized to `TableTypes = Mapping[Tag, NeighborTableType]`) for ahead-of-time compilation (a dotted tag string is also accepted; the type stays `Mapping[Any, …]`); internal: keyed by `offset_tag`, normalized at the entry points; no deprecation window (a migration script for ICON4Py instead) | ### What it deletes @@ -739,7 +746,7 @@ tables assign different neighbors to the same domain element. The model: `FieldOffset` (both forms) and its export; bare-name provider keys (rejected at the strict entry points); the `_Staggered` prefix and its string sniffing (replaced by the `Staggered[D]` class and a small `[]` tag -grammar); `_CONST_DIM` as a magic name; the stored `AxisLiteral.kind`; +grammar); `_CONST_DIM` as a magic name; the separate `value` and `kind` fields of `AxisLiteral`; `SparseTag`; `NamedIndex` and the dimension half of the mypy plugin; `DimensionIndex(kind=LOCAL)` as a way to declare a local dimension, and the `LOCAL` member of `DimensionKind` itself (derived from `LocalDimensionIndex`); and the @@ -772,8 +779,8 @@ raise, with why each loses: - **Keep every concept and fix only which string wins.** It enforces the tangle instead of removing it; no concept goes away. - **`(name, kind)` value equality with an interning registry.** It decouples the - Python type's identity from the IR's, so it needs a registry, a `copyreg` hook and - a custom fingerprint deconstructor to paper over the gap — and still cannot give a + Python type's identity from the IR's, so it needs a name-keyed registry and a + blanket `copyreg` hook to paper over the gap — and still cannot give a nested `V2E.Local` a unique name. - **Static-only `max_neighbors` / `min_neighbors`.** Counts are not known statically: `fvm_nabla_setup.py` sizes `V2E` from the atlas mesh and ICON's skip values are @@ -783,13 +790,13 @@ raise, with why each loses: ## Relation to gt4py ADRs - **ADR 0019 (Connectivities).** The part naming `FieldOffset` as the frontend - identifier is superseded by ADR 0030; the `Connectivity` / `NeighborTable` / + identifier is superseded by ADR 0031; the `Connectivity` / `NeighborTable` / `ConnectivityType` vocabulary is kept ([What stays](#what-stays-and-why)). - **ADR 0026 (Staggered dimensions).** Its encoding is superseded by `Staggered[D]` ([above](#staggeredd)); its semantics are unchanged, and [Cartesian axis dimensions](#cartesian-axis-dimensions) states the structure they encode. -- **ADR 0029 (Dimensions as nominal types)** and **ADR 0030 (Connectivities - as types)** record this design in the gt4py tree. +- **ADR 0030 (Dimensions as nominal types)** and **ADR 0031 (Connectivities + as types; planned number)** record this design in the gt4py tree. - **ADR 0023 (build cache).** Fingerprints depend on qualified names, so the cache invalidates on module renames (Identity, rule 4). @@ -824,7 +831,7 @@ with the reasoning, so that a later reader does not reopen them. remove the one cosmetic cost of choosing which member of a pair to declare. It has to be static — it changes the integer correction `connectivity_for_cartesian_shift` bakes in, hence the emitted stencil — and it - would have to join `kind` in the dimension fingerprint, which rule 4 now + would have to be a field of `DimensionRef`, hence of the fingerprint, which rule 4 now establishes as a pattern rather than an obstacle. See [[personal/egparedes/connectivities-as-types/connectivities-as-types_staggering|the staggering appendix]]. Not in this stack. @@ -868,19 +875,20 @@ GridTools/gt4py#2898 (merged 2026-09-23) fixed the N2 leak first: unstructured shifts lower with the offset's own tag, shift lowering is type-driven so module-qualified offsets (`a(mod.V2E)`) work, and a regression matrix {shift, `neighbor_sum`} × {tag ≠ variable name, tag ≠ local-dimension name} -guards it. The rest is a stack of four GridTools/gt4py PRs, each green in CI -on its own, each based on the previous one: +guards it. The rest is a stack of four GridTools/gt4py PRs, each meant to be +green in CI on its own and based on the previous one. #2907 and the PRs above it still sit +on an earlier state of #2899, without `DimensionRef`: | PR | Branch | What | | --- | --- | --- | -| A: GridTools/gt4py#2899 | `connectivities-as-types-2-dimension-classes` | `feat[next]`: a concrete dimension is a class identified by its qualified name (ADR 0029); `codegen_name`; `CartesianAxisIndex` / `AnyCartesianAxisIndex` (both exported from `gtx`) and `Staggered[D: CartesianAxisIndex]`, with `__add__`/`__sub__` restricted to an axis statically and at runtime; interactive-`__main__` fallback; `NamedIndex` and the dimension half of the mypy plugin removed; mypy typing case `cartesian_axis_levels`; `ConstList` with `size=1` replaces the `_CONST_DIM` aliases; `AxisLiteral` stores only its tag, deriving `kind` and `dim`; printing IR never imports (`resolve_loaded`); offset tag = local dimension tag = provider key in the tree | -| B: GridTools/gt4py#2907 | `connectivities-as-types-3-neighbor-connectivity` | `feat[next]`: `NeighborConnectivity[Domain, Codomain]`, `LocalDimensionIndex` (and `DimensionKind.LOCAL` removed: a local's `kind` is `None`, localness comes from `common.is_local_dimension`, and `order_dimensions` ranks horizontal/local/vertical explicitly), `check_neighbor_table`, `local_dimension_of`, declaration fingerprinting; usable in the DSL; shared local dimensions, in the declarations and in the backends (`connectivity_key_over`, DaCe `local_dimension_size`); `NeighborTableType` and `ts.ShiftType`; pyright in the typing nox session, with `reportUnnecessaryTypeIgnoreComment: error` so a rejection that stops firing fails the run; ADR 0030 | +| A: GridTools/gt4py#2899 | `connectivities-as-types-2-dimension-classes` | `feat[next]`: a concrete dimension is a class identified by its qualified name (ADR 0030); `DimensionRef` values below the frontend, also in `AxisLiteral`, so nothing is imported from a tag; `codegen_name`; `CartesianAxisIndex` / `AnyCartesianAxisIndex` (both exported from `gtx`) and `Staggered[D: CartesianAxisIndex]`, with `__add__`/`__sub__` restricted to an axis statically and at runtime; `DimensionRange` (was `NamedRange`) and `Dimension.at`; class-identity check of call arguments; interactive-`__main__` fallback; `NamedIndex` and the dimension half of the mypy plugin removed; mypy typing case `cartesian_axis_levels`; `iterator.builtins.ConstList` (still of kind `LOCAL`) replaces the `_CONST_DIM` aliases; offset tag = local dimension tag = provider key in the tree | +| B: GridTools/gt4py#2907 | `connectivities-as-types-3-neighbor-connectivity` | `feat[next]`: `NeighborConnectivity[Domain, Codomain]`, `LocalDimensionIndex` (and `DimensionKind.LOCAL` removed: a local's `kind` is `None`, localness comes from `common.is_local_dimension`, and `order_dimensions` ranks horizontal/local/vertical explicitly), `check_neighbor_table`, `local_dimension_of`, declaration fingerprinting; usable in the DSL; shared local dimensions, in the declarations and in the backends (`connectivity_key_over`, DaCe `local_dimension_size`); `NeighborTableType` and `ts.ShiftType`; pyright in the typing nox session, with `reportUnnecessaryTypeIgnoreComment: error` so a rejection that stops firing fails the run; ADR 0031 (planned number) | | C: GridTools/gt4py#2910 | `connectivities-as-types-6-class-keyed-providers` | `feat[next]!`: the tree and docs declare connectivities as classes; class-keyed offset providers with `check_offset_provider` at every entry point; `FieldOffset` removed; `as_offset(dim, field)` restricted to an `AnyCartesianAxisIndex`; `table_types` replaces `offset_provider_type`; migration script | | D: GridTools/gt4py#2912 | `connectivities-as-types-8-typed-positions` | `refactor[next]`: `MultiDimensionIndex` and typed embedded positions | `NeighborTableType`, -`TableTypes` and `ts.ShiftType` land in B, `table_types` in C; ADR 0029 and -ADR 0030 are in A and B respectively. +`TableTypes` and `ts.ShiftType` land in B, `table_types` in C; ADR 0030 and +ADR 0031 are in A and B respectively. **ICON4Py migration.** `scripts/python/migrate_connectivities.py` (PR C) rewrites `Dimension(...)` and `FieldOffset(...)` declarations (connectivities @@ -904,7 +912,7 @@ left to ICON4Py. bit vector; the alignment convention and its antisymmetry; why extents are declared; the six axis-level alternatives and the staggering follow-ups. - [[personal/egparedes/connectivities-as-types/connectivities-as-types_identity|What type identity costs the IR, pickle and codegen]]: - the mechanics behind Identity rules 1 and 3–6 — reconstruction by import, the one + the mechanics behind Identity rules 1 and 3–6 — `DimensionRef`, the one `copyreg` hook, fingerprinting, the injective codegen mangling and the `Staggered[D]` tag grammar. - [[personal/egparedes/connectivities-as-types/connectivities-as-types_typing|Decisions made by running mypy and pyright]]: diff --git a/content/personal/egparedes/connectivities-as-types/connectivities-as-types_alternatives.md b/content/personal/egparedes/connectivities-as-types/connectivities-as-types_alternatives.md index d950e1c..c573732 100644 --- a/content/personal/egparedes/connectivities-as-types/connectivities-as-types_alternatives.md +++ b/content/personal/egparedes/connectivities-as-types/connectivities-as-types_alternatives.md @@ -30,8 +30,8 @@ statically meaningful. [[shared/dimensions-as-types|dimensions as types]] and GridTools/gt4py#2844). Keeps independently declared same-named dimensions interchangeable and avoids the importability rule. Rejected because it decouples the Python -type's identity from the IR's, needs a registry plus `copyreg` plus a custom -fingerprint deconstructor to paper over that gap, and cannot give a nested +type's identity from the IR's, needs a name-keyed registry and a blanket +`copyreg` hook to paper over that gap, and cannot give a nested `V2E.Local` a unique name without further convention. See [[personal/egparedes/connectivities-as-types/connectivities-as-types#identity-is-the-qualified-python-name|Identity]]. **Integer type parameters for `max_neighbors`** (`LocalDimensionIndex[F: int, M: int]`). diff --git a/content/personal/egparedes/connectivities-as-types/connectivities-as-types_identity.md b/content/personal/egparedes/connectivities-as-types/connectivities-as-types_identity.md index 7d8ef22..42fc07c 100644 --- a/content/personal/egparedes/connectivities-as-types/connectivities-as-types_identity.md +++ b/content/personal/egparedes/connectivities-as-types/connectivities-as-types_identity.md @@ -8,40 +8,38 @@ status: draft > **Appendix** to [[personal/egparedes/connectivities-as-types/connectivities-as-types|Connectivities as types]]. > The mechanics behind rules 1 and 3-6 of *Identity is the qualified Python name*: -> reconstruction by import, the one `copyreg` hook, fingerprinting, the injective +> `DimensionRef`, the one `copyreg` hook, fingerprinting, the injective > codegen mangling, and the `Staggered[D]` tag grammar. -## Rule 1 — reconstruction from the IR is an import +## Rule 1 — two levels -1. **Reconstruction from the IR is an import.** `resolve(tag)` imports the - longest importable module prefix and walks the rest as attributes (nested - classes like `V2E.Local` resolve naturally), the way `pickle` references a - class. Only where the module path ends is memoized: the attribute walk is - repeated, so a declaration redefined under the same name (a re-run - notebook cell) resolves to the new class. `AxisLiteral` stores only the tag - and derives `kind` and `dim` from it as read-only properties (the `TODO` at - `iterator/ir.py:93`); the derived `kind` is optional, since a local - dimension's is `None`; - printing IR never imports (`resolve_loaded`). `Staggered[D]` tags use the - small grammar `[]`, resolved by subscripting the owner. +1. **Nothing is imported from a tag.** `DimensionRef(module, qualname, kind, + is_cartesian_axis, base)` is frozen, interned and pickled by value. Comparing a ref + with a dimension class raises `TypeError`, since one side missed its conversion; + hash-based lookups cannot be checked and are misses. `AxisLiteral` stores the ref. + `DimensionRef.from_tag(tag, kind, is_cartesian_axis=...)` rebuilds one from text: + the pretty printer prints short names plus a header with each dimension's tag, kind + and axis flag, from which the parser rebuilds the refs. The roundtrip backend, which + runs on classes, takes them from the fields and connectivities of each call. + `Staggered[D]` tags use the small grammar `[]`. ## Rules 3-6 — registry, fingerprints, mangling, staggering 3. **No registry.** Classes pickle by reference. One narrow `copyreg` hook exists, for `Staggered[D]`, whose bracketed qualname `save_global` cannot look up; it reduces to the base dimension and re-interns. -4. **Fingerprints depend on qualified names, plus `kind`.** A dimension is - deconstructed as its by-reference name *and* its declaration-time `kind`, which - decides a field's layout order and the scan axis — so a dimension redefined under - the same name with another kind does *not* reuse artifacts. `Staggered[D]` goes +4. **Fingerprints depend on qualified names, plus the `DimensionRef`.** A dimension is + deconstructed as its by-reference name *and* its ref. The ref has the `kind`, which + decides a field's layout order and the scan axis, and the axis level + (`CartesianAxisIndex` versus `DimensionIndex`), on which index arithmetic depends — + so a dimension redefined under the same name with another of either does *not* reuse + cached stages or artifacts. `Staggered[D]` goes through its base and inherits this; its base cannot be flipped in place, since - the class is interned by base identity and its tag embeds the base tag. The axis - level (`CartesianAxisIndex` versus `DimensionIndex`) is deliberately *not* - fingerprinted: it changes what is accepted, never what is emitted. A connectivity + the class is interned by base identity and its tag embeds the base tag. A connectivity declaration is fingerprinted *additionally* by its domain, codomain, `Local` and counts. Consequently the ADR 0023 build cache invalidates on module renames. 5. **Codegen names need injective mangling.** `codegen_name(tag)` is a prefix - escape — `_`→`_u`, `.`→`_d`, `[`→`_l`, `]`→`_r` — used by gtfn, DaCe, the + escape — `_`→`_u`, `.`→`_d`, `:`→`_c`, `[`→`_l`, `]`→`_r` — used by gtfn, DaCe, the roundtrip backend and the nanobind bindings; its inverse `from_codegen_name` is used by DaCe to parse names back. The simpler "escape `__`, then replace `.`" is **not** injective (`".."` and `"_"` @@ -49,16 +47,16 @@ status: draft to length 4. 6. **Staggering is part of the dimension change.** The `_Staggered` name prefix needs the name→class lookup that type identity removes, so - `Staggered[D]` is a real class and part of ADR 0029 (PR A), together with + `Staggered[D]` is a real class and part of ADR 0030 (PR A), together with the [[personal/egparedes/connectivities-as-types/connectivities-as-types#cartesian-axis-dimensions|Cartesian axis dimensions]] its parameter is bounded on; see [[personal/egparedes/connectivities-as-types/connectivities-as-types#staggeredd|`Staggered[D]`]]. ## The `Staggered[D]` tag - **IR and serialization.** The tag is - `gt4py.next.common.Staggered[]` — the one tag that is not a - qualified name. `resolve` parses the `[]` grammar and - subscripts the owner, the IR pretty-parser accepts it, and `codegen_name` + `gt4py.next.common:Staggered[]` — the one tag that is not a + qualified name. `DimensionRef.from_tag` parses the `[]` grammar + without importing the base, the IR pretty-parser accepts it, and `codegen_name` escapes the brackets. `pickle` cannot look up a bracketed qualname, so one `copyreg` hook reduces a staggered class to its base and re-subscripts on load; fingerprints are likewise taken through the base. diff --git a/content/personal/egparedes/connectivities-as-types/connectivities-as-types_slides.md b/content/personal/egparedes/connectivities-as-types/connectivities-as-types_slides.md index cc8e75e..7de8f67 100644 --- a/content/personal/egparedes/connectivities-as-types/connectivities-as-types_slides.md +++ b/content/personal/egparedes/connectivities-as-types/connectivities-as-types_slides.md @@ -27,7 +27,7 @@ npx -y @marp-team/marp-cli@4 --no-stdin \ One declaration for offset, local dimension and provider key -ADR 0029 (dimensions) · ADR 0030 (connectivities) +ADR 0030 (dimensions) · ADR 0031 (connectivities; planned number) > **Appendix** to [Connectivities as types](connectivities-as-types), summarising the note it is published alongside; where the two disagree the note is authoritative. Every slide links the section it compresses, and the deck adds no facts of its own. Rendering instructions are on the slide before this one. @@ -81,11 +81,11 @@ The class *contains* its local dimension and *is* its own provider key. Nothing ## Identity is the qualified Python name -`tag = f"{cls.__module__}.{cls.__qualname__}"` +`tag = f"{cls.__module__}:{cls.__qualname__}"` - the static view (nominal types) and the runtime view (`is`) agree by construction -- reconstruction from the IR is an **import**, the way `pickle` references a class -- so `` dimensions are rejected, and a redefinition is a *different* connectivity +- below the frontend a dimension is a **`DimensionRef` value**: nothing is imported from a tag +- pickling needs importable classes, so `` dimensions are rejected, and a redefinition is a *different* connectivity - the IR names a connectivity by its `offset_tag` = its local dimension's tag, so shifts, reductions and sparse arguments find one table under **one** string → [Identity](connectivities-as-types#identity-is-the-qualified-python-name) @@ -164,8 +164,8 @@ Of ten cross-object identity constraints: **six dissolve**, three collapse into | PR | Contents | | --- | --- | -| A #2899 | dimensions as classes, `Staggered[D]`, ADR 0029 | -| B #2907 | `NeighborConnectivity`, `LocalDimensionIndex`, ADR 0030 | +| A #2899 | dimensions as classes, `DimensionRef`, `Staggered[D]`, ADR 0030 | +| B #2907 | `NeighborConnectivity`, `LocalDimensionIndex`, ADR 0031 (planned) | | C #2910 | class-keyed providers, `FieldOffset` removed, migration script | | D #2912 | `MultiDimensionIndex`, typed embedded positions | diff --git a/content/personal/egparedes/connectivities-as-types/connectivities-as-types_staggering.md b/content/personal/egparedes/connectivities-as-types/connectivities-as-types_staggering.md index 50eb4dc..34d437c 100644 --- a/content/personal/egparedes/connectivities-as-types/connectivities-as-types_staggering.md +++ b/content/personal/egparedes/connectivities-as-types/connectivities-as-types_staggering.md @@ -240,8 +240,8 @@ Numbered as in the main note's *Open questions*. readable without the declaration, the frontend and embedded shift test matrix doubles, and the keyword would have to be folded into the dimension fingerprint. That last cost is now a known quantity rather than an open hole: Identity rule 4 - fingerprints a dimension's `kind` alongside its by-reference name, so an - alignment keyword would follow the same pattern. Not in this stack. + fingerprints a dimension's `DimensionRef` alongside its by-reference name, so an + alignment would be one more field of the ref. Not in this stack. 6. **`kind`'s remaining two jobs.** Once `LOCAL` leaves the enum, `kind` is a layout sort key and a name for the scan axis. Layout is a property of the field, diff --git a/content/shared/dimensions-as-types.md b/content/shared/dimensions-as-types.md index 329c897..bc59e56 100644 --- a/content/shared/dimensions-as-types.md +++ b/content/shared/dimensions-as-types.md @@ -9,7 +9,7 @@ status: superseded > **Superseded** by > [[personal/egparedes/connectivities-as-types/connectivities-as-types|Connectivities as types]] -> (gt4py ADR 0028, GridTools/gt4py#2899), which makes a dimension a class with +> (gt4py ADR 0030, GridTools/gt4py#2899), which makes a dimension a class with > *type* identity (its qualified name) instead of the `(name, kind)` value > identity and interning registry proposed here. Kept for reference until that > proposal moves to `shared/`. From fc4b60f501b916aefd1eff3e713300a47d8d3a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Gonz=C3=A1lez=20Paredes?= Date: Thu, 3 Dec 2026 17:02:13 +0100 Subject: [PATCH 2/3] =?UTF-8?q?personal/egparedes:=20connectivities=20as?= =?UTF-8?q?=20types=20=E2=80=94=20layout=20order=20and=20roundtrip=20synth?= =?UTF-8?q?esis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../connectivities-as-types/connectivities-as-types.md | 3 ++- .../connectivities-as-types_identity.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/content/personal/egparedes/connectivities-as-types/connectivities-as-types.md b/content/personal/egparedes/connectivities-as-types/connectivities-as-types.md index 7107465..235c5cc 100644 --- a/content/personal/egparedes/connectivities-as-types/connectivities-as-types.md +++ b/content/personal/egparedes/connectivities-as-types/connectivities-as-types.md @@ -494,7 +494,8 @@ The self-type costs two definition-site suppressions, one per checker; P4 of `kind` **shrinks.** It carries four jobs today: `LOCAL` marks a neighbor axis; `order_dimensions` sorts by `(kind, as_non_staggered(dim).value)`, so it decides -memory layout order (constraint F4); `order_dimensions` also uses it to enforce +memory layout order (constraint F4; #2899 sorts by +kind rank, then base qualname, then base tag, so the module does not decide the order); `order_dimensions` also uses it to enforce at most one `LOCAL` dimension; and `VERTICAL` names the scan axis and, by convention, the undecomposed one. The first and third are now class facts — `kind == LOCAL` iff `issubclass(d, LocalDimensionIndex)` — so **`LOCAL` leaves the diff --git a/content/personal/egparedes/connectivities-as-types/connectivities-as-types_identity.md b/content/personal/egparedes/connectivities-as-types/connectivities-as-types_identity.md index 42fc07c..0526e31 100644 --- a/content/personal/egparedes/connectivities-as-types/connectivities-as-types_identity.md +++ b/content/personal/egparedes/connectivities-as-types/connectivities-as-types_identity.md @@ -20,7 +20,8 @@ status: draft `DimensionRef.from_tag(tag, kind, is_cartesian_axis=...)` rebuilds one from text: the pretty printer prints short names plus a header with each dimension's tag, kind and axis flag, from which the parser rebuilds the refs. The roundtrip backend, which - runs on classes, takes them from the fields and connectivities of each call. + runs on classes, takes them from the fields and connectivities of each call, and synthesizes a class + from the ref only for a dimension none of them has. `Staggered[D]` tags use the small grammar `[]`. ## Rules 3-6 — registry, fingerprints, mangling, staggering From ebe1301a8c1dd4d0abbb17148208e47ae26d69a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Gonz=C3=A1lez=20Paredes?= Date: Fri, 4 Dec 2026 00:29:08 +0100 Subject: [PATCH 3/3] =?UTF-8?q?personal/egparedes:=20connectivities=20as?= =?UTF-8?q?=20types=20=E2=80=94=20Domain=20truthiness,=20periodic=20grids,?= =?UTF-8?q?=20layout=20tie-break?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../connectivities-as-types.md | 29 +++++++++++-------- .../connectivities-as-types_staggering.md | 20 +++++++------ 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/content/personal/egparedes/connectivities-as-types/connectivities-as-types.md b/content/personal/egparedes/connectivities-as-types/connectivities-as-types.md index 235c5cc..5f5d0ca 100644 --- a/content/personal/egparedes/connectivities-as-types/connectivities-as-types.md +++ b/content/personal/egparedes/connectivities-as-types/connectivities-as-types.md @@ -379,7 +379,8 @@ stated as rules: 2. **Types must be importable to be pickled.** Only the connectivities of an offset provider still carry classes into a compile job. `` in a qualname is rejected at class creation (for dimensions and connectivities), as an early - heuristic; pickle's own `save_global` stays the authoritative check. Interactive + heuristic: a tag is the qualified name, which must be unique and lets the class + be pickled; pickle's own `save_global` stays the authoritative check. Interactive `__main__` (REPL, notebooks, `python -c`) matters — every notebook declares its dimensions there — so the process-pool runner (`BUILD_JOBS_MODE=process`) detects a job that references such a class and, with a warning, @@ -417,11 +418,13 @@ stated as rules: `NotImplemented` when the right operand is a dimension, so Python falls back to `is` and `I == J` is always a `bool`. It builds a `Domain` only for an *integral* right operand — `I == 5` — which is the one documented exception to "equality is - `is`", and `Domain.__bool__` raises, so a `Domain` can never be mistaken for a - truth value. The residual hazard is narrow and accepted: a dict holding both an - integer key and a dimension-class key whose hashes collide would reach - `bool(Domain)`. Class-keyed providers hold only classes and tag strings, and a - `str` compares unequal to a class, so they cannot. + `is`". A `Domain` is a non-empty `Sequence`, hence truthy, so a container that + mixes integers and dimension classes misbehaves: `I in [5]` is `True` and + `[3, 4].count(I) == 2`. The hazard is inherited from `main` and out of scope here; + a raising `Domain.__bool__` would be a separate change, after a check of the + `if domain:` call sites, where truthiness today means "has a dimension". + Class-keyed providers hold only classes and tag strings, and a `str` compares + unequal to a class, so they are not affected. 9. **Same-named declarations are different connectivities.** Two declarations with the same qualified name from different modules, or a redefinition, are simply different classes; no warning is issued, and @@ -495,7 +498,7 @@ The self-type costs two definition-site suppressions, one per checker; P4 of `kind` **shrinks.** It carries four jobs today: `LOCAL` marks a neighbor axis; `order_dimensions` sorts by `(kind, as_non_staggered(dim).value)`, so it decides memory layout order (constraint F4; #2899 sorts by -kind rank, then base qualname, then base tag, so the module does not decide the order); `order_dimensions` also uses it to enforce +kind rank, then base qualname, then base tag, so the module only breaks ties between equal qualnames); `order_dimensions` also uses it to enforce at most one `LOCAL` dimension; and `VERTICAL` names the scan axis and, by convention, the undecomposed one. The first and third are now class facts — `kind == LOCAL` iff `issubclass(d, LocalDimensionIndex)` — so **`LOCAL` leaves the @@ -846,11 +849,13 @@ with the reasoning, so that a later reader does not reopen them. §4d). 7. **A cell `degree` on the axis.** Left out because **nothing consumes it** until an exterior-calculus surface exists; a static `degree=0|1` is itself perfectly - well defined and needs no periodicity. The ranges do *not* substitute for it: a - periodic axis gives both classes `[0, n)` under either assignment and halo - padding makes the widths arbitrary, so degree is not inferable from extents in - general. The dependency runs the other way — *deriving extents* needs the degree - plus a periodicity and halo policy. A degree is *canonical* for + well defined. The axis is the infinite integer line (ADR 0030); a `Domain` selects + a bounded range of it, and periodicity is a wrap-around rule of the grid, not of + the dimension. The ranges do *not* substitute for a degree: on a periodic grid both + classes can be `[0, n)` under either assignment and halo padding makes the widths + arbitrary, so degree is not inferable from extents in general. The dependency + runs the other way — *deriving extents* needs the degree plus the grid's + wrap-around and halo policy. A degree is *canonical* for a mesh location and only *declarational* for an axis, so it belongs on the `LocationIndex` of the next item; see [[personal/egparedes/connectivities-as-types/connectivities-as-types_staggering|the staggering appendix]] and [[personal/egparedes/connectivities-as-types/connectivities-as-types_conventions|conventions]] §4a. diff --git a/content/personal/egparedes/connectivities-as-types/connectivities-as-types_staggering.md b/content/personal/egparedes/connectivities-as-types/connectivities-as-types_staggering.md index 34d437c..5294729 100644 --- a/content/personal/egparedes/connectivities-as-types/connectivities-as-types_staggering.md +++ b/content/personal/egparedes/connectivities-as-types/connectivities-as-types_staggering.md @@ -18,9 +18,10 @@ status: draft A **Cartesian axis** is an index space with integer index arithmetic and exactly one staggered partner — the dimensions `CartesianConnectivity` acts on. -Read one axis of a Cartesian grid as a -1-dimensional CW complex — a path when the axis is bounded, a cycle when it is -periodic. Such a complex has exactly two cell classes, of degree 0 and 1, and a +The axis itself is the two-way infinite integer line (ADR 0030); read it as a +1-dimensional CW complex. A `Domain` selects a bounded range of it, which is a +path complex; a periodic grid is that range plus a wrap-around rule owned by the +grid, not a property of the dimension. Such a complex has exactly two cell classes, of degree 0 and 1, and a declared axis together with its `Staggered[·]` name those two classes. `Staggered` is the **involution that swaps them**. The types do not say which class has degree 0, and they need not: the ADR 0026 position convention @@ -99,7 +100,7 @@ a reference implementation and on boundary index ranges. ## 3. Extents **Extents are declared, never derived.** A path complex has `n` 0-cells and -`n - 1` 1-cells; a cycle has `n` and `n`. So the two members of a pair do not in +`n - 1` 1-cells; with a periodic wrap-around the grid may use `n` and `n`. So the two members of a pair do not in general have the same range, and for a bounded, halo-free complex *which one is wider is the degree assignment* (periodicity or halo padding destroys that correspondence — see §7): @@ -110,8 +111,9 @@ the interfaces run `[0, n+1)`. Both are expressible without any new type-level concept because a `Domain` holds absolute `UnitRange(start, stop)`s rather than sizes — see [[personal/havogt/field-data-protocol/field-data-protocol|the field data protocol]] -for why absolute addressing is the right domain model — and the periodic case -needs nothing extra, the two ranges simply coincide in size. The invariant a grid +for why absolute addressing is the right domain model — and a periodic grid +needs nothing extra from the dimension: the two ranges coincide in size and the +wrap-around belongs to the grid's boundary or halo handling. The invariant a grid builder owes is that the two ranges *interleave*; their sizes then differ by at most one when the complex is closed, and halo extension relaxes even that (two of SGRID's four bounded cases, `low` and `high`, have equal sizes). An absolute range @@ -268,10 +270,10 @@ Numbered as in the main note's *Open questions*. exterior-calculus surface exists (Proposal 1 of [[personal/egparedes/discretization-independent-fd-syntax|the surface-syntax note]]). Absolute ranges do **not** determine the - degree in general: a periodic axis gives both classes `[0, n)` under either + degree in general: on a periodic grid both classes can be `[0, n)` under either assignment, and halo padding makes the relative widths arbitrary. A static degree - needs no periodicity and would not be ill-defined — it is *deriving extents* that - needs the degree together with a periodicity and halo policy. Revisit if that + is a property of the infinite line and would not be ill-defined — it is *deriving + extents* that needs the degree together with the grid's wrap-around and halo policy. Revisit if that surface lands — but note that a degree is *canonical* for a mesh location and only *declarational* for a Cartesian axis, so it belongs on the `LocationIndex` of the main note's item 8 rather than here