Skip to content

EvoX Compiler documentation

A minimal, explicit, compiler-neutral tensor graph compiler and runtime for Python.

evoxc (EvoX Compiler) is a Python tensor graph compiler and runtime: it builds computational graphs, transforms them, and hands them to a backend — an interpreter, or a compiler that generates code. The graph is the program — there is no eager mode, no implicit tracing, and no hidden compilation.

It is for people who write numerical programs — optimisation loops, batched simulations, model forwards — and want to see, save, transform and reuse the graph instead of treating a framework call as opaque. A NumPy interpreter runs graphs on a CPU with no compiler toolchain installed; IREE, XLA via PJRT and TVM are optional backends that receive StableHLO.

The four defining properties

Simple

Convenience APIs are compositions, not a second semantics: vmap is sugar over vectorize, bind only passes arguments, and build runs trace → lower → compile → load in one call. When you need a stage on its own, you call the same function the shorthand calls.

Minimal

numpy is the only hard runtime dependency. The package is a Python frontend, a NumPy interpreter, and a Rust extension for the graph transforms and the optional CPU engine; a prebuilt wheel runs graphs without a compiler toolchain. Optimisation, scheduling, memory planning and code generation belong to external compilers, never to evoxc.

Explicit

Every stage of the pipeline is a public function with a distinct result object, and you can inspect, save or reuse the object at any point. Communication between devices is an explicit collective in the graph; moving data between host and device is the explicit Tensor.to(device); a large tensor enters a graph as an input or through the warned evoxc.constant, never by silent capture.

Compiler-neutral

EvoXIR represents the program. StableHLO connects it to IREE, XLA and TVM, and StableHLO is an export target rather than the definition of the IR. A backend that cannot express something fails loudly, and the NumPy interpreter stays the reference behaviour.

The explicit pipeline

defn → trace → Graph → transform → Graph → lower → LoweredProgram → compile → CompiledArtifact → load → Executable → run → Tensor
  • defn — @evoxc.defn marks a Python function as a graph definition. Calling it with concrete tensors is an error: it describes a computation, it does not execute one.
  • trace — evoxc.trace(fn, *specs) runs the definition against TensorSpec inputs and returns a Graph, EvoXIR’s region-based SSA module plus the input/output trees.
  • transform — evoxc.vectorize, vmap, batch_functions, grad, jvp and vjp take a Graph and return an ordinary Graph of ordinary ops. evoxc.split_by_inputs slices one graph into a prepare/apply pair at its (fixed vs per-call) input boundary — a SplitPlan holding two ordinary graphs — and evoxc.analyze_inputs reports the per-input facts behind that choice.
  • lower — evoxc.lower(graph, backend=…) returns a LoweredProgram: StableHLO MLIR text, or the backend’s own payload.
  • compile — evoxc.compile(lowered, **options) returns a CompiledArtifact — the compiler’s own artifact (a vmfb, a PJRT executable, serialized IR).
  • load — evoxc.load(artifact, device=…) returns an Executable bound to a device.
  • run — evoxc.run(exe, *args) executes it and returns a Tensor, or a tree of tensors matching the outputs you traced.

Nothing happens implicitly between those calls: no stage consumes an earlier-stage object and performs the missing steps, and each object’s summary() or text() shows what it holds.

Quickstart — sixty seconds

import evoxc
from evoxc import TensorSpec

@evoxc.defn
def f(x, w):
    return evoxc.sum(evoxc.tanh(evoxc.dot(x, w)), axes=1)

spec_x, spec_w = TensorSpec((4, 8), evoxc.float32), TensorSpec((8, 4), evoxc.float32)
graph    = evoxc.trace(f, spec_x, spec_w)                       # Graph          (EvoXIR)
lowered  = evoxc.lower(graph)                                   # LoweredProgram
artifact = evoxc.compile(lowered)                               # CompiledArtifact
exe      = evoxc.load(artifact, device="cpu")                   # Executable
y        = evoxc.run(exe, evoxc.ones((4, 8)), evoxc.ones((8, 4)))   # Tensor
print(y.shape, y.dtype)      # (4,) float32
print(graph)                 # <Graph 4 ops, 1 function, 2 tensor inputs, 0 static values, 1 output>

The same graph runs on another backend by changing one argument — backend="native" uses the in-process Rust CPU engine, and the optional compiler adapters take backend="iree", "xla" or "tvm":

exe = evoxc.build(f, spec_x, spec_w, backend="native", device="cpu")  # trace → lower → compile → load
y   = evoxc.run(exe, evoxc.ones((4, 8)), evoxc.ones((8, 4)))

build and evaluate are documented shorthand for the same stages (evaluate derives the specs from concrete tensors, then builds and runs), never a separate execution mode. Install evoxc with pip install evoxc — NumPy only, with the compiled extension in the wheel — and add a compiler extra when you want one.

The explicit evoxc stack: defn → Graph (EvoXIR) → transforms → lower → LoweredProgram → compile (NumPy interpreter or IREE / XLA-PJRT / TVM) → CompiledArtifact → load → Executable → run → Tensor

What evoxc leaves to other tools

evoxc owns the frontend and the staging contract; it deliberately does not own optimisation, kernel scheduling, memory planning or code generation — those belong to the compilers it hands StableHLO to. It also contains no neural-network modules, layers, optimizers, datasets, training loops or model zoo, no automatic global sharding or implicit collectives, no CUDA allocator or kernel scheduler, and no serving or checkpoint manager. Those are separate libraries built on top of evoxc, such as the evoxc-hf distribution for HuggingFace checkpoints.

Where to go next

Type to search…

↑↓ navigate↵ selectEsc close