# [GT4Py] Flexible Embedded Backends <!-- Add the tag for the current cycle number in the top bar --> - Shaped by: Hannes - Appetite (FTEs, weeks): 1 cycle, 1 dev + 1 for knowledge transfer - Developers: <!-- Filled in at the betting table unless someone is specifically required here --> ## Problem The toolchain steps where put into workflows in the previous cycle. Still some steps, specifically the ones checking the syntactical/type correctness, are hard-coded in the `field_operator`/`program` decorators. The desired state would be to allow full customization of the toolchain via workflow steps by specifying a backend (TODO: to be renamed to `workflow`, `toolchain`, `transforms`, `???`?). This would allow pure embedded (without linting through parsing+lowering+type deduction) without hacks. This project also serves as knowledge transfer for the workflowified toolchain. ## Appetite 1 cycle ## Solution Fixing the problem is both a cleanup and a feature: - remove special-casing around "embedded backends" - enable full customization The linting steps which are currently in `post_init`s in decorators will be removed. Instead these steps become part of a backend (This is already in the pipeline: [#1516](https://github.com/GridTools/gt4py/pull/1516), only the calls remain in the decorators). A fully `None` backend will not do any checks or transformations. To keep early checking we add an embedded backend with a linting step. To keep current behavior this will become the new default backend. To be able to switch the default we need a customization option for the default backend, to allow field_operators to have non-checked backend even without explicitly setting a backend on each of them. Additional design questions, for follow-up cleanup: - clear separation of workflows that run at different times: - at load of the function: linting - at compile time (to enable AOT compilation, should not use runtime \*arg \*\*kwargs, only in case of jit) - at run time (should only call?) ## Rabbit holes <!-- Details about the solution worth calling out to avoid problems --> Having the no-checks embedded execution represented internally by a `None`-valued backend might not be achievable without special casing in the decorator classes. Mitigate by time-boxing any exploration into this and else choose to convert a value of `None` passed to the decorator functions to another representation of the no-checks embedded execution (some kind of backend instance). ## 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 --> ## Progress <!-- Don't fill during shaping. This area is for collecting TODOs during building. As first task during building add a preliminary list of coarse-grained tasks for the project and refine them with finer-grained items when it makes sense as you work on them. --> - [x] Task 1 ([PR#xxxx](https://github.com/GridTools/gt4py/pulls)) - [x] Subtask A - [x] Subtask X - [ ] Task 2 - [x] Subtask H - [ ] Subtask J - [ ] Discovered Task 3 - [ ] Subtask L - [ ] Subtask S - [ ] Task 4