agentleFS
param087param087/agent-ml-skills/skills/reproducible-ml/SKILL.md

reproducible-ml

Skill11 starsChanged 6 months agoMITView on GitHub

Use when an ML result must be reproducible — fixing seeds, pinning environments, versioning data, and structuring projects so runs can be exactly recreated. Covers determinism gotchas across NumPy, PyTorch, and CUDA.

  • Installs packages

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use DVC or dataset snapshots.

    line 44
  2. Very specific:

    Treat data as immutable inputs keyed by version (data_v="2026-06-01").

    line 45

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Reproducible ML

Overview

Reproducibility means: same code + same data + same config → same result. It is a prerequisite for trusting comparisons, debugging regressions, and shipping. Three pillars: seed everything, pin everything, version the data.

When to use

  • Results vary run-to-run.
  • Setting up a new project or research codebase.
  • Preparing work others must reproduce (papers, audits, reviews).

Pillar 1 — Seed everything

import os, random, numpy as np, torch

def seed_everything(seed: int = 42):
    os.environ["PYTHONHASHSEED"] = str(seed)
    random.seed(seed)
    np.random.seed(seed)
    torch.manual_seed(seed)
    torch.cuda.manual_seed_all(seed)
    torch.backends.cudnn.deterministic = True
    torch.backends.cudnn.benchmark = False  # disables nondeterministic autotuner

For DataLoaders, also set worker_init_fn and a generator so workers are deterministic.

Pillar 2 — Pin the environment

  • Pin exact versions: requirements.txt with ==, or uv.lock / poetry.lock / conda env export.
  • Record Python + CUDA + cuDNN versions in the run metadata.
  • Containerize (Docker) for cross-machine reproducibility.

Pillar 3 — Version the data

  • Hash datasets (sha256) and log the hash with every run.
  • Use DVC or dataset snapshots; never overwrite data.csv in place.
  • Treat data as immutable inputs keyed by version (data_v="2026-06-01").

Project layout that supports reproducibility

project/
├── data/            # raw (immutable) + processed, both versioned
├── src/             # importable code, no notebooks doing real work
├── configs/         # YAML/Hydra configs, one per experiment
├── scripts/         # entrypoints: train.py, evaluate.py
├── requirements.txt # or uv.lock / poetry.lock (pinned)
└── README.md        # exact commands to reproduce

Determinism gotchas

  • GPU reductions can be nondeterministic even with seeds — use torch.use_deterministic_algorithms(True) and set CUBLAS_WORKSPACE_CONFIG=:4096:8.
  • Parallel groupby/apply ordering can vary — sort before reducing.
  • set/dict ordering across processes — set PYTHONHASHSEED.
  • Non-pinned dependencies silently change behavior between installs.

Pitfalls

  • Seeding only NumPy but using PyTorch/CUDA RNGs.
  • "Works on my machine" — unpinned env + unversioned data.
  • Doing real computation in notebooks with hidden execution order — move logic to src/.

Hand-off

A repo where pip install -r requirements.txt && python scripts/train.py --config configs/exp.yaml recreates the exact result that experiment-tracking logged.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.