Every simulated result in OptiRS just got replaced — with a real implementation, or an honest error that says what it can’t do.
Today we released OptiRS 0.3.2 — a production-hardening release built around one organizing theme: honesty. Code that simulated a result — fabricated p-values, hardcoded success rates, thread::sleep standing in for device latency, secure-aggregation masks that were never actually cancelled — was either replaced with a real implementation or changed to return an explicit error naming what it cannot do. No path in this release reports a number it did not compute.
OptiRS is the Pure Rust ML Optimization Suite Powered by SciRS2. No Python. No PyTorch optimizers. No external crates outside the SciRS2/COOLJAPAN line — every array, RNG, numeric-trait, SIMD and parallelism operation goes through scirs2-core; no direct ndarray, rand, rayon, or wide. The result compiles to a single static binary (or WASM) and runs everywhere.
Why 0.3.2 matters
A codebase can compile, pass its tests, and still lie to you. 0.3.2 went looking for exactly that failure mode across the whole workspace, and found it repeatedly:
- Secure aggregation was numerically wrong, not just insecure. Masks were added to client updates and never removed — the “aggregate” was the mean of the updates plus a pile of random noise.
- A drift detector’s baseline absorbed the drift it existed to detect. Its EWMA variance estimator multiplied by roughly
α·k²on a single k-sigma observation — measured:1.0e-5→70in one observation — masking a real shift within about twenty samples. - GPU vendor backends (CUDA, ROCm, oneAPI, Metal) called
thread::sleepto imitate device latency while their copy functions moved zero bytes. - A benchmark harness could report infinite throughput because per-iteration timing quantized to zero on fast closures — a division by zero dressed up as a rate.
- 1,241 rustc and 1,360 clippy warnings were hidden behind blanket
#![allow(...)]attributes at the workspace level.
OptiRS 0.3.2 ends all of that:
- Real Bonawitz secure aggregation. Each client generates a per-round X25519 key pair; pairwise seeds come from a real ECDH shared secret hashed with SHA-256; masks expand through a SHA-256 counter-mode PRG with rejection sampling; every unordered client pair contributes
+monce and−monce so the server’s sum telescopes exactly. The server holds no key material and cannot reconstruct any client’s mask. - Real statistical drift tests, built on NaN-safe ordering, a Lanczos
ln_gamma, the Kolmogorov and chi-square survival functions, and the two-sample KS statistic — throughscirs2-stats— instead of invented p-values. - GPU backends now say so. Every vendor memory backend’s file header states plainly that its copy functions move zero bytes and which statistics fields are declared but never incremented.
- Zero-warning, no-blanket-allow policy. The workspace-level lint table is now intentionally empty; every crate opts in explicitly via
[lints] workspace = true.cargo checkandcargo clippy --workspace --all-features --all-targetsboth finish at zero warnings. - ~90 dead scaffolding types removed — duplicate configs, constructor-only shells, and roughly 13 million dead duplicate parameters in the transformer-based learned optimizer (which is what made its previously
#[ignore]d creation test fast enough to enable).
Technical Deep Dive: Where the honesty pass landed
Streaming and privacy (optirs-core). The drift/anomaly stack (streaming::adaptive_streaming) now runs on a shared numerics module — median/quantile selection, the standard-normal and chi-square survival functions, KL/Jensen-Shannon/Hellinger divergences, 1-D Wasserstein distance — instead of ad hoc approximations. The federated-learning stack (privacy::federated) gained the real Bonawitz protocol above, plus coordinate-wise median, trimmed mean, Krum, Multi-Krum, Bulyan and centered-clipping robust aggregators, and a Merkle-tree audit trail (RFC-6962-style, HMAC-SHA256 pinned against RFC 4231 vectors).
Neural architecture search (optirs-nas). Exact hypervolume by HSO recursion now drives NSGA-II against a latched reference point; MOEA/D (Zhang & Li, 2007) ships with a Das-Dennis weight lattice; and grid, TPE and kernel-regression-surrogate hyperparameter search replace what used to fall through to random search.
Learned optimizers (optirs-learned). LSTM optimizers meta-train by real truncated BPTT, with gradients checked against finite differences and meta-training verified to reduce held-out meta-loss. The transformer-based optimizer gained a real backward pass through its output projection, layer norms, feed-forward blocks and input embedding.
Workspace hygiene. Every source file is now under 2,000 lines — the 17 files that exceeded it were split into roughly 90 module files with public APIs preserved through re-exports. A new deny.toml at the workspace root, enforced by cargo deny check bans, blocks BLAS/LAPACK FFI, bincode, z3, rusqlite, the C compression family, and TLS/crypto FFI in favor of the COOLJAPAN pure-Rust equivalents.
Getting Started
cargo add optirs-core scirs2-core
[dependencies]
optirs-core = "0.3.2"
scirs2-core = "0.6.5" # required foundation
The optimizer API is unchanged from 0.3.1 — no optimizer, scheduler or regularizer was removed or renamed:
use optirs_core::optimizers::{Adam, Optimizer};
// Always use scirs2_core for arrays - never ndarray directly.
use scirs2_core::ndarray::Array1;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let params = Array1::from_vec(vec![1.0, 2.0, 3.0, 4.0]);
let gradients = Array1::from_vec(vec![0.1, 0.2, 0.15, 0.08]);
let mut optimizer = Adam::new(0.001);
let updated_params = optimizer.step(¶ms, &gradients)?;
println!("Updated parameters: {:?}", updated_params);
Ok(())
}
What’s New in 0.3.2
- Real Bonawitz secure aggregation for federated learning, replacing a protocol whose masks never cancelled (
optirs-core::privacy::federated, newx25519-dalekdependency). - Real statistical drift and anomaly detection — chi-square, KS, G-test and divergence measures computed through
scirs2-stats, plus ML anomaly detectors with measured (not hardcoded) success rates. - Verifiable audit trails — an RFC-6962-style Merkle tree with HMAC-SHA256-pinned leaves and constant-time digest comparison.
- Exact hypervolume, NSGA-II and MOEA/D for multi-objective NAS, plus real grid/TPE/surrogate hyperparameter search.
- LSTM truncated-BPTT meta-training and a real transformer backward pass in
optirs-learned. FileCheckpointStorage— a filesystem-backed checkpoint store usingoxicodewith CRC32 corruption detection.deny.tomlenforced bycargo deny check bansacross Linux/macOS/Windows/wasm32.- Zero-warning workspace policy — every blanket
#![allow(...)]removed; roughly 2,600 combined rustc/clippy warnings fixed rather than re-suppressed. - File-size policy — no source file at or above 2,000 lines.
- Numerous correctness fixes:
LowLatencyOptimizer::exact_updateno longer zeroes parameters on every call, DARTS discretization no longer picks the most negative logit,kfac_hessian_approximationno longer indexes past its slices, and the cross-platform benchmark harness can no longer report infinite throughput. - Removed: a large amount of publicly-exported scaffolding that was never implemented — duplicate configs, constructor-only shells, and dead types across
optirs-core,optirs-learned,optirs-nasandoptirs-tpu. Nothing that had a working implementation was removed or renamed.
Tips
- Upgrading from 0.3.1 is safe, but re-read your federated-learning integration. The duplicate, insecure
SecureAggregatorinfederated_privacy::componentsis gone; the real Bonawitz protocol inprivacy::federatedis the only one left. If you named the old type, this is a real compile break, not a formality. - If you called
GpuOptimizer::to_gpu/to_cpudirectly, switch tomove_to_gpu/move_to_cpu— the old names remain as#[deprecated]shims for callers, but externalimpl GpuOptimizerimplementors must rename the required trait methods. - Treat
optirs-gpu’s non-Metal backends as a status report, not a feature list. WebGPU kernels exist but are blocked upstream; OpenCL is context-only; CUDA/ROCm have no backend. Metal is the one path that runs real compute shaders end to end today. - Enable
deny.tomlin your own downstream crate if you depend on OptiRS and want the same pure-Rust guarantee enforced automatically —cargo deny check bansis how this release keeps BLAS/LAPACK FFI and friends out for good. - Run
cargo deny check bansbefore you vendor anything new into a fork. The banned list (BLAS/LAPACK FFI,bincode,z3,rusqlite, the C compression family,openssl/native-tls/ring) is the fastest way to catch an accidental non-pure-Rust dependency before it ships.
This is the foundation
OptiRS is the optimizer layer of the COOLJAPAN ML and scientific stack, anchored on SciRS2 — now on the 0.6.5 line as of this release. It is the torch.optim/optax-class companion to ToRSh (deep learning), SkleaRS (scikit-learn-class), TenfloweRS, and TrustformeRS (transformers), sitting alongside NumRS2, PandRS, OxiBLAS, Oxicode, OxiFFT, OxiZ, OxiARC, OxiMedia, OxiGDAL, OxiLean, Legalis-RS, and OxiRAG — a Pure Rust scientific computing platform where every layer extends SciRS2 rather than bolting on a foreign runtime.
Repository: https://github.com/cool-japan/optirs
Star the repo if you’d rather your optimizer suite return an honest error than a fabricated number. 0.3.2 is the release where OptiRS stopped simulating and started measuring.
— KitaSan at COOLJAPAN OÜ August 18, 2026