I built a compiler that turns computation graphs into the weights of a vanilla transformer — no training anywhere [P]
Our take
The recent demonstration of a compiler, Torchwright, that translates computation graphs into transformer weights—without any training—is a fascinating development with significant implications for how we understand and utilize large language models. It elegantly sidesteps the traditional training paradigm, allowing for the direct encoding of algorithms into a transformer architecture. This work builds on prior efforts like RASP and Tracr, but distinguishes itself by its ability to express computation graphs in standard Python and target a readily accessible architecture like Phi-3, ensuring compatibility with standard Hugging Face tooling. The ability to bypass training entirely, as highlighted in Multi-Tenant SaaS: Which Architecture Would You Choose?, opens up new avenues for deploying and customizing models, potentially reducing computational costs and accelerating development cycles – especially relevant as we grapple with the resource demands of ever-larger models. The underlying principle—that a transformer can, in essence, *execute* a program—is a profound observation and one that challenges our conventional understanding of these models as purely learning machines.
The beauty of this approach lies in its accessibility and flexibility. By defining a computation graph in Python, users can effectively “program” a transformer to perform specific tasks without requiring massive datasets or extensive training runs. This contrasts sharply with the current landscape where model development is heavily reliant on data curation and optimization. Consider the insights shared in Understanding GPU Inference Workloads; the ability to pre-define model behavior could dramatically alter inference patterns and optimize resource utilization. The project’s repository, containing twelve runnable examples, serves as a valuable resource for exploring the capabilities of Torchwright and demonstrating its practical applications. It's a tangible illustration of how we can move beyond viewing transformers solely as statistical learners and toward seeing them as programmable computational engines. The work also echoes the broader discussions around model interpretability and understanding, as explored in Neurips Position Track Rebuttal and Reviews, prompting questions about the inherent algorithmic capacity of these architectures.
The significance extends beyond simply circumventing training. It suggests a deeper connection between transformers and the broader field of computation. If we can define arbitrary algorithms as computation graphs and then translate them into transformer weights, it raises the possibility of using transformers to execute a wider range of tasks than currently imagined. This could unlock new applications in areas such as scientific computing, symbolic reasoning, and even robotics, where the ability to precisely control model behavior is crucial. The development also highlights the importance of architectural choices. Targeting a standard architecture like Phi-3, rather than a custom one, ensures broader accessibility and facilitates integration into existing workflows. This pragmatism is key to driving adoption and accelerating the exploration of these new possibilities.
Looking ahead, it will be crucial to investigate the limitations of this approach. Can all algorithms be efficiently expressed as computation graphs suitable for transformer execution? How does the size and complexity of the graph impact performance? And importantly, how does this technique compare to traditional training-based approaches in terms of accuracy and efficiency across different task domains? The ability to programmatically define transformer behavior represents a paradigm shift with the potential to fundamentally reshape the future of AI, and it’s a question worth watching as researchers continue to explore the boundaries of what these models can truly achieve.
I've been chasing the question of what algorithms a transformer can actually express -- separate from what it can learn. So I built a compiler: define a computation graph in ordinary Python, and it produces the weights of a transformer that executes the graph. The result is a standard Phi-3-architecture checkpoint that vanilla huggingface loads with no custom code and no trust_remote_code. Zero training in the pipeline.
Write-up (origin + how the constructions work): https://ood.dev/posts/torchwright-intro/
Repo (twelve runnable examples): https://github.com/physicsrob/torchwright
Hand-built transformer weights aren't a new idea. RASP defines a language whose primitives map onto transformer sublayers, and Tracr compiles RASP programs into actual weights. I wanted two things they don't aim for: expressing a computation graph in ordinary Python, and targeting a stock architecture, so the output loads in vanilla huggingface with no custom code.
[link] [comments]
Read on the original site
Open the publisher's page for the full experience