Big refactor of the core + context - #12
Draft
bgailleton wants to merge 31 commits into
Draft
Conversation
… rest of the package
… - not possible because my param injections are ot visible by the latter
Collaborator
Author
|
if the ref arrives anywhere, ignore the links to |
bgailleton
marked this pull request as draft
July 27, 2026 15:01
…. Add the noise helpers for perlin and all
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current framework limitations
In short, there are two main issues.
Contexts are too convoluted and inflexible.
The current design relies on many context types, each with its own parameters, kernels, helpers, and related logic. This makes the framework difficult to understand, hard to extend, and overly monolithic.
The Taichi ecosystem has slowed down.
While
taichiis still maintained, its pace of development has decreased significantly. This is a good opportunity to redesign the framework around a single composition philosophy while remaining backend-agnostic. In particular,quadrants—a fork oftaichithat has been actively developed since mid-2025—provides a promising alternative backend.Refactor
The new architecture is significantly more modular. It is built around a small set of abstract classes, ordered from low-level building blocks to high-level abstractions.
Parameter: Represents a physical parameter that can be constant, scalar, or spatially varying (e.g. the erodability coefficientK).Helper: Represents a device-side utility function. For example, a kernel may call a placeholder such asget_left_neighbour, which is bound at compile time to an implementation such as_get_left_neighbour_periodic,_get_left_neighbour_normal, or_get_left_neighbour_nodata_check. This allows boundary conditions and similar behaviors to be changed without modifying the kernel itself.Bag: A structured collection ofParameters andHelpers that provides a clean namespace for kernel dependencies.Kernel: Encapsulates the GPU computation itself. A kernel is bound to aBagcontaining its parameters and helpers. Changing these dependencies requires recompilation, but the kernel implementation remains unchanged.Routine: A collection of relatedKernels. It automates resource management (e.g. acquiring and releasing temporary arrays from the memory pool), enforces a unique dependency bag, and enables backend-specific optimizations such as kernel fusion (taichiandquadrants) or CUDA Graph execution (cupy.RawKernel).Program: The highest-level abstraction. A program represents a complete, ready-to-use simulation, including routines, owned data, accessors, setters, and conversion utilities (e.g. tonumpy).These abstract interfaces are implemented for multiple backends. Currently, three are supported:
taichi: the legacy, mature backend.quadrants: a newer, actively developed backend with ataichi-like programming model.cupy.RawKernel: a low-level CUDA backend.Once the building blocks have been assembled, a
Kernel,Routine, orProgramcan be compiled and used in a simulation.TODO
Parameter,Helper,Kernel, andRoutine.taichi,quadrants, andcupy.RawKernel.GridContextwith mergeableBags of parameters and helpers.Programinterface.Programclasses.