Skip to content

Add production-ready fold-mean Optuna search - #139

Open
cornelislouisa wants to merge 5 commits into
mainfrom
guille/production-optuna
Open

cornelislouisa wants to merge 5 commits into
mainfrom
guille/production-optuna

Conversation

@cornelislouisa

Copy link
Copy Markdown
Collaborator

Summary

Add the supported production path for resumable, multi-GPU Optuna searches over the omics benchmark.

Each outer ablation cell is its own study. A trial samples one model configuration and evaluates that exact configuration over all five validation folds. The objective is the arithmetic mean across folds; test folds never participate in selection.

Search runtime

  • resumable Optuna studies plus a separate fold-attempt ledger
  • completed folds are reused after interruption or retry
  • deterministic study names, filtering, and virtual sharding
  • explicit GPU-slot assignment and one CPU thread per training subprocess
  • dataloader worker isolation to prevent host oversubscription
  • atomic per-run logs and machine-readable objective/metric payloads
  • cache warmup and dry-run model composition
  • fail-loud WGCNA density targeting; no frozen-threshold fallback

The reusable multi-dataset and smoke configs use relative paths. There are no personal scratch paths or W&B entities in the committed configs.

Parallel STRING safety

Parallel cache warmup can otherwise leave truncated gzip files or partially written JSON. STRING cache construction now uses:

  • per-artifact POSIX file locks
  • temporary writes followed by atomic os.replace
  • complete gzip-stream validation
  • corrupt gzip/JSON recovery

This changes cache I/O only, not graph semantics.

Protocol and documentation

All six omics dataset configs now default to the five-fold rotation (split_type: k-fold, k: 5). The README documents fold behavior, train-only graph construction, WGCNA target connectivity vs STRING cutoff, Optuna studies/trials/retries/shards, baseline selection, and portable launch commands.

Dependency compatibility

The storage code uses Optuna 2.x, which is incompatible with SQLAlchemy 2.x. pyproject.toml now pins:

  • optuna>=2.10.0,<3.0.0
  • sqlalchemy>=1.3.0,<2.0.0

Persistence/resume tests were run with Optuna 2.10.1 and SQLAlchemy 1.4.54.

Verification

  • 75 targeted Optuna, STRING, dataset, split, baseline, and stats tests passed
  • 245 non-slow tests passed
  • production Optuna dry-run successfully composed and instantiated the smoke configuration
  • all pre-commit hooks passed

Scope

Intentionally excluded: Sep24 campaign configs, .gitignore, status/rebalance tooling, test-evaluation/checkpoint scripts, plotting, W&B result aggregation, runbooks/guides, and generated output files.

PR dependency

This branch was built on the temporary combined state of #137 and #138 so their reviewed behavior could be tested together. After those two PRs merge, this branch should be rebased onto updated main; the remaining diff will be this Optuna/STRING/k-fold/README change only.

cornelislouisa and others added 4 commits September 24, 2026 12:27
The baselines were not comparable to the GNNs in two ways.

Hyperparameters were tuned independently inside each fold, so two folds
of the same cell could be reported under different hyperparameters. That
is not what the GNN side does: an Optuna trial evaluates one
configuration across the whole rotation and is scored on the mean. A
per-fold winner also reports the best of several draws from a noisy
validation estimate, which flatters the baseline.

Selection now happens once per cell. Every grid candidate is scored on
every fold's validation split, the candidate with the highest mean wins,
and all five folds are refit and evaluated with that single
configuration. Ties resolve by grid order, matching GridSearchCV. The
choice does not depend on which fold's job computes it, so it is cached
under a fold-independent key and the remaining jobs reuse it. Refitting
still uses training data only, and test data never takes part in
selection.

The feature sets also differed. Baselines ran SelectKBest on top of
whatever columns they were given, while the GNNs consume nodes chosen by
variance, correlation, distance correlation, or random sampling against
the training split. Any accuracy gap was partly a feature-selection
artifact. Baselines now reproduce the GNN node selection directly,
including the node budget and the RNG seeding that makes method=random
reproducible, and SelectKBest is gone from the dataset configs.
verify_baseline_features.py checks this against the parquet artifacts
the GNN pipeline writes.

Within one job the folds are built once and shared between SVM and
elastic net. Rebuilding per baseline meant running the
distance-correlation scan over every gene twice.

Selection is enabled by baseline_hparam_selection in configs/baseline.yaml
and applies only to k-fold runs. Fixed splits, and anyone who sets
per_fold, keep the previous behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
Training graphs were binarized with a per-dataset adjacency_threshold
copied from an old explorer sweep. Those cutoffs do not keep a fixed
edge density once the train fold, node set, or corrections change, so
graphs that were supposed to be comparable were not.

WGCNA training now requires adjacency_target_connectivity and keeps
the strongest train-fold edges nearest to that density. STRING still
uses adjacency_threshold. There is no silent fallback from one to the
other. The stats explorer still sweeps a cutoff, and it has to say so
with wgcna_binarization=fixed_threshold.

Cache directories follow the setting that actually built the graph, so
a density-targeted WGCNA cache cannot be reused as a cutoff cache.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add a resumable Optuna launcher that keeps experimental ablations outside
the search space and evaluates every sampled configuration across the
complete validation-fold rotation. Persist studies and individual fold
attempts so interrupted jobs resume without repeating successful folds.

Run training in isolated subprocesses with deterministic GPU assignment,
one CPU thread, and machine-readable objective and metric payloads. Pin
the Optuna 2.x and SQLAlchemy 1.x combination used by the storage layer.

Make STRING cache construction safe under parallel cache warmup with
per-artifact file locks, atomic gzip and JSON writes, validation, and
corrupt-cache recovery. Default all six datasets to the five-fold
protocol and document the supported search workflow in the README.

Keep the public surface focused on reusable production and smoke configs;
campaign snapshots, evaluation scripts, plotting, and runbooks remain
out of this change.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant