How pkraison/toonygrad works
• Core Engine and Codegen: Represented by directories like engine (including files such as realize.py and schedule.py). This is where the computation scheduling, code generation, and memory planning (referenced in the README) happens.
• Tensor & Operations: The tensor.py file is central, and it interacts with various modules (toonygrad/function.py, ops.py). Also include the “UOp” and related UOps elements, which are now used in place of LazyBuffer.
• Neural Network Layer (NN): The nn directory (with datasets, optim, state) indicates higher-level abstractions for training and inference.
• Backend & Runtime: Capture device-related functionalities (device.py) and runtime-specific operations (runtime/ops_clang.py). This is critical because the project now supports only the CLANG backend.
• Data Types and Helpers: Modules like dtype.py and helpers.py provide foundational support that is decoupled from the rest of tinygrad’s dependencies.
Relationships and data flow
• That the NN layer (neural network abstractions) builds on top of the tensor and engine components, using helper functions and datasets.
• The renderer should be shown as a utility that interfaces with both the engine and tensor components for formatting or debugging output.
• That the lower-level device and runtime layers feed the engine with hardware-specific operations (CLANG backend).
Architectural patterns or design principles
• Dependency inversion: Higher-level NN operations are built on lower-level tensor and engine functionalities.
• Emphasis on immutability and modern Python practices: The removal of mutable lazy buffers in favor of “immutable UOp” indicates design consistency favoring immutability.
• Monolithic core refactoring: Since toonygrad is “just a replacement of engine and codegen,” focus on the engine as the central orchestrator.
Additional details based on the README
• Dependency on Python 3.10 as an environment requirement.