Your first search()
A torch.nn.Module and a sample input go in; a verified-lowered module and run stats come out. The e-graph in between explores every equivalent spelling of your model's graph.
The shortest path
from mlopt_orchestrator import Optimizer
from mlopt_torch import TorchBackend
opt_mod, stats = Optimizer(backend=TorchBackend()).optimize(model, x)optimize(model, x) runs the full pipeline — search (saturate + extract under a cost model) then lower (emit a module through the backend's sink, numerically verified against the source). It returns a LowerResult that unpacks as (module, stats); stats carries rule_fires, lowering, runner, and the strategy's own keys.
The two phase verbs
opt = Optimizer(backend=TorchBackend())
res = opt.search(model, x) # SearchResult — the extracted term
mod = opt.lower(res, x, verify=True) # LowerResult — verified moduleKeeping them separate means you can re-lower one search result under different runners without re-saturating.
Steer what "cheapest" means
from mlopt_orchestrator import LatencyCriterion, MemoryCriterion
opt_mod, stats = Optimizer(backend=TorchBackend()).optimize(
model, x,
criteria=LatencyCriterion() * 0.7 + MemoryCriterion("peak") * 0.3,
)
# or the shorthand: criteria={"latency": 1.0, "memory": 0.5}Choose how the result is delivered
from mlopt_cuda import CudaGraphRunner
from mlopt_torch import TorchCompileRunner
opt_mod, stats = opt.optimize(model, x, runner=TorchCompileRunner())
opt_mod, stats = opt.optimize(model, x, runner=CudaGraphRunner())Every delivered program ships a certificate — a replayable derivation (mlopt_core.egraph.verify_certificate replays it standalone). The certificate, not the timing, is the claim.
Next
→ Watch a law get minted — or read the full walkthrough in docs/api.md and the contract in the frozen API reference.