Skip to content

feat: agent-facing contracts: docstring index, run headers, verified doc commands - #32

Merged
zengarden merged 6 commits into
devfrom
agent-readiness
Oct 14, 2026
Merged

zengarden merged 6 commits into
devfrom
agent-readiness

Conversation

@zengarden

Copy link
Copy Markdown
Member

What

Makes the library usable from documentation alone: an agent that never reads the source can
define an experiment, run it on CPU/GPU/Ray, use checkpoints and the data helpers, and trust the
commands the docs show.

Three commits on dev (3d6c09d):

  • fix: 🐛 harden config, checkpoint and launcher edges found by the agent trials
  • docs: ✏️ document every public contract so the source need not be read
  • test: 💍 check the documented commands and the example run headers

⚠️ Breaking change

mode=val is renamed to mode=eval in the mnist and resnet examples (vit_tp already used eval).
No alias is kept; the old value now fails with Unknown mode 'val' ... train, eval, help.
Names about the validation set are unchanged (val_dataloader, val_batch_size_per_device, the
ImageNet val/ directory). The change is recorded in the first commit's message for the changelog.

Also fixed (each had a failing test first)

  • Hydra's run directory was pinned to ./output, ignoring output_root: any command failed with
    FileExistsError where ./output was not creatable, including mode=help
  • set_cfg assigned a full config's overrided_cfg: {} back onto the instance, dropping override
    records and making mode=help under-report
  • exp_class no longer appears as an override
  • examples raise UnknownExperimentModeError instead of NotImplementedError
  • vit_tp builds the train loader only when a batch exists, instead of failing with ZeroDivisionError
  • tinyexp-run-with-redis refuses a launcher=ray command (the driver owns Redis there) and
    resolves -m the way the child process does, including torchrun -m and accelerate launch -m

Verification

  • 277 passed, 1 skipped (GPU-only)
  • make check, make docs-test (strict) pass
  • import tinyexp stays free of torch and wandb (subprocess assertion)
  • Every command in the run headers, README.md, SKILL.md and docs/*.md is validated
    statically against the config it targets

Known limits

  • The GPU paths (DDP/NCCL, FSDP, fp16, GPU tensor parallel) and multi-node Ray/Redis are verified
    as commands and configuration only, not executed.
  • The command check is static: a command can be legal yet no longer describe the example.

Zeming LI added 6 commits October 14, 2026 09:24
…t trials

Running the library from documentation alone exposed behavior that did not match what the docs
promised. Each fix below failed a test before it was made.

- Hydra's run directory was pinned to ./output and ignored output_root, so any command failed with
  FileExistsError where ./output was not creatable, including mode=help
- set_cfg assigned a full config's overrided_cfg: {} back onto the instance, dropping the records of
  fields processed before it and making mode=help under-report overrides
- exp_class no longer shows up as an override; store_and_run_exp fills it in
- examples raise UnknownExperimentModeError instead of NotImplementedError, so an unsupported mode
  lists the ones that are handled
- vit_tp builds the train dataloader only when a batch exists, instead of training zero steps and
  failing with ZeroDivisionError
- tinyexp-run-with-redis refuses a launcher=ray command, which already owns its Redis, and resolves
  -m the way the child process does (torchrun -m and accelerate launch -m included)

The evaluation mode is renamed from val to eval in the mnist and resnet examples, matching vit_tp.
mode=val is not kept as an alias and now reports the supported modes.
An agent that only reads the docs has to be able to call the library correctly, and the first
command it runs has to work.

- every public module, mixin and accelerator carries a docstring: responsibility, exports and a
  minimal usage example. The API page renders all of them instead of only the top-level package
- AGENTS.md gains a task-to-file index, the places not to explore, the order of preference for a
  change, and what mode=help does and does not check
- SKILL.md becomes the same index for an installed package, where AGENTS.md and docs/ are absent
- every example opens with a run header (Modes, Run, Env, Needs, Out), and the new
  tinyexp/examples/README.md maps requirements to examples
- Redis, W&B, sampling and logging helpers describe their units, defaults and lifecycle

tests/test_tinyexp_artifacts.py asserts that import tinyexp stays free of torch and wandb.
The documentation is the interface an agent works from, so it is now checked the same way code is.

- every command in a run header, README, SKILL and docs/*.md is validated against the config it
  targets (unknown keys and value types are rejected); example lists are discovered automatically,
  so a new example is covered without touching the test. The check is static: a command can be
  legal yet no longer describe what the example does
- every Modes value in a run header must be handled in the example's run()
- tests/tine_engine (a typo, referenced only by AGENTS.md) becomes tests/tiny_engine
- tinyexp/tiny_engine gains the missing __init__.py docstring
vit_tp_exp uses ``from __future__ import annotations``, so its config fields are annotated with
strings such as "RayCfg". OmegaConf resolves them with typing.get_type_hints, which on Python 3.9
looks up names only in the module globals, not in the class body where the nested config classes
live; Python 3.10 added the class namespace. Every vit_tp_exp command, mode=help included, failed
on 3.9 with "NameError: name 'RayCfg' is not defined". The bug predates this branch; the new
example smoke tests are the first to run vit_tp_exp on 3.9.

The ten config fields now name their type as VitTpExp.<Cfg>, which resolves from the module
globals on every supported version.
@zengarden
zengarden merged commit 1756a6d into dev Oct 14, 2026
8 checks passed
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