micm_nlp.group¶
Run a group of runs described by one YAML – the framework half of a run.
A group config names unit configs and lists runs over them:
configs:
spt: ./tune.spt.yml
eval: ./test.eval.yml
runs:
- config: spt
name: spt_s11
seed: 11
overrides: {peft.encoder_hidden_size: 192}
separate_test: {config: eval, overrides: {}} # rare
source_group: joshi5 # anything else -> the runner
Every name a separate_test block references must itself be a key of
configs: – loading raises otherwise.
The file stem is the group name. For the selected entry this module loads the
unit config, applies the seed, then the overrides, fills the output block
(run dir + identity columns), writes a snapshot of the resolved config into the
run dir and calls the runner – run(config, ctx) – which does the science.
Result rows are written by the trainer, never here. The only scheduler
logic in the package is the SLURM_ARRAY_TASK_ID read in
select_indices() (info.json merely records SLURM* variables).
Attributes¶
Classes¶
Everything the framework knows about one run that is not the config. |
Functions¶
|
Set |
|
Pin |
|
The seed the config carries, if any -- read after overrides. |
|
Load and validate a group config. |
|
The runner callable from |
|
The selected entry as a resolved config plus its context. |
|
Run the selected entries of a group config. Returns the indices run. |
|
Run one unit config outside any group. |
|
The entry's unreserved scalar keys -- the axes this group varies over. |
|
Which entries to run: |
Module Contents¶
- class micm_nlp.group.RunContext¶
Everything the framework knows about one run that is not the config.
A frozen dataclass rather than keyword arguments so that adding a field never breaks a runner written against an older version.
The runner’s first argument is the run’s config;
test_config, when set, is the resolved second config a separate test phase runs under – the entry’sseparate_testblock, loaded, overridden and given its ownoutputblock (test_config.yml, prefixseparate_).- entry: dict[str, Any]¶
- extras: dict[str, Any]¶
- group: str | None¶
- index: int | None¶
- name: str | None¶
- output_dir: str | None¶
- test_config: micm_nlp.config.CONFIG | None¶
- micm_nlp.group.apply_override(config, dotted: str, value) None¶
Set
config.a.b.c = valuefrom'a.b.c'.An all-digit segment indexes a list (
…optimizer_grouped_parameters.0.lr). Strict: the attribute is read before it is written, so an unknown key raises instead of silently creating one.
- micm_nlp.group.apply_seed(config, seed: int | None) None¶
Pin
training_args.args.seed; aNoneseed leaves the config alone.
- micm_nlp.group.config_seed(config) int | None¶
The seed the config carries, if any – read after overrides.
- micm_nlp.group.load_group(path: str | pathlib.Path) dict[str, Any]¶
Load and validate a group config.
Paths in
configsresolve relative to the group file’s own directory, so a group is location-independent (absolute paths pass through).- Returns:
{'group': stem, 'configs': {name: absolute path}, 'runs': [...]}.- Raises:
ValueError – for any schema violation, naming the entry index.
- micm_nlp.group.load_runner(spec: str | None) Callable¶
The runner callable from
'package.module:attr'or'path/to/script.py[:attr]'.A path is loaded as a module by location (so the script must not do work at import time – the usual
if __name__ == '__main__':guard);attrdefaults torun.Nonemeans the default runner.
- micm_nlp.group.resolve_entry(group: dict[str, Any], index: int, cli_seed: int | None = None, extras: dict[str, Any] | None = None) tuple[micm_nlp.config.CONFIG, RunContext]¶
The selected entry as a resolved config plus its context.
Order: load, seed (entry, else CLI), overrides,
outputblock, output dir created with a snapshot of the resolved config and aninfo.jsoncarryingstarted, the output dir and the environment, so a run that dies before the trainer exists still says where and when it ran; thenseparate_testthe same way (no seed), with its ownoutputblock. The output dir isruns/groups/{group}/{time_id}_{name}; if it already exists (the same entry dispatched twice within one second) this raises rather than merging two runs into one directory.
- micm_nlp.group.run_group(group_path: str | pathlib.Path, runner: str | None = None, run_index: int | None = None, seed: int | None = None, extras: dict[str, Any] | None = None) list[int]¶
Run the selected entries of a group config. Returns the indices run.
- micm_nlp.group.run_unit(config_path: str | pathlib.Path, runner: str | None = None, extras: dict[str, Any] | None = None) None¶
Run one unit config outside any group.
Nothing to resolve – the trainer’s default output dir already puts the run under
runs/units/– so the context is built directly, withgroupleftNone: there is no group, and the stamped column says so.
- micm_nlp.group.scalar_columns(entry: dict[str, Any]) dict[str, Any]¶
The entry’s unreserved scalar keys – the axes this group varies over.
- micm_nlp.group.select_indices(n_runs: int, run_index: int | None) list[int]¶
Which entries to run:
SLURM_ARRAY_TASK_ID>run_index> all of them.Array dispatch is authoritative – a
--run-indexunder SLURM is ignored with a note, so an array can never be silently re-pointed. With neither, every entry runs in order, which is the whole group on a machine with no scheduler.
- micm_nlp.group.DEFAULT_RUNNER = 'micm_nlp.pipeline:run'¶
- micm_nlp.group.FRAMEWORK_COLUMNS = ('group', 'index', 'time_id', 'uuid4', 'metric_group', 'step')¶
- micm_nlp.group.RESERVED_KEYS = ('config', 'overrides', 'seed', 'name', 'separate_test')¶