r/Compilers • • Oct 05 '26

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 😊

Mithril Paper Repo

7 Upvotes

12 comments sorted by

3

u/zhivago Oct 05 '26

If only there were a link ...

2

u/jack_smirkingrevenge Oct 05 '26

haha, didn't realise that links automatically don't carry into text body šŸ˜… added now.

1

u/zhivago Oct 05 '26

Your static background image fills me with an unreasonable degree of rage.

It makes reading and scrolling very annoying.

2

u/jack_smirkingrevenge Oct 05 '26

yeah the mobile UI seems to have some issues for the background and scrolling, fixed now. thanks

3

u/realestLink Oct 05 '26

I'm not familiar with Interaction Nets or Bend2. Can you give me a high level idea of what they are?

6

u/jack_smirkingrevenge Oct 05 '26 edited Oct 05 '26

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

u/realestLink Oct 05 '26

I see. Thanks for the explanation ā¤ļø

1

u/c-cul Oct 05 '26

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

2

u/Honest-Finish3596 Oct 06 '26

Ah, language models and their propensity to write comments which have no relevance beyond their latest edit/the conversation they were having.

1

u/smallMac-yay Oct 07 '26

What a wonderful project this is!

1

u/smallMac-yay Oct 07 '26

I’d like ANE backend