I built a compiler that turns computation graphs into the weights of a vanilla transformer — no training anywhere [P]

· Source: Machine Learning · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Software Development & Engineering · Depth: Expert, quick

Summary

A new compiler, "torchwright", has been developed to convert computation graphs defined in ordinary Python directly into the weights of a vanilla transformer model. This tool generates a standard Phi-3-architecture checkpoint that can be loaded by Hugging Face without any custom code or "trust_remote_code", entirely bypassing the traditional training process. The project aims to investigate the inherent algorithmic expressiveness of transformers, separate from their learning capabilities. Unlike previous approaches like RASP and Tracr, which also compile programs into transformer weights, "torchwright" prioritizes using standard Python for graph definition and targeting a stock transformer architecture for seamless integration. The repository includes twelve runnable examples demonstrating its functionality.

Key takeaway

For Machine Learning Engineers exploring model efficiency or interpretability, this compiler offers a novel approach to embed deterministic computations directly into transformer architectures. You can now define specific algorithms in Python and compile them into Phi-3 weights, potentially reducing training overhead for certain tasks or integrating operations that are difficult for neural networks to learn efficiently. Consider experimenting with "torchwright" to inject "frozen tools" or complex, non-learnable functions into your models, enhancing their capabilities without extensive retraining.

Key insights

A compiler directly generates vanilla transformer weights from Python computation graphs, demonstrating inherent algorithmic expressiveness without training.

Principles

Method

Define a computation graph in ordinary Python, then compile it to generate weights for a standard Phi-3-architecture transformer, loadable directly via Hugging Face.

In practice

Topics

Code references

Best for: Research Scientist, AI Scientist, Machine Learning Engineer, AI Architect

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Machine Learning.