[workspace]
resolver = "2"
members = [
    "crates/oxibonsai",
    "crates/oxibonsai-core",
    "crates/oxibonsai-image",
    "crates/oxibonsai-kernels",
    "crates/oxibonsai-model",
    "crates/oxibonsai-runtime",
    "crates/oxibonsai-rag",
    "crates/oxibonsai-tokenizer",
    "crates/oxibonsai-eval",
    "crates/oxibonsai-serve",
]

[workspace.package]
version = "0.2.2"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/cool-japan/oxibonsai"
authors = ["COOLJAPAN OU (Team KitaSan)"]
rust-version = "1.86"
homepage = "https://github.com/cool-japan/oxibonsai"
readme = "README.md"
keywords = ["llm", "inference", "gguf", "bonsai", "1-bit"]
categories = ["science", "algorithms", "command-line-utilities"]

[workspace.dependencies]
# ── Internal crates ──
oxibonsai-core = { path = "crates/oxibonsai-core", version = "0.2.2" }
oxibonsai-image = { path = "crates/oxibonsai-image", version = "0.2.2" }
oxibonsai-kernels = { path = "crates/oxibonsai-kernels", version = "0.2.2" }
oxibonsai-model = { path = "crates/oxibonsai-model", version = "0.2.2" }
oxibonsai-runtime = { path = "crates/oxibonsai-runtime", version = "0.2.2", default-features = false }
oxibonsai-tokenizer = { path = "crates/oxibonsai-tokenizer", version = "0.2.2" }
oxibonsai-serve = { path = "crates/oxibonsai-serve", version = "0.2.2" }
oxibonsai-rag = { path = "crates/oxibonsai-rag", version = "0.2.2" }
oxibonsai-eval = { path = "crates/oxibonsai-eval", version = "0.2.2" }
oxibonsai = { path = "crates/oxibonsai", version = "0.2.2" }

# ── COOLJAPAN Ecosystem (Pure Rust Policy) ──
scirs2-core = { version = "0.5.0", default-features = false }
scirs2-linalg = { version = "0.5.0", default-features = false }
scirs2-neural = { version = "0.5.0", default-features = false }
oxifft = "0.3.2"
oxiarc-deflate = "0.3.3"

# ── GPU backends ──
metal = "0.33.0"
cudarc = { version = "0.19", features = ["nvrtc", "cuda-version-from-build-system", "fallback-latest"] }
objc = "0.2"

# ── Error handling ──
thiserror = "2.0.18"
anyhow = "1.0.102"

# ── Observability ──
tracing = "0.1.44"
tracing-subscriber = { version = "0.3.23", features = ["env-filter", "json"] }

# ── Serialization ──
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.150"
toml = "1.1.2"

# ── Async runtime ──
tokio = { version = "1.52.3", features = ["full"] }
tokio-stream = "0.1.18"

# ── HTTP server ──
axum = "0.8.9"
tower = "0.5.3"
tower-http = { version = "0.6.11", features = ["cors", "trace"] }
http-body-util = "0.1.3"

# ── CLI ──
clap = { version = "4.6.1", features = ["derive"] }
dotenvy = "0.15.7"

# ── Binary / memory / numerics ──
memmap2 = "0.9.10"
byteorder = "1.5.0"
half = { version = "2.7.1", features = ["serde"] }
libc = "0.2.186"
mach2 = "0.6.0"
crc32fast = "1.5.0"

# ── Parallelism ──
rayon = "1.12.0"

# ── Tokenizer ──
tokenizers = { version = "0.23.1", default-features = false, features = ["fancy-regex"] }

# ── Model conversion ──
safetensors = "0.7.0"
oxionnx-proto = "0.1.4"

# ── HTTP client ──
reqwest = { version = "0.13", features = ["json", "blocking"] }
ctrlc = { version = "3.5.2", features = ["termination"] }

# ── Benchmarking (dev) ──
criterion = { version = "0.8.2", features = ["html_reports"] }

# ── Testing (dev) ──
proptest = "1.11.0"
tempfile = "3.27.0"

[package]
name = "oxibonsai-cli"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
authors.workspace = true
rust-version.workspace = true
description = "Pure Rust 1-bit LLM inference engine for PrismML Bonsai models — CLI"

[[bin]]
name = "oxibonsai"
path = "src/main.rs"

[features]
default = ["server"]
server = ["oxibonsai-runtime/server"]
rag = ["oxibonsai-rag"]
simd-avx2 = ["oxibonsai-kernels/simd-avx2"]
simd-avx512 = ["oxibonsai-kernels/simd-avx512"]
simd-neon = ["oxibonsai-kernels/simd-neon"]
native-tokenizer = ["dep:oxibonsai-tokenizer"]
eval = ["dep:oxibonsai-eval"]
cuda = ["oxibonsai-kernels/cuda"]
native-cuda = ["gpu", "oxibonsai-kernels/native-cuda", "oxibonsai-model/native-cuda", "oxibonsai-runtime/native-cuda", "oxibonsai-image/native-cuda"]
metal = ["gpu", "oxibonsai-kernels/metal", "oxibonsai-model/metal", "oxibonsai-runtime/metal", "oxibonsai-image/metal"]
gpu = ["oxibonsai-kernels/gpu"]
wasm = [
    "oxibonsai-core/wasm",
    "oxibonsai-kernels/wasm",
    "oxibonsai-model/wasm",
    "oxibonsai-runtime/wasm",
]

[dependencies]
oxibonsai-core.workspace = true
oxibonsai-rag = { workspace = true, optional = true }
oxibonsai-eval = { workspace = true, optional = true }
oxibonsai-tokenizer = { workspace = true, optional = true }
oxibonsai-kernels.workspace = true
oxibonsai-model.workspace = true
oxibonsai-image.workspace = true
oxibonsai-runtime = { workspace = true, default-features = false }
tracing.workspace = true
anyhow.workspace = true
serde.workspace = true
serde_json.workspace = true
toml.workspace = true

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
memmap2.workspace = true
axum.workspace = true
clap.workspace = true
dotenvy.workspace = true
tracing-subscriber.workspace = true
reqwest = { workspace = true, features = ["blocking"] }
ctrlc.workspace = true
tokio.workspace = true

[dev-dependencies]
criterion.workspace = true
half.workspace = true
oxibonsai-core.workspace = true
oxibonsai-kernels.workspace = true
oxibonsai-model.workspace = true
oxibonsai-runtime.workspace = true
reqwest.workspace = true
axum.workspace = true
tower.workspace = true
tokio.workspace = true
serde_json.workspace = true
tempfile.workspace = true
bytes = "1.11.1"
http-body-util.workspace = true

[[example]]
name = "basic_inference"
path = "examples/basic_inference.rs"

[[example]]
name = "streaming"
path = "examples/streaming.rs"

[[example]]
name = "custom_sampling"
path = "examples/custom_sampling.rs"

[[example]]
name = "model_info"
path = "examples/model_info.rs"

[[example]]
name = "metrics_demo"
path = "examples/metrics_demo.rs"

[[example]]
name = "server_client"
path = "examples/server_client.rs"

[[example]]
name = "runtime_controllers"
path = "examples/runtime_controllers.rs"

[[bench]]
name = "kernel_benchmarks"
harness = false

[[bench]]
name = "inference_throughput"
harness = false

[[bench]]
name = "memory_benchmarks"
harness = false

[[bench]]
name = "controllers_bench"
harness = false

[profile.release]
lto = true
codegen-units = 1
opt-level = 3

# Test/dev runtime performance. This workspace's tests run real numeric work
# (parity golden references, model forward passes). At the default dev/test
# opt-level=0 those are unoptimized + non-autovectorized, so some tests take
# *minutes* (e.g. the DiT-shape joint-attention CPU reference ~14.5 GFLOP, and
# the speculative decoder's ~240 forward passes over the 151936-row vocab).
# Float results are unchanged: Rust does not enable fast-math, so opt-level does
# not reassociate reductions — parity gates (cos>=0.999) stay bit-stable.
[profile.test]
opt-level = 2

# Dependencies (incl. workspace path-deps like oxibonsai-model/-kernels when
# built as deps of another crate's tests) compile under the `dev` profile during
# `cargo test`/`nextest`. Optimize them so the model forward in the runtime tests
# isn't the bottleneck. The crate you're actively editing stays at dev
# opt-level=0, so incremental compiles of your own code remain fast.
[profile.dev.package."*"]
opt-level = 3
