Skip to content

Conversation

@tehrengruber
Copy link
Contributor

@tehrengruber tehrengruber commented Nov 5, 2025

In #1968 we introduced pre- and jit-compilation of static arguments. In the first version this was only support for programs, but not field operators which were directly called. This PR extends to functionality to also support field operators and scans.

A good amount of technical debt which accumulated around the Backend.__call__ method was also removed as it became obsolete with the unified approach.

Since scans are the only type of callable with generic arguments and there is a good amount of technical debt surrounding them that was beyond the scope of this PR, the first version barely implements something working for them and prints a warning as performance is likely not great. If performance is needed a simple workaround is to wrap the scan into a field operator or program.

tehrengruber added a commit to tehrengruber/gt4py that referenced this pull request Nov 5, 2025
tehrengruber added a commit to tehrengruber/gt4py that referenced this pull request Nov 5, 2025
tehrengruber added a commit to tehrengruber/gt4py that referenced this pull request Nov 6, 2025
tehrengruber added a commit to tehrengruber/gt4py that referenced this pull request Nov 10, 2025
tehrengruber added a commit to tehrengruber/gt4py that referenced this pull request Nov 13, 2025
tehrengruber added a commit to tehrengruber/gt4py that referenced this pull request Nov 13, 2025

foast_to_itir: workflow.Workflow[AOT_FOP, itir.FunctionDefinition]

def __call__(self, inp: AOT_FOP) -> AOT_PRG:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function used to be wrong. The out argument was previously passed in kwarg_types, but this function just ignored all values in kwarg_types and just added out manually again. With the CompiledProgramPool the out argument is just the third argument and not a keyword argument anymore (consistent with the program definition below). Since this function should be reworked or replaced I didn't bother and just dropped the manual addition and added some sanity checks.

)


@dataclasses.dataclass(frozen=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not used anywhere including in icon4py and PMAP so I removed it instead of investing time into making it compatible with _CommonProgramLike.


# TODO(tehrengruber): This class does not follow the Liskov-Substitution principle as it doesn't
# have a program definition. Revisit.
@dataclasses.dataclass(frozen=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not used anywhere including in icon4py and PMAP so I removed it instead of investing time into making it compatible with _CommonProgramLike. Since Backend.__call__ was removed it couldn't stay.

@@ -1,400 +0,0 @@
```python
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file has become mostly obsolete with the introduction of CompiledProgram, hence I removed it here.

tehrengruber added a commit to tehrengruber/gt4py that referenced this pull request Jan 28, 2026
Copy link
Contributor

@egparedes egparedes left a comment

Choose a reason for hiding this comment

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

Looks good to me. Don't have any serious objection, mostly naming and code style issues, many of them optional.


DEFAULT_BACKEND: next_backend.Backend | None = None

DefinitionT = TypeVar(
Copy link
Contributor

Choose a reason for hiding this comment

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

Not criticial but this typevar name is too generic. What about DSLDefT or something in that direction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went for ProgramLikeDefinitionT for now. If we really want to do DSLCallable we should also rename CompiledProgram to CompiledDSLCallable etc. This doesn't feel like a good fit for this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think ProgramLike is meaningless in this context and that the right solution would be exactly what you propose as non-fitting this PR: use DSLCallable here and rename CompiledProgram to CompiledDSLCallable. Anyway, unless @havogt has a strong opinion towards one of the options, this should not be a blocker for this PR.

Comment on lines 61 to 66
class _ProgramLikeMixin(Generic[DefinitionT]):
"""
Mixing used by program and program-like objects.

Contains functionality and configuration options common to all kinds of program-likes.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest a different naming, in the same spirit as the previous suggestion:

Suggested change
class _ProgramLikeMixin(Generic[DefinitionT]):
"""
Mixing used by program and program-like objects.
Contains functionality and configuration options common to all kinds of program-likes.
"""
class _DSLCallableMixin(Generic[DSLDefT]):
"""
Mix-in used by directly callable GT4Py DSL artifacts like programs and operators.
Contains functionality and configuration options common to all kinds of callable artifacts.
"""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See comment above.

Copy link
Contributor

Choose a reason for hiding this comment

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

See answer above.

Copy link
Contributor

@egparedes egparedes left a comment

Choose a reason for hiding this comment

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

LGTM

@tehrengruber tehrengruber merged commit dd23d1f into GridTools:main Jan 29, 2026
22 of 23 checks passed
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