Show HN: Mandala – Automatically save, query and version Python computations `mandala` is a framework I wrote to automate tracking ML experiments for my research. It differs from other experiment tracking tools by making persistence, query and versioning logic a generic part of the programming language itself, as opposed to an external logging tool you must learn and adapt to. The goal is to be able to write expressive computational code without thinking about persistence (like in an interactive session), and still have the full benefits of a versioned, queriable storage afterwards. Surprisingly, it turns out that this vision can pretty much be achieved with two generic tools: 1. a memoization+versioning decorator, `@op`, which tracks inputs, outputs, code and runtime dependencies (other functions called, or global variables accessed) every time a function is called. Essentially, this makes function calls replace logging: if you want something saved, you write a function that returns it. Using (a lot of) hashing, `@op` ensures that the same version of the function is never executed twice on the same inputs. Importantly, the decorator encourages/enforces composition. Before a call, `@op` functions wrap their inputs in special objects, `Ref`s, and return `Ref`s in turn. Furthermore, data structures can be made transparent to `@op`s, so that an `@op` can be called on a list of outputs of other `@op`s, or on an element of the output of another `@op`. This creates an expressive "web" of `@op` calls over time. 2. a data structure, `ComputationFrame`, can automatically organize any such web of `@op` calls into a high-level view, by grouping calls with a similar role into "operations", and their inputs/outputs into "variables". It can detect "imperative" patterns - like feedback loops, branching/merging, and grouping multiple results in a single object - and surface them in the graph. `ComputationFrame`s are a "synthesis" of computation graphs and relational databases, and can be automatically "exported" as dataframes, where columns are variables and operations in the graph, and rows contain values and calls for (possibly partial) executions of the graph. The upshot is that you can query the relationships between any variables in a project in one line, even in the presence of very heterogeneous patterns in the graph. I'm very excited about this project - which is still in an alpha version being actively developed - and especially about the `ComputationFrame` data structure. I'd love to hear the feedback of the HN community. Colab quickstart: https://ift.tt/oybcEw9... Blog post introducing `ComputationFrame`s (can be opened in Colab too): https://ift.tt/9diqoae Docs: https://ift.tt/QSAH0Pn https://ift.tt/cxqWokm July 12, 2024 at 01:40AM
Show HN: Mandala – Automatically save, query and version Python computations https://ift.tt/78O5x2f
Related Articles
Show HN: Tamagui – Universal React design systems optimized for native and web https://ift.tt/3nJCdGAShow HN: Tamagui – Universal React design systems optimized for native… Read More
Show HN: Bare turns one's Twitter timeline into an old-school blog reader https://ift.tt/3132IxUShow HN: Bare turns one's Twitter timeline into an old-school blog rea… Read More
Show HN: Configurable and auto-formattable markup language https://ift.tt/3CWSX1mShow HN: Configurable and auto-formattable markup language https://ift… Read More
Show HN: Fast(er) Sorting with Sorting Networks https://ift.tt/3cTVr69Show HN: Fast(er) Sorting with Sorting Networks https://ift.tt/3CWwf9J… Read More
Show HN: TriOTP, the OTP Framework for Python Trio https://ift.tt/3legANcShow HN: TriOTP, the OTP Framework for Python Trio https://ift.tt/3cTz… Read More
Show HN: Giving a 2D grid a 3D look – part 3 https://ift.tt/3nQWGJHShow HN: Giving a 2D grid a 3D look – part 3 https://ift.tt/3cPQpaS No… Read More
Show HN: Janken – A rock paper scissors game https://ift.tt/3CBV5f7Show HN: Janken – A rock paper scissors game https://neet.vc/janken/ N… Read More
Show HN: Learn Latin through interactively reading the Classics https://ift.tt/3DIxydIShow HN: Learn Latin through interactively reading the Classics https:… Read More
0 Comments: