---
# System prepended metadata

title: '[GT4Py] Compile time domains'
tags: [cycle 30 07/25]

---

# [GT4Py] Compile time domains

###### tags: `cycle 30 07/25` <!-- Change to the current cycle number -->

- Shaped by: Till Ehrengruber, Sara Faghih-Naini
- Appetite (FTEs, weeks): 
- Developers: Sara

## Problem

- Compile times due to excessively large domain expressions
- Simplification of concat_where expressions beyond what we are currently able to do
<!-- The raw idea, a use case, or something we’ve seen that motivates us to work on this -->

## Appetite
<!-- Explain how much time we want to spend and how that constrains the solution -->

## Solution


- Step 1: Merge [`get_domain` PR](https://github.com/GridTools/gt4py/pull/1893)
  - Remove implicit size args (simplify / remove `_process_args`, cleanup `CompileTimeArgs`)
  - Does this PR work DaCe? Talk to Edoardo
- Step 2: Write a pass that transforms  
    Example program:
    ```python
    @program
    def my_prog(inp, out):
      fo(inp, out=out)
    ```
    Corresponding IR:
    ```
    SetAt(
      target=out,
      expr=fo(inp),
      domain=unstructured_domain(
        Vertex, get_domain(out, Vertex)[0], get_domain(out, Vertex)[1],
        get_domain(out, K)
      )
    )
    ```
    into:

    ```
    SetAt(
      target=out,
      expr=fo(inp),
      domain=unstructured_domain(
        named_range(Vertex, 0, 50000),
        named_range(K, 0, 100)
      )
    )
    ```
    Passes that have similar "mechanics": TraceShiftPass, Domain Inference, Type Inference
- Step 3: Figure out how the pass gets the static sizes from the runtime fields and integrate the pass into `apply_common_transforms`. If no compile time sizes are given, use runtime sizes. Whether they are used could be configured as such:
    ```python
    @program(static_domain_sizes=True)
    def my_prog(inp, out):
      fo(inp, out=out)
    ```
<!-- The core elements we came up with, presented in a form that’s easy for people to immediately understand -->

## Rabbit holes
<!-- Details about the solution worth calling out to avoid problems -->

## No-gos
<!-- Anything specifically excluded from the concept: functionality or use cases we intentionally aren’t covering to fit the ## appetite or make the problem tractable -->
