Keras OptiRoulette meta-optimizer (PyTorch backend only)
Project description
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/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file optiroulette_keras-0.1.2.tar.gz.
File metadata
- Download URL: optiroulette_keras-0.1.2.tar.gz
- Upload date:
- Size: 25.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
305dc2828d9a48ef5eb37cac58d2761f2eebae698d020e3eb063807a2e0a52b7
|
|
| MD5 |
9e92a30da92c00d1a8a4f0631c55ab7c
|
|
| BLAKE2b-256 |
fbaf38bd1ab3c20f6f26b4d4d7a45d47c46679956ee148bf670673bf731de292
|
Provenance
The following attestation bundles were made for optiroulette_keras-0.1.2.tar.gz:
Publisher:
publish-pypi-keras.yml on MStamatis/OptiRoulette
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
optiroulette_keras-0.1.2.tar.gz -
Subject digest:
305dc2828d9a48ef5eb37cac58d2761f2eebae698d020e3eb063807a2e0a52b7 - Sigstore transparency entry: 976425019
- Sigstore integration time:
-
Permalink:
MStamatis/OptiRoulette@c63e76f684e015f3e418e4ef69c5848d423c5dab -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MStamatis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi-keras.yml@c63e76f684e015f3e418e4ef69c5848d423c5dab -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file optiroulette_keras-0.1.2-py3-none-any.whl.
File metadata
- Download URL: optiroulette_keras-0.1.2-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd09b7af1a0366697df8a03826aa178946fb6d5b0ca8b1b8c9ab46dc8ee99ac1
|
|
| MD5 |
cca0bf609e242be9b13f80a3415ae81a
|
|
| BLAKE2b-256 |
3a480a8a846d3e263902b9cdcd7853eea34863a5fea762f2c91dab1c0cdb55d2
|
Provenance
The following attestation bundles were made for optiroulette_keras-0.1.2-py3-none-any.whl:
Publisher:
publish-pypi-keras.yml on MStamatis/OptiRoulette
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
optiroulette_keras-0.1.2-py3-none-any.whl -
Subject digest:
dd09b7af1a0366697df8a03826aa178946fb6d5b0ca8b1b8c9ab46dc8ee99ac1 - Sigstore transparency entry: 976425024
- Sigstore integration time:
-
Permalink:
MStamatis/OptiRoulette@c63e76f684e015f3e418e4ef69c5848d423c5dab -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MStamatis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi-keras.yml@c63e76f684e015f3e418e4ef69c5848d423c5dab -
Trigger Event:
workflow_dispatch
-
Statement type: