Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .agents/skills/codabench-benchopt/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
name: codabench-benchopt
description: >
Designing and operating a machine-learning competition on Codabench whose
evaluation is a benchopt benchmark — where each decision belongs (benchmark
vs phase config vs ingestion vs scoring vs competition.yaml vs worker), the
design forks that are genuinely open (training on the platform or not,
metric in the objective or in the scoring program, hosted or self-hosted
workers, how many phases), and how much to hide from participants at what
cost. Also the evaluation protocol the platform design rests on: single
sealed split vs cross-validation, leakage in the split, and the distribution
shift between public and ranked data. Consult when setting up or reviewing a
competition bundle, an ingestion/scoring program, a phase input_data
directory, a hidden/sealed test phase, a self-hosted compute worker, or when
deciding what goes in the public starting kit. Trigger words: Codabench,
competition bundle, competition.yaml, ingestion program, scoring program,
input_data, reference_data, phase, sealed phase, hidden test set,
leaderboard, starting kit, submission contract, compute worker,
hide_prediction_output, leakage, train/test split, cross-validation, group
split, distribution shift, benchopt competition.
---

# Benchopt-powered Codabench competitions

**The benchmark is the competition.** The platform is a scheduler and a
leaderboard; the programs it runs are adapters. Everything here serves one
invariant — participants run the same code the server runs.

## Start here: protocol, then forks, then build

**Step 0 is the evaluation protocol**, not the platform: cross-validation or a
single sealed split, how the split is cut, what shift sits between what
participants develop on and what ranks them
([data-and-splits.md](./data-and-splits.md)). The forks below inherit it.

Then settle these, in order — each narrows the ones after it. Ask if they are
not on record rather than picking silently
([design-decisions.md](./design-decisions.md)):

1. Does the platform train, or only run inference on a shipped model?
2. How many phases — one, a development/final pair, or more?
3. Where is the metric computed — objective, or scoring program?
4. Hosted Codabench workers, or a self-hosted queue?
5. Where does the benchmark live — phase bundle, or baked into the image?
6. Is the submission environment frozen, or resolved per submission?

## Layer map

| Layer | Artifact | Owns |
|---|---|---|
| Benchmark | `tracks/<t>/{objective,datasets,solvers}`, or `benchmark/` for a single track | task, loaders, submission contract, and the metric *if* you score there |
| Submission | `submission.py` + weights and/or training code | the model, nothing else |
| Phase | `input_data/` = `config.yaml` (+ benchmark, + sealed `datasets/*.py`) | which data, which split, seed, training on or off, leaderboard column map |
| Ingestion | `ingestion_program/` | filesystem wiring; exec `benchopt run` |
| Scoring | `scoring_program/` | results → `scores.json`, parsing or computing the metric |
| Competition | `competition.yaml` | windows, quotas, visibility flags, pages, image |
| Infra | image + worker + staging | environment, data residency, mounts, queue |

Per-layer boundaries and traps: [responsibilities.md](./responsibilities.md).

## Invariants, whichever fork you take

- **One code path.** The benchmark participants run locally is the benchmark the
server runs. No platform detection, no "server mode" branch in the objective.
- **Task in the benchmark, configuration in the phase.** Whatever a phase may
change *without changing the task* — dataset and parameters, seed, training
on/off, leaderboard column map — lives in the phase config, not the objective
and not the image.
- **Fail loudly at every boundary.** The characteristic failure here is not a
crash, it is a plausible wrong number on a leaderboard nobody can re-derive
three weeks later.
- **Placement is per artifact, not per repo.** Everything shipped in a phase is
readable by every submission container; everything in the public repo is
readable by everyone ([sensitivity.md](./sensitivity.md)).
- **Minimize what differs between phases.** Each difference is a code path first
exercised where mistakes are unfixable. Some designs legitimately change more
than the data — pay that knowingly, and rehearse before the phase opens.

## Starting point: the template

Start a new single-track competition from
[`x-datascience-datacamp/template_codabench`](https://github.com/x-datascience-datacamp/template_codabench),
a GitHub template repo. It encodes the defaults: training on the platform,
one phase with hidden private columns, metric in the objective, benchmark
shipped in the phase `input_data`, frozen environment, data built by
`Dataset.prepare()`, and CI end to end on `Simulated`. Its README lists the adaptation steps in
order. Change the template itself rather than diverging copies, so fixes
reach the next competition.

## Reference implementation

For multi-track and sealed-phase designs: the NeurIPS 2026 neural-interfaces
competition — `2026-neurips_compet-eeg`
(public benchmark + bundles) and its private ops repo (Terraform workers, phase
publishing). Four tracks, one image, warm-up on public proxy data and a sealed
final phase on a held-out cohort; metric in the objective, inference-only,
self-hosted workers.

**Its code encodes its forks. Re-check each piece against yours before copying
it.** Copying it verbatim into a single-track port means deleting, unless your
fork needs them:

- The objective `training` toggle. Only needed when phases differ (fork 1).
- Symlink dereferencing and the dangling-link guard. These come from
multiple tracks sharing code through symlinks.
- The sealed `datasets/*.py` drop-in. Only for a sealed phase that ships its
split as code.
- The no-config auto-detect fallback in scoring. With one phase config, read
`config["scoring"]["columns"]` and fail otherwise.
- The workdir copy and solver install in ingestion. They predate benchopt path
selectors ([responsibilities.md](./responsibilities.md)).

For a single track, put the benchmark in its own `benchmark/` folder rather
than the repo root, so it is clear what is benchopt and what is the Codabench
wrapper.
108 changes: 108 additions & 0 deletions .agents/skills/codabench-benchopt/data-and-splits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Step 0: the evaluation protocol

Settle before the forks: the protocol decides fork 1 (a protocol needing
server-side cross-validation can only be training-on-platform) and fork 2
(whether a sealed split exists at all). Deciding it after the benchmark is
written means rewriting the benchmark.

## Cross-validation or a single sealed split

Rule of thumb: **scarce data needs CV; expensive or confidential data needs a
privacy design that CV does not fit.** Most competitions sit between and must
choose.

- Few independent units (subjects, sessions, sites — not rows) means a single
split's variance can exceed the gap between the top entries. If you rank on
one split anyway, estimate that variance first and use it to decide whether
the top-k are distinguishable before awarding anything on the difference.
- CV puts every sample in a test fold, so you cannot cross-validate *and* keep
a fold hidden. The only way to have both is server-side CV under
training-on-platform (fork 1 B), at k times the compute.
- Under inference-only submissions, server-side CV means the submission ships
k models. If you get there, the ranking wanted a single sealed split.

Common compromise: rank on a single sealed split, and ship a CV configuration
over the public data so participants model-select against something other than
the leaderboard.

## Leakage in the split

The split is part of the task definition, and in a competition its failure mode
is specific: a leak ships inside the starting kit, every participant inherits
it, a participant finds it publicly mid-phase, and it cannot be fixed without
invalidating the leaderboard.

Train and test must be independent for the generalization the leaderboard
claims to measure. Beyond the usual group, temporal and duplicate leaks, one
case is easy to get wrong:

- **Several axes at once.** When an observation is a combination (gene ×
condition, user × item, subject × stimulus), holding out "new A × new B" is an
L-shaped split: A-test units still appear in train with B-train, and the
reverse. That is by design, so do not assert A disjointness across sides.
Assert instead that each axis label is constant per unit (a unit is test on
that axis everywhere), and that no *cell* is shared. An axis held out
completely (a new species, a new site) must be disjoint.

What follows from it:

- Split on the coarsest unit that differs at deployment — by subject for "works
on a new subject", by site for "works at a new site". Recording-level for
windowed signals, plus a gap at the boundary when windows overlap.
- The *target* leaks even when the input does not: one stimulus seen by many
subjects lets a model retrieve instead of predict. Deduplicate on the target.
- Anything fitted on the full dataset (normalization, PCA, channel selection)
belongs inside the training fold — in a competition this one is not a private
mistake, it is shipped code.
- Ids, file names and row order are readable to every submission, since a phase
bundle is ([sensitivity.md](./sensitivity.md)). Strip what should not be.

Test it: assert the independence above in the split script (no unit on both
sides of a fully held-out axis, no shared cell otherwise), and run a **cheating
baseline** on ids and metadata alone. Above chance means the split leaks.

## Check the metric against sensible baselines

Before opening, score a trivial floor and a simple model on every ranked subset:
the simple model must clearly beat the floor (else the task is broken or
impossible) and leave room above it (else it is trivial). Seed them so the
numbers are reproducible. Three less obvious traps:

- **Probabilistic metrics.** Under a likelihood, a constant with a wide,
well-calibrated spread can be a hard floor a decent point predictor loses to.
- **Heavy-tailed per-observation losses.** A count likelihood (NB, Poisson)
grows like `y · log(1/mu)` when `mu` is near 0, so one bad prediction on a
highly expressed observation can outweigh thousands of rows. Look at the
per-observation loss of the reference (max, top-10 share) and cap it (e.g.
at about 15× a typical row) rather than ranking on a mean one row decides.
Clip the baselines' `mu` away from 0, too: `expm1` of a negative log
prediction is negative, and a clip at 0 then predicts zero counts.
- **The synthetic smoke-test dataset needs the same check**, with enough signal
that the reference beats the floor, or the smoke test passes on a pipeline
that cannot learn.

When a public half shows on the leaderboard and a hidden half ranks, halve each
held-out region by the unit that is new in it (gene, run, subject), with a hash
of its key, so the same unit falls in the same half everywhere. A region with no
new unit can be halved by observation. Then score the reference on both halves:
they should agree within noise.

## Name the shift you are measuring

Any gap between what participants develop on and what ranks them — public proxy
vs hidden cohort, development vs final phase — is what the leaderboard actually
measures.

- Separate shift you **chose** (different site, hardware or population, because
generalizing across it is the research question) from shift you **inherited**
(the proxy is an older, dirtier dataset). Announce the first; reduce the
second.
- **Measure it before opening**: train a baseline on the public part, evaluate
on the sealed part. If two baselines swap order, that is what participants
will experience as randomness. This doubles as the end-to-end rehearsal of the
sealed phase.
- Declare it on the participation page — "developed on cohort X, ranked on
cohort Y recorded with the same hardware" is also the honest reading of the
numbers when they are later cited.

What to publish of the data: dial 1 of [sensitivity.md](./sensitivity.md).
Loading
Loading