Skip to content

fix[next]: format domain warnings for array scalars - #2924

Closed
dganellari wants to merge 2 commits into
GridTools:mainfrom
dganellari:review-domain-warning
Closed

dganellari wants to merge 2 commits into
GridTools:mainfrom
dganellari:review-domain-warning

Conversation

@dganellari

@dganellari dganellari commented Sep 25, 2026 •

Copy link
Copy Markdown

Non-contiguous domain inference can produce a zero-dimensional array when connectivity data lives on a GPU. Formatting the warning calls round() on that array and raises instead of reporting the intended warning. Convert the percentage to a Python float before rounding; the warning threshold and inferred domain stay unchanged.

# Before
round((1 - fraction_accessed) * 100)
# After
round(float((1 - fraction_accessed) * 100))

This independent fix targets main and contains no optimization passes. The regression test covers ordinary scalar and zero-dimensional array reduction results. Focused tests and staged checks passed; the fix was also included in the refreshed companion stack's successful MI300A/GH200 GPU runs, although those runs are not a dedicated GPU warning-path test.

Related independent optimizations: #2922 and #2923. ICON4Py's integration is C2SM/icon4py#1484.

@dganellari dganellari mentioned this pull request Sep 25, 2026
2 tasks done
Prevent GPU domain inference from failing while reporting the warning.
f"Translating '{expr}' using '{tag}' requires "
f"computations on many additional points "
f"({round((1 - fraction_accessed) * 100)}%) in order to get a contiguous "
f"({round(float((1 - fraction_accessed) * 100))}%) in order to get a contiguous "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's convert fraction_accessed instead and add a comment why.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, converted fraction_accessed where it is calculated and added a comment explaining why.

data=np.asarray([0] + [99] * 99, dtype=fbuiltins.IndexType).reshape((100, 1)),
)
}
if array_scalar:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I would just skip the test or otherwise use cupy when available.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced the array with CuPy when a GPU is available.

@havogt havogt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we merge #2953, this changes is not needed.

…atting warnings.

Replace the simulated array test with a CuPy case when a GPU is available.
havogt added a commit that referenced this pull request Oct 30, 2026
…ty tables (#2953)

Compilation received the runtime offset provider, so it depended on
where and how connectivity tables are stored:

- With `GT4PY_BUILD_JOBS_MODE=process`, workers get a host copy of each
table, while serial and thread compilation use the device original. On
GPU backends the compiled input and its persistent translation-cache key
therefore differed between modes.
- Compile-time domain inference (`_max_domain_range_sizes`,
`_unstructured_translate_range_statically`) reduced device arrays, which
means implicit syncs and cupy 0-d results (see #2924).

Compilation now runs against a compile-time view of the offset provider.
`make_compilation_task` replaces each gather connectivity, once per
runtime connectivity, by a compile-time connectivity: a read-only,
C-contiguous host table, memory-mapped from a file in the session cache
directory named by a digest of its content (dtype, shape and data,
hashed in place). It is fingerprinted by the digest instead of the table
and pickled as a reference to its file, which replaces the previous file
references and the `with_refs` variant of `CompilationTask`. Workers
unpickle the compilable inside the task, so an unreadable table file
fails only that task instead of breaking the pool. All runners therefore
compile the same input with the same key, and the host tables live in
the page cache, shared with the workers. Compilation that bypasses
`make_compilation_task` (e.g. a direct `Backend.compile`) still sees the
runtime tables. Execution always receives the runtime offset provider.

Translation-cache keys of programs with connectivities change on all
backends, so they are re-translated once.
@havogt

havogt commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

#2953 is now merged, so I am closing this one.

@havogt havogt closed this Oct 30, 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.

3 participants