Skip to content

About

Repository used for benchmarking the mmcontext models

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

mmcontext-benchmark

Multi-model comparison for mmcontext.

mmcontext is the focused model package (architecture + single-model evaluation). This repo compares models: it embeds (or predicts on) the same datasets with many methods and scores them on one shared set of classification metrics. The dependency edge is one-way — mmcontext-benchmark imports mmcontext, never the reverse.

It compares, on equal footing:

  • mmcontext models, old approach — checkpoints whose numeric data is registered onto the legacy MMContextEncoder;
  • mmcontext models, new approach — checkpoints that resolve omics vectors through an attached memory-mapped VectorStore (MMContextModule);
  • external baselines — CellWhisperer (joint embedder) and SCSA (a direct marker-gene classifier), each run in its own container.

You don't tag mmcontext checkpoints as old vs new: the adapter inspects the loaded model and picks the right path automatically.

Architecture

src/mmcontext_benchmark/
├── artifacts.py        # the on-disk contract every model writes & eval reads
├── adapters/           # one adapter per model "kind"
│   ├── base.py           # EmbedderAdapter / ClassifierAdapter + Dataset/ModelSpec
│   ├── registry.py       # auto-detect mmcontext; dispatch externals by `kind`
│   ├── mmcontext.py      # unified old/new mmcontext embedder
│   ├── cellwhisperer.py  # container-backed embedder
│   └── scsa.py           # container-backed direct classifier
├── containers/         # container execution for external tools
│   ├── runner.py         # docker / apptainer launcher
│   ├── scsa/             # Dockerfile + in-container entrypoint
│   └── cellwhisperer/    # Dockerfile + in-container entrypoint
├── embed/              # orchestrator over the (dataset × model) grid
├── eval/               # two-track scoring (embedders + classifiers)
└── collect/            # cross-model comparison tables (+ LaTeX)
conf/                   # Hydra configs: datasets/, models/, benchmark.yaml
scripts/run_benchmark.py

The artifact contract

Every adapter writes one <root>/<dataset>/<model>/ directory:

  • embedders → embeddings.parquet, subset.h5ad, *_label_embeddings_*;
  • classifiers → predictions_<label>.parquet, subset.h5ad.

The eval layer dispatches on which files are present — that's what lets wholly different methods be compared. See artifacts.py.

Two metric tracks, one set of keys

  • Embedder track uses mmcontext.eval.LabelSimilarity (nearest-label retrieval). CellWhisperer's dot-product + softmax + logit_scale scoring is carried in meta.yaml and applied automatically.
  • Classifier track (eval/classification.py) scores SCSA's predictions and emits the same LabelSimilarity/... metric keys, so the collection step fuses both into one table. Ranking-only metrics (AUC, top-k, MRR) are NaN for hard classifiers. scIB is dropped as legacy.

External tools = containers

CellWhisperer and SCSA have heavy, mutually-conflicting dependency stacks (numpy<2, pinned torch, vendored Geneformer, …). Each ships as its own image with a self-contained entrypoint; the host adapter prepares inputs, runs the container (Docker locally, Apptainer on SLURM), and reads back the standard artifacts. No per-tool venvs or interpreter-path juggling.

docker build -t mmcontext-bench/scsa:latest \
  -f src/mmcontext_benchmark/containers/scsa/Dockerfile .
docker build -t mmcontext-bench/cellwhisperer:latest \
  -f src/mmcontext_benchmark/containers/cellwhisperer/Dockerfile .

Usage

pip install -e ".[dev,test]"          # or: uv sync

# Full grid (datasets × models) — embed then evaluate then collect:
python scripts/run_benchmark.py

# Only mmcontext checkpoints (no containers needed):
python scripts/run_benchmark.py models=mmcontext_only

# Re-evaluate existing artifacts without re-embedding:
python scripts/run_benchmark.py stage=eval

Add a model by appending an entry to a list in conf/models/. mmcontext checkpoints need only source, name, layer_key; external tools add kind: scsa / kind: cellwhisperer. Add a dataset under conf/datasets/.

Status

Core pipeline implemented end-to-end. Import-light tests (artifact contract, adapter dispatch, classification metrics, collection) run in CI; full embedding runs need torch + mmcontext and the built container images, so they run on the maintainer's machine / cluster. The two container entrypoints port the original SCSA/CellWhisperer logic and should be validated against the built images.

About

Repository used for benchmarking the mmcontext models

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages