Engineering R&D

MLang: A Compiler for ML Inference

A lightweight, dependency-free ML language compiler in Rust that emits C and CUDA

~33 KB native binaries

GitHub

A small programming language for running neural networks, compiled straight to native code so a model can ship without Python or a framework.

The problem

Deploying even a tiny model usually drags in a full ML runtime, which is heavy for edge devices and hard to audit.

The approach

A Rust compiler with zero dependencies type-checks tensor shapes, lowers programs to a typed IR with constant folding, and emits C11 or CUDA C++ with fused kernels. Weights are embedded or read at run time, and an importer turns dense networks, including scikit-learn MLPs, into MLang source.

The outcome

Self-contained executables of about 33 KB. Experimental and not yet hardened for safety-critical use.

In detail

Designed and built MLang, an experimental programming language for machine-learning inference with a compiler written in Rust and no third-party crates. Tensor shapes are type-checked at compile time, programs are lowered to a typed intermediate representation with constant folding, and the compiler emits C11 for the CPU or CUDA C++ for the GPU, including fused matrix-multiplication kernels. The output is a self-contained executable of roughly 33 KB that needs no Python or ML framework at deployment. Weights can be embedded or loaded at run time, and a model importer converts dense networks, including trained scikit-learn MLPs, into MLang source.

Built with

More in Engineering R&D

Next project: Multi-Label ECG Preprocessing with SNOMED CT

By Kanishka Ranaweera, PhD, Machine Learning Engineer in Melbourne, Victoria, Australia. hello@kanishkabuilt.me