Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 2 additions & 0 deletions .codex/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Project commands and conventions are in AGENTS.md.
# Hooks call the shared checker once it is introduced; user permissions stay local.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[*.{py,rs}]
indent_size = 4

[Makefile]
indent_style = tab
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto eol=lf
*.onnx binary
*.pb binary
*.png binary
*.jpg binary
64 changes: 27 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,39 @@
name: Test
name: Baseline validation
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
concurrency:
group: baseline-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
linux:
runs-on: ubuntu-latest
name: Linux ${{ matrix.elixir }}, ${{ matrix.otp }}
baseline:
strategy:
fail-fast: false
matrix:
elixir: ["1.17.3"]
otp: ["27.1.2"]
os: [ubuntu-24.04, macos-15]
runs-on: ${{ matrix.os }}
timeout-minutes: 25
env:
MIX_ENV: test
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Install dependencies
run: mix deps.get
- name: Compile and check warnings
run: mix compile --warnings-as-errors
- name: Check formatting
run: mix format --check-formatted
- name: Run tests
run: mix test

macos:
runs-on: macos-latest
name: macOS
env:
MIX_ENV: test
steps:
- uses: actions/checkout@v2
- name: Install
persist-credentials: false
- uses: erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124 # v1.24.1
with:
elixir-version: '1.20.4'
otp-version: '29.1.1'
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: '3.14.10'
- name: Supply the separately installed runtime
run: |
brew update
brew install erlang@27 elixir
- name: Install dependencies
run: mix deps.get
- name: Compile and check warnings
run: mix compile --warnings-as-errors
- name: Check formatting
run: mix format --check-formatted
- name: Run tests
run: mix test
runtime_path=$(python scripts/install_runtime.py install)
echo "ORT_DYLIB_PATH=$runtime_path" >> "$GITHUB_ENV"
- run: mix deps.get --check-locked
- run: mix compile --warnings-as-errors
- run: mix format --check-formatted
- run: mix test
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,15 @@ ortex-*.tar

# Temporary files, for example, from tests.
/tmp/

/runtime/
/.venv/
/dist/
/bench/results/
**/__pycache__/
/.ruff_cache/
/.cache/
/priv/native/
/examples/_build/
/examples/deps/
/examples/priv/
18 changes: 18 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Working on Ortex

Read docs/development.md for setup and supported environments. Use `make help`
for the commands implemented by this branch. Run the relevant checks before
committing; use atomic conventional commits. Keep runtime/API changes separate
from development infrastructure.

The native crate lives in native/ortex. Run Cargo from that directory so its
.cargo/config.toml applies. Changes crossing the BEAM/native boundary need tests
through the public Elixir API. Process-wide runtime configuration requires a
fresh VM. Keep inference workloads and scheduler measurements under bench/.

Fixtures and examples must use public or synthetic inputs, with recorded source,
license, and reference results. Never download models implicitly during tests.

Use the RiverFinancial fork. Do not publish packages or releases unless the
user explicitly requests publication. Do not rewrite other branches as part of
foundation work.
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.DEFAULT_GOAL := help
PYTHON ?= python3
export MIX_ENV := test
export ORT_DYLIB_PATH ?= $(shell $(PYTHON) scripts/install_runtime.py path 2>/dev/null)

.PHONY: help setup deps doctor test docs

help: ## Show development commands
@awk 'BEGIN {FS = ":.*## "} /^[a-zA-Z0-9_.-]+:.*## / {printf " %-22s %s\n", $$1, $$2}' $(MAKEFILE_LIST)

setup: ## Fetch Mix dependencies and the development runtime
mix local.hex --force
mix local.rebar --force
$(MAKE) deps
$(PYTHON) scripts/install_runtime.py install

deps: ## Fetch the locked test and documentation dependencies
mix deps.get --check-locked
MIX_ENV=docs mix deps.get --check-locked

doctor: ## Describe tools, architecture, and runtime selection
$(PYTHON) scripts/doctor.py

test: ## Run library tests and doctests
mix test

docs: ## Build documentation with warnings treated as errors
MIX_ENV=docs mix docs --warnings-as-errors
13 changes: 3 additions & 10 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ config :elixir, :dbg_callback, {Macro, :dbg, []}
config :ortex,
add_backend_on_inspect: config_env() != :test

# Set the cargo feature flags required to use the matching execution provider
# based on the OS we're running on
ortex_features =
case :os.type() do
{:win32, _} -> ["directml"]
{:unix, :darwin} -> ["coreml"]
{:unix, _} -> ["cuda", "tensorrt"]
end

config :ortex, Ortex.Native, features: ortex_features
# Do not infer accelerator support from the operating system. Runtime selection
# stays explicit through ORT_DYLIB_PATH; compilation needs no runtime headers.
config :ortex, Ortex.Native, features: ["ort/load-dynamic"]
25 changes: 25 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Development

Use `mise install`, then `mise exec -- make setup` and `mise exec -- make doctor`.
Rustup reads the pinned rust-toolchain.toml. GNU Make 3.81 or newer is sufficient;
Windows developers can use Git Bash with Make available on PATH.

The supported BEAM pairs are Elixir 1.19 / OTP 28 and Elixir 1.20 / OTP 29.
Normal development uses the latter. Rust 1.92 is the minimum; the normal pinned
toolchain is 1.93.1. Python 3.12+ runs the standard-library tooling.

ONNX Runtime is a separate dependency. `make setup` installs the development
runtime under runtime/ and records its path. Make passes that path through
ORT_DYLIB_PATH; an explicitly set environment variable takes precedence. Direct
Mix commands need that variable too. ONNX Runtime 1.23.2 is used on Intel macOS
because 1.24.4 has no official Intel macOS archive. Successful process exit is
part of testing; runtime 1.22.0 has exhibited shutdown failures on macOS.

The foundation retains main's ort rc.8 and Rustler 0.29 native implementation.
Rustler migration belongs to the separate feature work. CPU dynamic loading is
the development default; additional Cargo features must be explicitly selected
in the consuming application's config. Library tests remain under test/ with
normal ExUnit discovery. Additional suites are introduced by later stack PRs.

Documentation has its own Mix environment so building docs does not install
EXLA, Torchx, or example tokenizers. Large examples own their extra dependencies.
11 changes: 11 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Examples

Examples have an independent Mix project: from this directory, run `mix deps.get`
and `mix run distilbert/distilbert_classification.exs` (or another example).
Set ORT_DYLIB_PATH to the separately installed runtime. Model paths are relative
to this directory. The Python export dependencies are separate from the library.

The inherited DistilBERT and StableLM exports remain manual demonstrations. Their
model revisions and export environments have not yet been made reproducible;
they are not validation gates. The foundation test PR adds small prepared models
with recorded provenance and expected outputs.
3 changes: 3 additions & 0 deletions examples/config/config.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Config

config :ortex, Ortex.Native, features: ["ort/load-dynamic"]
16 changes: 16 additions & 0 deletions examples/mix.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
defmodule Ortex.Examples.MixProject do
use Mix.Project

def project do
[
app: :ortex_examples,
version: "0.1.0",
elixir: "~> 1.19",
deps: [
{:ortex, path: ".."},
{:tokenizers, "~> 0.4"},
{:jason, "~> 1.4"}
]
]
end
end
9 changes: 9 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[tools]
erlang = "29.1.1"
elixir = "1.20.4-otp-29"
python = "3.14.10"
actionlint = "1.7.12"
shellcheck = "0.11.0"
shfmt = "3.14.1"

# Rust is pinned by rust-toolchain.toml. Checkers are isolated from model exporters.
19 changes: 10 additions & 9 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ defmodule Ortex.MixProject do
[
app: :ortex,
version: "0.1.10",
elixir: "~> 1.14",
elixir: "~> 1.19",
start_permanent: Mix.env() == :prod,
deps: deps(),

# Docs
name: "Ortex",
source_url: "https://github.com/elixir-nx/ortex",
homepage_url: "http://github.com/elixir-nx/ortex",
source_url: "https://github.com/RiverFinancial/ortex",
homepage_url: "https://github.com/RiverFinancial/ortex",
docs: [
main: "readme",
extras: ["README.md"]
Expand All @@ -21,6 +21,10 @@ defmodule Ortex.MixProject do
]
end

def cli do
[preferred_envs: [docs: :docs]]
end

# Run "mix help compile.app" to learn about applications.
def application do
[
Expand All @@ -31,12 +35,9 @@ defmodule Ortex.MixProject do
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:rustler, "~> 0.27"},
{:rustler, "~> 0.29.1"},
{:nx, "~> 0.6"},
{:tokenizers, "~> 0.4", only: :dev},
{:ex_doc, "0.29.4", only: :dev, runtime: false},
{:exla, "~> 0.6", only: :dev},
{:torchx, "~> 0.6", only: :dev}
{:ex_doc, "~> 0.40.4", only: :docs, runtime: false}
]
end

Expand All @@ -45,7 +46,7 @@ defmodule Ortex.MixProject do
files: ~w(lib .formatter.exs mix.exs README* LICENSE* native/ortex/src/ config/config.exs
native/ortex/Cargo.lock native/ortex/Cargo.toml native/ortex/.cargo/config.toml),
licenses: ["MIT"],
links: %{"GitHub" => "https://github.com/elixir-nx/ortex"},
links: %{"GitHub" => "https://github.com/RiverFinancial/ortex"},
description: "ONNX Runtime bindings for Elixir"
]
end
Expand Down
Loading
Loading