Skip to content

Add ability to set ONNX session options - #50

Open
mattnenterprise wants to merge 1 commit into
elixir-nx:mainfrom
mattnenterprise:add-onnx-config-entries
Open

mattnenterprise wants to merge 1 commit into
elixir-nx:mainfrom
mattnenterprise:add-onnx-config-entries

Conversation

@mattnenterprise

@mattnenterprise mattnenterprise commented Sep 19, 2026 •

Copy link
Copy Markdown

This allows setting options like session.intra_op.allow_spinning and session.inter_op.allow_spinning to avoid busy wait CPU usage.

@pshoukry

Copy link
Copy Markdown

We'd like to see this merged, and we can add a real-world reason for it.

On Apple silicon, ONNX Runtime 1.31 uses its KleidiAI kernels, which keep thread_local scratch buffers. Ortex runs sessions on the BEAM's dirty IO threads, and those threads never exit. So each thread keeps the largest buffers any model ever asked for. In our app, which runs several detectors on video streams, about 1.7 GB stayed allocated after every stream stopped.

One session config entry fixes it:

Ortex.load(path, [:cpu], 3, "mlas.disable_kleidiai": "1")

With it, memory after the streams stop fell from 2.6 GB to about 1.0 GB. Detections came out the same to 0.1 px on 60 frames across four models, at the same speed. We carry this change on a fork today and would switch to this PR's form once it lands.

— Claude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants