OptiRoulette-Keras (Torch Backend)
This package accompanies the paper "OptiRoulette Optimizer: A New Stochastic Meta-Optimizer for up to 5.3x Faster Convergence".
A standalone, pip-installable Keras meta-optimizer that brings OptiRoulette's
training logic to Keras compile/fit flows:
- random optimizer switching
- warmup -> roulette phase handling
- optimizer pool with active/backup swapping
- compatibility-aware replacement
- learning-rate scaling rules when switching
- momentum/state transfer on swap
The default behavior is loaded from the bundled optimized.yaml profile.
Research Highlights
Based on the current paper draft, OptiRoulette is a stochastic meta-optimizer that combines:
- warmup optimizer locking
- randomized sampling from an active optimizer pool
- compatibility-aware LR scaling during optimizer transitions
- failure-aware pool replacement
Reported mean test accuracy vs a single-optimizer AdamW baseline:
| Dataset | AdamW | OptiRoulette | Delta |
|---|---|---|---|
| CIFAR-100 | 0.6734 | 0.7656 | +9.22 pp |
| CIFAR-100-C | 0.2904 | 0.3355 | +4.52 pp |
| SVHN | 0.9667 | 0.9756 | +0.89 pp |
| Tiny ImageNet | 0.5669 | 0.6642 | +9.73 pp |
| Caltech-256 | 0.5946 | 0.6920 | +9.74 pp |
Additional paper-reported highlights:
- Target-hit reliability: in the reported 10-seed suites, OptiRoulette reaches key validation targets in 10/10 runs, while the AdamW baseline reaches none of those targets within budget.
- Faster time-to-target on shared milestones (example: Caltech-256 @ 0.59, 25.7 vs 77.0 epochs), with budget-capped lower-bound speedups up to 5.3x for non-attained baseline targets.
- Paired-seed analysis is positive across datasets, except CIFAR-100-C test ROC-AUC, which is not statistically significant in the current 10-seed study.
Important: the metrics above are from the current OptiRoulette paper draft (PyTorch experiment suite), not from a full Keras multi-seed validation.
Status
OptiRoulette-Keras is currently an experimental / pre-release package.
It has not yet been validated through full scientific multi-seed experiment suites.
Backend Requirement
You must use Keras with the torch backend:
export KERAS_BACKEND=torch
Set this before importing keras.
Install
pip install OptiRoulette-Keras
Examples
- CIFAR-100 Keras demo notebook
- Tiny-ImageNet Keras demo notebook
- Both notebooks use pure
keras.layersmodel definitions.
Quick Use (compile/fit)
import os
os.environ["KERAS_BACKEND"] = "torch"
import keras
from optiroulette_keras import create_roulette_callback
model = keras.Sequential([
keras.layers.Input(shape=(32, 32, 3)),
keras.layers.Conv2D(32, 3, activation="relu"),
keras.layers.GlobalAveragePooling2D(),
keras.layers.Dense(100),
])
# If you do not pass arguments, bundled optimized.yaml defaults are used
# (optimizers, roulette, pool, LR rules, seed fallback).
# Advanced optimizers (e.g. ranger, adan) are resolved via pytorch-optimizer adapter.
controller, roulette_cb = create_roulette_callback()
# Note: this call is still required. Without it, there is no OptiRoulette switching.
# verbose levels:
# 0 -> no OptiRoulette output (default)
# 1 -> print only active optimizer
# 2 -> include all OptiRoulette metrics in fit/progbar logs
model.compile(
optimizer=controller.active_optimizer,
loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=["accuracy"],
)
model.fit(train_loader, validation_data=val_loader, epochs=10, callbacks=[roulette_cb])
Custom arguments example:
controller, roulette_cb = create_roulette_callback(
optimizer_specs={
"adam": {"learning_rate": 1e-3},
"adamw": {"learning_rate": 1e-3, "weight_decay": 0.01},
"sgd": {"learning_rate": 5e-2, "momentum": 0.9, "nesterov": True},
},
roulette={"warmup_epochs": 0, "warmup_optimizer": None, "warmup_config": {}},
switch_granularity="epoch",
)
If you do not pass these arguments, defaults from bundled optimized.yaml are used.
API
from optiroulette_keras import (
OptiRoulette,
OptiRouletteOptimizer,
OptiRouletteCallback,
create_roulette_callback,
PoolConfig,
ensure_torch_backend,
get_default_config,
get_default_seed,
get_default_optimizer_specs,
get_default_pool_setup,
get_default_roulette_config,
)
Package Layout
This folder is a standalone PyPI package inside the same repository:
packages/optiroulette-keras/pyproject.tomlpackages/optiroulette-keras/src/optiroulette_keras/*packages/optiroulette-keras/tests/*
Build
From this folder:
python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
Metadata
Release files for OptiRoulette-Keras 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| optiroulette_keras-0.1.2.tar.gz | 25.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| optiroulette_keras-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 52.1 kB
Release files / optiroulette_keras-0.1.2.tar.gz
| Download URL | optiroulette_keras-0.1.2.tar.gz |
|---|---|
| Size | 25.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
305dc2828d9a48ef5eb37cac58d2761f2eebae698d020e3eb063807a2e0a52b7
|
|
BLAKE2b-256 checksum How to use checksums |
fbaf38bd1ab3c20f6f26b4d4d7a45d47c46679956ee148bf670673bf731de292
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 22, 2026.
Transparency logRelease files / optiroulette_keras-0.1.2-py3-none-any.whl
| Download URL | optiroulette_keras-0.1.2-py3-none-any.whl |
|---|---|
| Size | 26.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd09b7af1a0366697df8a03826aa178946fb6d5b0ca8b1b8c9ab46dc8ee99ac1
|
|
BLAKE2b-256 checksum How to use checksums |
3a480a8a846d3e263902b9cdcd7853eea34863a5fea762f2c91dab1c0cdb55d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 22, 2026.
Transparency log