A model in the open ONNX format, run by Bentrix itself with no Python — its folder and manifest, the built-in engine, the faster ONNX Runtime engine on your processor or graphics card, and how Bentrix keeps a library from being a way in.
01The folder
A model is a folder in your models folder holding two files: model.onnx, exported from PyTorch, TensorFlow, scikit-learn or any tool that writes ONNX, and manifest.json, which says how the window becomes the model's input and how its output becomes a forecast:
{
"schema_version": 1,
"name": "plus",
"interval": "M1",
"frames": ["M1"],
"lookback": 32,
"steps": 4,
"input": { "fields": ["close"], "transform": "returns" },
"output": { "kind": "delta", "pick": "first" }
}
- input — the fields read from each frame's bars (
open,high,low,close,tick_volume), in order, and one fixed transform:raw(as they are),returns(each bar's change on the one before) orzscore(centred on the window's mean, in its standard deviations). The input tensor is[1, n]of 32-bit floats,n= fields × lookback × frames × markets. - output — how the output becomes the steps' closes:
kindclose(the values are closes),delta(changes from the last close) orreturn(fractional returns on it);pickfirstorlasttakes that many values from the start or the end of the output.
model_check reads the folder and says, before anything runs, whether the file's tensors match the manifest. The manifest names no library, no path and no operator to load — a model file is never a way to make Bentrix load code.
In Python, export_manifest(name, interval, steps, frames=…, fields=…, transform=…, output=…) writes the manifest, refusing a transform Bentrix does not apply; train on the windows extract_windows writes with the same fields and transform, so the model sees at serving exactly what it saw training.
02Which operators run where
Press Check on a model in Settings › Forecast › Models (or call model_check / model_info). Bentrix reads the file's own operator list — without running anything — and says:
- it runs on both engines — every operator it uses is one the built-in engine runs;
- an operator the built-in engine does not run — named, with its opset, and three offers: Get the accelerated engine, Export with an older opset without it, Run it as a Python model Bentrix runs for you;
- a custom operator domain — needs an operator library for the domain …, which Bentrix does not load — with two offers: Export the model without it, Run it as a Python model. Such a file is refused before any engine is asked to load it.
The page also says how many operators the built-in engine runs; the accelerated engine runs ONNX's standard set.
03The two engines
| Built-in | Accelerated | |
|---|---|---|
| What it is | tract, written in Rust, inside Bentrix | Microsoft's ONNX Runtime, 1.31.0 |
| Needs | nothing | one download, or your own GPU maker's libraries |
| Runs on | the processor | the processor, an NVIDIA graphics card (CUDA), or Core ML on a Mac |
| Where it runs | a process of its own, or inside Bentrix if you choose | always a process of its own |
Choose under Settings › Forecast › Engine. Both answer the same for the same model — measured on Bentrix's own fixture model, to the last bit.
04Getting the accelerated engine
On the processor. Press Get the accelerated engine (CPU, N MB). Bentrix downloads ONNX Runtime's own release from Microsoft's GitHub page, through the driver on this computer, checks its size and fingerprint against the ones it carries, takes out the library, checks that too, and only then keeps it. A download that does not match is thrown away whole. Remove deletes it.
On an NVIDIA graphics card. Two parts:
- Get the GPU provider (NVIDIA CUDA, N MB) — ONNX Runtime's GPU build, fetched and checked as above.
- NVIDIA's own CUDA and cuDNN libraries. Bentrix does not download NVIDIA's libraries: they are NVIDIA's, under NVIDIA's licence. Install them from NVIDIA, then press Find them on this computer. Bentrix looks in NVIDIA's standard folders, lists each file it found with its fingerprint, and you press Use these files to tick them.
If a file is missing, the page says which, and offers to Check again after you install it, to Use the accelerated engine (CPU) instead, or to Choose the folder (Advanced).
Advanced: Library folder takes the full path of an ONNX Runtime library of your own; Use this library ticks that exact file.
05A library is code
A library is a program, so Bentrix holds three rules:
- Only you set the engine. No tool, agent or program can choose an engine, name a library or press a download — an assistant can read which engine a model runs on, never where its library is.
- Only a checked file loads. A downloaded library loads only while its fingerprint is the one Bentrix carries; a library you ticked loads only while it is still the exact file you ticked. A changed file unticks itself. The check is made again just before the library loads, inside the process that loads it.
- Never a library the model names. A model that needs an operator library of its own is refused with the reason; nothing beside the file is ever loaded.
The accelerated engine always runs in a process of its own — in the window, under bentrix --serve, and when Bentrix hosts the driver — so a crash inside ONNX Runtime or a GPU library ends that process and never Bentrix. Run the built-in engine inside Bentrix (off by default) moves only the built-in engine onto a thread of the window.
06A model an agent installs waits for you
An AI assistant or a program can put a model into your folder with model_install — an ONNX file with its manifest, or a Python file. It does not run until you say so: Settings › Forecast › Models lists it as installed by an agent, waiting for your tick, and Run it ticks those exact bytes. If the file is replaced afterwards, it waits for you again. A file you put in the folder yourself needs no tick. An agent can Forget a model it installed; your own files are yours to delete, and an install never overwrites one.
model_list and model_info answer what the folder holds — each model's kind, label, fingerprint, consent and the engine it would run on, never where an engine's library is.
07The host's limits
| Setting | What it does | Default |
|---|---|---|
| Memory cap | The most a model host may hold — 1, 2, 4 or 8 GB. A model past it fails inside its host; Bentrix goes on. It applies to ONNX models; a Python model runs under your own interpreter. | 2 GB |
| Threads | The accelerated engine's threads — Auto (this computer's cores, up to 8), 1, 2, 4 or 8. | Auto |
| Late is | An answer this long after its close is counted late — 1, 2, 5 or 10 s. | 2 s |
| Time cap per run | A model that has not answered in this long is ended — 5, 10, 30 or 60 s. | 5 s |
08What you will see
The legend row and Settings › Forecast say which engine a model runs on — built-in (tract) or accelerated (ONNX Runtime 1.31.0, NVIDIA CUDA). If the chosen engine cannot run — not downloaded, a ticked file changed — the model does not start, and the page says why and what to do.
On a Mac, the folder Bentrix keeps models and engines in is the Linux-style one for now; this is not yet measured on a Mac.