Skip to content

fix[next]: accept unused connectivities in offset provider for gtfn#2633

Draft
havogt wants to merge 1 commit into
GridTools:mainfrom
havogt:fix-863-gtfn-unused-connectivity
Draft

fix[next]: accept unused connectivities in offset provider for gtfn#2633
havogt wants to merge 1 commit into
GridTools:mainfrom
havogt:fix-863-gtfn-unused-connectivity

Conversation

@havogt

@havogt havogt commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

What

Fixes #863.

A @field_operator / @program called with an offset provider that contains connectivities it does not use currently crashes on the gtfn backend. Such a program is lowered to a cartesian grid type (using a connectivity would force unstructured), but the offset provider still carries the connectivity — e.g. when a single offset provider is shared across many programs (the icon4py pattern).

The embedded, roundtrip, and dace backends already handle this; only gtfn raised:

AssertionError  # itir_to_gtfn_ir.py: assert grid_type == common.GridType.UNSTRUCTURED

How

In cartesian mode, ignore connectivities from the offset provider:

  • itir_to_gtfn_ir._collect_offset_definitions: skip connectivity entries instead of asserting UNSTRUCTURED (a cartesian program never references their tags).
  • gtfn_module._process_connectivity_args: still declare a wrapper parameter for every connectivity so the runtime's positional connectivity arguments line up, but mark cartesian-mode ones pass_through and don't forward them into the generated program.
  • otf/binding: a pass_through parameter is forwarded to the callee raw, without constructing a buffer SID — so no generated::<dim>_t tags are required for it.

The unstructured path is unchanged.

Test

Added test_unused_connectivity_in_offset_provider (runs across the backend matrix): a cartesian copy operator invoked with a connectivity in the offset provider. Verified passing on embedded / roundtrip / gtfn / dace (CPU).

A field operator called with an offset provider that contains
connectivities it does not use is lowered to a cartesian grid type
(using a connectivity would force unstructured). The gtfn backend then
asserted `grid_type == UNSTRUCTURED` while collecting offset definitions
and crashed.

In cartesian mode, ignore such connectivities: they are still declared
as wrapper parameters so the runtime call signature stays stable, but
are passed through the bindings without building a SID, since the
generated program neither defines their dimension tags nor accesses
them.

Fixes GridTools#863.
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.

Functional: Enable passing of non-empty offset providers

1 participant