caleb-bb

caleb-bb

I just wanted to gauge people’s interest.

So, I’ve got this tool in the works. It’s supposed to take a model implementation in PyTorch and spit out an Axon implementation. I haven’t written the Axon emitter yet, though. Once I do, it won’t just let you run the model. It will translate the model into Elixir.

See, models on Arxiv come with a PyTorch reference implementation. This is why people usually use PyTorch for research; you can basically import arxiv_paper. Elixir has nothing like that. We’re way behind because the best we can do is have someone hand-implement a model in Axon. You have to translate, by hand, from the PyTorch implementations we find on Arxiv. Bumblebee is basically a body of that work.

So I’m trying to automate it and make it so you can fire up this Elixir library in your CLI and basically do import arxiv_paper, and get it back in Axon. This is different from ONNX importing. ONNX just lets you run a model. This actually translates the PyTorch model to Elixir so you can tweak it, do LoRA, etc. The old axon_onnx library is stale, though, and the ONNX hop adds another step where things can break.

Today it captures a PyTorch model via FX or torch.export, round-trips it through a JSON graph into Elixir where you can validate it, infer shapes, expand it to primitives and collapse it back, and compiles it back out to PyTorch .

The first step is an Axon emitter that works for common architectures (CNNs, MLPs) on Arxiv.

My question is: if I can get this working to that benchmark, would anyone want to use it? Elixir, generally speaking, is not a research language for ML (more for deployment and orchestration) but as long as Axon exists, we might as well have something like this.

How it happened
My original idea was a graph-theoretic notation to enable transpilation of ML models between languages. You compile your PyTorch implementation (or whatever language) into my notation. Then that notation can be compiled into any other language. A model transpiler, in other words.

# Primitive Set — ML Architecture Notation Version 0.4 — Draft --- # - Pastebin.com ← my original notation.

My friend at Brainfuel has this thing called LawSpec. I showed him my notation and he used his LawSpec thing to make it an actual Elixir application. I forked it:

I have yet to write the back-end Axon emitter to enable transpilation. But like I said, it shouldn’t take that long to get common model architectures working.

Questions:

  1. Would you use it?
  2. What would it take for you to trust this over a hand port?

Showing Posts 1 to 6

gtcode

gtcode

I looked into this when you first posted, but didn’t find the time to put together a detailed reply. I had a number of thoughts, some of which were getting ahead of where the project currently stands.

This is an ambitious project. I’m curious to see how the approach holds up in practice, given how much variation there is between potential models to port.

caleb-bb

caleb-bb OP

Fair cop. The answer: the approach holds up as well as my ability to generalize over models. I suspect that very common architectures will not be terribly hard to implement. The only other major bottleneck would be something so clever in a model that it doesn’t map well to Axon, but that’s an upstream problem.

The nice thing about the LawSpec stuff is that it generalizes. Once the LawSpec laws are in place, it makes it much easier to replicate this project in other languages, e.g. Rust, which would probably be next.

gtcode

gtcode

Yes. I ported a custom Qwen 0.6B SLM to Elixir, which was a decent challenge. Parameter orientation was a gotcha. Valid Axon code wasn’t an assurance of correct results. I wasn’t able to get byte-identical outputs from PyTorch → EXLA, and instead settled on a suitable tolerance. Might be a valuable eval for your platform.

caleb-bb

caleb-bb OP

Correct. Right now my goal is just structural correctness. But within-tolerance on actual results would be a clear next step.

Just curious: what tolerances did you settle on, and how did you verify it? I would have used a property test, but what did you do?

Also, did you just check overall output or were you checking intermediate layers as well?

gtcode

gtcode

I just did deterministic reference comparison rather than a property test. I dumped results from Python and compared using the same inputs run through Elixir. Numerical gates were cosine similarity >= 0.99, both for the extracted penultimate hidden vector, and the final router logits (this was for a custom router that used those), and relative L2 error <= 0.12 for hidden and <= 0.10 for logits. CS was ~0.9945 for hidden and ~0.9974 for logits. Thresholds were tailored to the given router comparison, nothing universal.

Yes, intermediate checks that did survive as scripts and tests. Detailed checkpoints were in the weight reconstruction pipeline, and the hidden vector before the router head. I wasn’t able to find a permanent comparison of activations at every transformer layer.

E2E check used a fixed transcript and required matching token ID’s, router head weight hash and selected agent/role, in addition to the vector/logit checks. The final checks were Python/Elixir output comparisons, along with a prompt eval suite that I expanded for coverage before calling it close enough for jazz.

caleb-bb

caleb-bb OP

Thank you! Very useful.

Watch this space. Results soon.

— All posts loaded —

Where Next? Top

Trending in AI / LLMs Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
AstonJ
With advancements in AI gathering pace and set to increasingly accelerate, perhaps it’s worth having an annual thread on the topic - feel...
New
dmitriid
What A larger rant at in this post. Code at github: GitHub - dmitriid/llamex: Credo Plugin that detects issues that LLM-assisted Elixir r...
New
brightball
Posting this more for general discussion, but does anybody have a need for a stock CMS anymore? I’ve built 3 different sites using Elixi...
New
caleb-bb
I just wanted to gauge people’s interest. So, I’ve got this tool in the works. It’s supposed to take a model implementation in PyTorch a...
New
santosh79
I’ve been working on Current for a few month and recently open-sourced it. The central idea is that AI agents should propose actions rat...
New

Other Trending Topics Top

raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
gtcode
Aloha gang, There’s a new class of AI model out from TypeSafe. Jev is their flagship model. You can learn about it here: ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews