The model is small; the refresh policy is still interesting Link to heading
A lot of hyperparameter optimization examples stop after one search. They find a good configuration, save the model, and leave the next training run as an exercise for the reader. Production systems have to answer a harder question: when new data arrives, how much of that search should happen again?
I built small_ml_hpo to make that question concrete. It is a template for models and datasets that fit comfortably on a single machine: each trial can train without model parallelism or data sharding. The search itself can still scale horizontally across many machines. The demo uses LightGBM on tabular data, with Ray Tune coordinating trials, Optuna proposing configurations, and MLflow recording experiments and managing model versions.
The template supports three ways to respond to a data refresh:
- Fresh HPO: ignore earlier configurations and search the space again.
- Warm HPO: run a new search, but evaluate previously successful configurations first.
- Greedy retraining: skip the search and retrain only the best configurations from earlier sessions.
Those options turn retraining into an explicit cost-versus-exploration decision. They also force a useful distinction: warm means warm configurations, not warm model weights.
What small means here Link to heading
Small does not mean unimportant, and it does not necessarily mean a tiny dataset. It means one machine can hold the data and train one model without special infrastructure. That constraint applies to each trial, not to the search as a whole. A trial takes seconds or minutes rather than hours or days, so starting LightGBM from scratch is affordable.
Ray still earns its place. It distributes independent trials across available workers, whether those workers are CPU processes on one machine or nodes in a larger Ray cluster. Adding machines can therefore increase search throughput without changing the model or the training function. Each worker trains its own complete model; Ray is not splitting one model or dataset across the cluster. That distinction keeps each trial simple while letting the search use the hardware available.
The rest of the stack has a similarly narrow job:
| Component | Job in the template |
|---|---|
| LightGBM | Trains each tabular model from scratch |
| Optuna TPE | Proposes promising configurations after an initial random-search phase |
| Ray Tune | Runs trials concurrently and schedules their training budgets |
| Ray ASHA | Stops low-performing trials early in fresh and warm searches |
| MLflow | Stores parent and child runs, trial tables, model artifacts, registry versions, and the champion alias |
Pruning here means terminating an unpromising hyperparameter trial, not removing weights from a neural network. The LightGBM callback reports its validation metric after every boosting round. Ray’s ASHA scheduler compares trials at successive budgets and stops the weak ones. LightGBM’s own early stopping is separate: it ends one trial when that model stops improving, while ASHA decides whether a trial deserves more resources relative to the others.
Greedy mode deliberately uses neither Optuna nor ASHA. It evaluates exactly the requested configurations with FIFO scheduling, so every selected configuration gets a complete result.
Warm configurations, fresh weights Link to heading
Every trial in every mode starts with a newly initialized model. The promotion step does the same: it refits both the challenger and the current champion on the current data. There is no hidden load_model call carrying last month’s boosted trees into this month’s run.
That is the right default for this problem. If a full fit is cheap, reusing weights adds complexity without buying much. Old trees still encode old relationships, and continuing training is not equivalent to fitting the whole model to the current snapshot. A fresh fit gives each candidate the same clean starting point and makes the data-to-artifact path easier to reproduce.
Loading previous weights makes sense in a different setting: fine-tuning an expensive neural network, adapting a pretrained foundation model, or running an explicitly continual-learning system. There, the initialization is a valuable asset. It also becomes part of the experiment design. You need to decide which layers can change, how much new data should move the model, and how to test for forgotten behavior. That is a worthwhile workflow, but it is not a drop-in optimization for this template.
The same rule applies when the champion wins. Retaining the champion means retaining its configuration, not leaving the old artifact untouched. The template refits that configuration on the new train-plus-validation data and registers a new model version. Production gets a model trained on the current snapshot without changing its hyperparameters merely because last month’s validation score was good.
One session, from snapshot to champion Link to heading
A session starts with a complete data snapshot, not an increment. An optional preprocessing hook runs before a temporal split creates train, validation, and test windows. The template hashes the split contents and split configuration to create a data version, then records that version and the feature schema in MLflow.
The search uses only train and validation. Afterward, the best completed trial becomes the challenger. Both its configuration and the current champion’s configuration are refit on train plus validation, with their training lengths determined on the current snapshot. They are then scored on the held-out test set that the search never saw.
A challenger must beat the champion by more than a configurable margin. This prevents a negligible improvement from causing a configuration change. The winner is registered as a new MLflow model version with its configuration, data version, test scores, and promotion decision attached. Only then does the champion alias move.
The first run is simpler: with no existing champion, the best challenger establishes the first registered version.
Three modes, three production speeds Link to heading
| Mode | What runs on the new snapshot | Search cost | When I would use it |
|---|---|---|---|
fresh | m random trials, then guided TPE trials up to the total budget | Highest when given a large budget | Initial training, major drift, a new feature pipeline, or a deliberate reset |
warm | Top n configurations from named parent sessions, then m random trials, then TPE | Medium with a small budget; high with a large one | Routine refreshes where history is useful but some exploration is still worthwhile |
greedy | Exactly the top n eligible configurations from named parent sessions | Lowest and most predictable | Frequent refreshes, stable relationships, and little reason to explore |
This roughly gives me three production policies:
- Fast: greedy retraining of a few known configurations.
- Medium: warm HPO with a small trial budget.
- Slow: fresh HPO, or warm HPO with enough budget for substantial exploration.
Fast, medium, and slow describe the budget policy rather than guarantees about wall-clock time. Dataset size, concurrency, and training cost still matter. Fresh is not inherently slower than warm at the same budget; warm’s advantage is that it spends the first trials on configurations that already worked. Greedy is the only mode that removes search entirely.
Warm mode also has a useful middle ground between blind trust and amnesia. A previously good configuration must prove itself on the current data before it can become the challenger, while random and guided trials still get a chance to find something better.
Carrying history forward without comparing stale scores Link to heading
A monthly RMSE from one snapshot is not directly comparable to an RMSE from another. The target distribution and test window may both have changed. Treating those raw numbers as one leaderboard would select configurations for the wrong reasons.
Instead, the template ranks completed trials within each parent session, converts those ranks to percentiles, and only then merges candidates from the named parents. When several parent sessions are supplied, an age discount multiplies each percentile by gamma^age. The newest parent has age zero; older sessions contribute less as gamma decreases. Configurations are de-duplicated and filtered against the current search space before the top n are selected.
That makes parent selection part of the operational decision. I can seed from the most recent run, several comparable runs, or a broader history when I suspect a seasonal pattern has returned. The trial table stored on each MLflow parent run preserves the configurations, outcomes, metrics, training lengths, data versions, and seed provenance needed to reconstruct that choice.
Search-space changes receive explicit handling too. Seeds outside current bounds are dropped and recorded. Removed hyperparameters or changed types force warm mode to fall back to fresh; greedy mode fails because it has no valid fixed list to run. Newly added hyperparameters can either receive declared defaults or force a fresh start, depending on the selected policy. Reusing history is helpful, but silently changing its meaning is not.
Running the demo Link to heading
The included demo uses monthly snapshots of the public Bike Sharing dataset. It runs four CPU-only sessions: fresh on snapshot 6, warm on snapshot 7, greedy on snapshot 8, and another warm session on snapshot 9 seeded from two earlier runs.
git clone https://github.com/huntermills707/small_ml_hpo.git
cd small_ml_hpo
uv sync
uv run python demo/run_demo.py
The walkthrough creates a separate SQLite tracking store and model registry under demo_runs/. After it finishes, the nested trial runs, trials.jsonl tables, promotion decisions, and champion versions are visible in MLflow:
uv run mlflow ui --backend-store-uri sqlite:///$PWD/demo_runs/mlflow.db
For a new project, the intended starting point is user_config.py: supply a snapshot loader, choose the time and target columns, define temporal validation and test windows, set the metric, and declare the LightGBM search space. A typical sequence then looks like this:
uv run hpo run --mode fresh --m 4 --budget 12 --label run-1
uv run hpo run --mode warm --parents <run-id> \
--n 3 --m 2 --budget 12 --label run-2 --seed 2
uv run hpo run --mode greedy --parents <run-id> \
--n 3 --label run-3 --seed 3
Each session is an MLflow parent run with nested child runs for its trials. That makes the refresh policy visible in the experiment record rather than leaving it in a scheduler configuration or someone’s notebook.
Where I would extend it Link to heading
The current template is intentionally narrow. LightGBM and tabular snapshots make the complete loop small enough to read, but the same policy ideas apply more broadly.
- Other model libraries. XGBoost, CatBoost, scikit-learn, or a small neural network could use the same fresh/warm/greedy session structure. This requires more than editing
user_config.py: trial reporting, training-length selection, refitting, test scoring, and model serialization currently have LightGBM-specific implementations. A small model-backend interface would be the clean extension. - GPU support. Ray can request GPU resources for trials, but the training backend also needs GPU-aware parameters and serialization. For small tabular models, CPU training may still be faster and simpler; GPU support matters more once the template covers larger neural models.
- Beyond tabular data. Text, image, and time-series workloads need different snapshot, splitting, and preprocessing contracts. The data version should cover raw inputs and transformations, not only DataFrame contents. The warm-configuration policy still applies even when the model format changes.
- More general production flexibility. Additional metrics, non-temporal validation, alternative searchers and schedulers, multi-objective optimization, and remote tracking stores are all natural additions. A real deployment also needs a scheduler, remote artifact storage, access control, and a serving or canary step; this template ends at the registry alias rather than pretending model registration is the whole production system.
Takeaways Link to heading
The useful artifact from an HPO run is not only the model. It is the collection of configurations, validation results, training lengths, pruning outcomes, and data versions that tells the next run where to look.
For small-data models, I want to reuse that knowledge without reusing stale weights by default. Fresh searches maximize exploration, warm searches spend some of the budget rediscovering what already worked, and greedy retraining keeps only the cheapest part of the loop. In all three, a new model still has to beat the current champion on the same current held-out data before it takes the alias.
The code and demo are in the small_ml_hpo repository. The part I would keep even in a larger system is the explicit refresh policy: decide what history means, decide how much search the new data deserves, and make promotion earn its way onto production.