Life of an artifact
Your training code
khaos.modeling.build(“<artifact>”), then train however you like↓
export_artifact
manifest.json and model.onnx↓
Hugging Face Hub, or a local directory
<org>/<artifact>↓
khaos.load() or khaos serve
adapter, then ONNX Runtime, then a result container
- Build.
khaos.modeling.build("<artifact>")gives the architecture for an artifact, defined inkhaos/<domain>/models/. - Train. Your own loop, in your own environment. Khaos does not train.
- Export.
export_artifactwritesmanifest.jsonandmodel.onnx. - Publish. Push the directory to the Hugging Face Hub, or keep it local.
- Run.
khaos.load()andkhaos serveread the manifest, find the registered pipeline for that artifact, and run it on ONNX Runtime.
Design
- Code and weights are separate. This repository holds the runtime and the architectures. Weights are published to the Hugging Face Hub and cached locally.
- ONNX is the contract. Whatever you train with, the runtime only sees an ONNX file and a manifest. The architectures are written to export cleanly with dynamic batch and length, and the tests check that ONNX Runtime matches PyTorch.
- One subpackage per domain. Each holds its adapter, containers and architectures, so optional dependencies stay isolated behind extras.
- Domain-owned containers. Each domain defines its own result types. There is deliberately no shared base class: a filing, a field grid and a trajectory have nothing meaningful in common.
- Registry-driven loading.
@register("artifact_name")binds a pipeline class to a name;load()imports only the domain it needs. - Light runtime, heavy training. Serving needs ONNX Runtime and FastAPI.
PyTorch and transformers live behind the
trainextra. - Local-first. Inference runs on the user’s machine through ONNX Runtime.
Adding a pipeline
A pipeline connects an exported model to the rest of the runtime. SubclassOnnxPipeline, turn raw input into named arrays, and build the domain’s container
from the outputs:
khaos.load("pde_darcy_flow_2d"),
khaos serve pde_darcy_flow_2d, and khaos download pde_darcy_flow_2d.