BotBeat
...
← Back

> ▌

Independent ResearchIndependent Research
RESEARCHIndependent Research2026-07-24

Torchwright: Compiling Algorithms Directly into Transformer Weights

Key Takeaways

  • ▸Torchwright proves that transformers can express arbitrary algorithms by constructing exact weights, decoupling architectural capability from training ability
  • ▸The tool enables zero-training transformer models that execute pre-programmed algorithms, starting with simpler architectures (ReLU FFNs, custom position encoding) for tractability
  • ▸A practical application demonstrates binary arithmetic on a compiled Phi-3 model loaded with standard Hugging Face, showing the viability of hand-constructed transformer weights
Source:
Hacker Newshttps://ood.dev/posts/torchwright-intro/↗

Summary

Vinay U Prabhu has developed Torchwright, a tool that compiles arbitrary computation graphs into the exact weight matrices of transformer models without any training. By constructing weights explicitly to implement specific algorithms, the project proves that transformer architectures can express arbitrary computations—answering a foundational question about what transformers are fundamentally capable of. The tool is demonstrated on a binary increment operation compiled into a Phi-3 checkpoint that can perform arithmetic using vanilla Hugging Face, with zero training involved.

The approach is inspired by prior work (RASP and Tracr) but aims for greater flexibility and intuitiveness by allowing developers to define algorithms in standard Python and letting the compiler manage memory allocation in the transformer's residual stream. The compiler assigns each intermediate value to specific columns in the residual stream and scatters corresponding weight matrices, enabling the composition of primitive operations (FFNs with ReLU, position encodings) into sophisticated algorithms without relying on gradient-based learning.

Editorial Opinion

This is a refreshing reversal of the usual machine learning narrative. Rather than asking 'what can we train transformers to do?', Prabhu asks 'what can transformers fundamentally express?'—and answers by proving it mathematically through weight construction. The work challenges assumptions about the necessity of training and opens a new angle on mechanistic interpretability: if you can construct weights to perform a task, you've proven the capability exists in the architecture itself. This could have profound implications for understanding transformer limitations and designing more capable architectures.

Large Language Models (LLMs)Machine LearningDeep LearningScience & ResearchOpen Source

More from Independent Research

Independent ResearchIndependent Research
RESEARCH

Persistent State Machine Architecture Achieves 2,129x Speedup for LLM Attention, Breaches Von Neumann Memory Wall

2026-07-25
Independent ResearchIndependent Research
RESEARCH

LLMs Learn Like Humans: New Research Shows Language Models Improve Reasoning Through Self-Generated Notes

2026-07-24
Independent ResearchIndependent Research
RESEARCH

Researchers Release Taxonomy of AI-Related Extinction Scenarios

2026-07-23

Comments

Suggested

LGLG
OPEN SOURCE

Toolgz Slashes LLM Tool-Definition Tokens 80% With Zero Accuracy Loss

2026-07-25
AnthropicAnthropic
PRODUCT LAUNCH

Anthropic Releases Claude Opus 5: Mid-Tier Model Balances Performance and Affordability

2026-07-25
ApertusApertus
PRODUCT LAUNCH

Apertus 1.5 Brings Image Understanding and 4x Context Window to Open-Source LLM

2026-07-25
← Back to news
© 2026 BotBeat
AboutPrivacy PolicyTerms of ServiceContact Us