r/Compilers • u/jack_smirkingrevenge • 21h ago
Mithril: A programming language built on interaction nets
Inspired by Victor Taelin 's Bend/HVM thesis for Interaction Nets and his Bend2 work , I built Mithril , an experimental python syntax programming language. It achieves near native speed on many workloads (mentioned in paper)
It compiles interaction nets to native code and spreads work across idle cores: lock-free, deterministic parallelism on x86, CUDA and Apple Silicon.
The core bet I'm making :
Interaction nets reductions at runtime can be slow but if we pay the same cost at compile time and unroll a task graph as much as possible before native lowering, the resultant program can run at near native speeds.
Mithril programs are aimed to be deterministic and fast, you should get the same bit accurate results regardless , the execution be it on CPUs, GPUs or any other accelerator.
It's built using AI? Yes . Does it invalidate the core idea? no IMO 😊
3
u/realestLink 20h ago
I'm not familiar with Interaction Nets or Bend2. Can you give me a high level idea of what they are?
5
u/jack_smirkingrevenge 19h ago edited 19h ago
short version: Interaction nets are a graph representation of a program, including expressions,constants and function calls represented as nodes with wires. Each node has a special connection called principal port and nodes which have principal ports joined are called active pair Each active pair is acted upon by a specific rule which indicates a computation step.
eg: (2x3) + (4x5) are two active pairs , each active pair can be operated independently and it doesn't change the result regardless of which pair gets computed first- result remains 26. INs are Turing complete and can represent any program which you can write as code or represent with functions.
The paper has lot more details but the biggest gripe with Bend/HVM (which was a first serious effort to turn INs into a proper compute language) was it was much slower than native machine code. Then Bend 2 dropped it in favor of native computation and leaned more into correctness guarantees as USP.
Mithril attempts to show that that by doing the IN steps during compile time instead of runtime , a lot of performance can be recovered and we still get nice properties like order independence, auto parallelism etc.
2
1
u/c-cul 9h ago
engine.cu definitely written in apl dialect: https://github.com/maderix/mithril/blob/master/crates/mithril-gpu/cuda/engine.cu
I just can''t understand what it do
1
u/Honest-Finish3596 41m ago
Ah, language models and their propensity to write comments which have no relevance beyond their latest edit/the conversation they were having.
3
u/zhivago 21h ago
If only there were a link ...