Is your feature request related to a problem? Please describe.
model_type currently owns too much:
- Train/generate recipe —
loss, predictor
- All metric wiring —
reported_metrics, diagnostic_metrics (while experiments separately own post_hoc_evaluator)
Because task scoring differs (STAR wants prediction EM; TinyGSM/IWSLT want post-hoc only), we clone model types (mlm_seq2seq vs mlm_tinygsm_seq2seq vs mlm_iwslt_seq2seq) that share the same loss/predictor and differ mostly in which metrics are listed. That creates a growing task × model config matrix for packaging, not for new generation modes.
We want a full cleanup: metrics composition becomes a first-class, experiment-owned surface (composable packages under each model family), and model_type shrinks to loss + predictor only. Generation modes stay coarse (unconditional / seq2seq / …).
Which component does this affect?
Describe the solution you'd like
Ownership
| Concern |
Owner |
loss, predictor |
model_type (model + mode only) |
| Atomic metric / post-hoc YAML |
Core: configs/lightning_train/metrics/, post_hoc_evaluator/ |
| Run-level composition of reported + diagnostic + post-hoc |
xlm-models/<family>/configs/metrics_bundle/ (or inline on experiments) |
Stable log fields (generated_text, refs) |
predictor to_dict contract |
Core must not host task×model bundles. src/xlm/configs/lightning_train/ keeps only reusable atomics. Family-qualified scoring bundles (with model-specific update_fns) live next to that family's experiments.
Config shape
# experiment (under xlm-models/<family>/configs/experiment/)
defaults:
- override /model_type: mlm_seq2seq # loss + predictor only
- /metrics_bundle: tinygsm # resolved from this family's config path
A bundle is a small @package _global_ config that fills reported_metrics / diagnostic_metrics / post_hoc_evaluator by composing existing atomics under metrics/ and post_hoc_evaluator/.
Reusable pieces (examples):
- Family
metrics_bundle/lm_train_basic.yaml — accumulated_loss on train/val/test lm
- Family
metrics_bundle/star_seq2seq.yaml — prediction EM + token accuracy with that family's update_fns
- Family
metrics_bundle/tinygsm.yaml — lm loss only + Gsm8kCodeEval post-hoc
- Family
metrics_bundle/iwslt14.yaml — lm loss only + iwslt14_mt post-hoc
- Optional ILM
metrics_bundle/diagnostics_stopping.yaml — length loss / token CE
Not one mega-YAML for the whole repo — one composition story so opening the experiment (or its bundle) shows the full scoring picture.
Migration
- Strip metrics from all
model_type YAMLs (keep loss/predictor/Harness).
- Add
xlm-models/<family>/configs/metrics_bundle/ packages for existing experiments; point experiments at them.
- Delete task forks that only existed for metrics (
mlm_tinygsm_seq2seq, *_iwslt_seq2seq, flexmdm_tinygsm_seq2seq, …) once unused.
- Update
docs/guide/metrics.md, eval.md, adding-a-model / adding-a-task.
- Experiments must compose a bundle explicitly (or a documented default) so forgetting metrics fails loudly or pulls only
lm_train_basic.
Worked example: TinyGSM × MLM (before → after)
Today
tinygsm_mlm uses a forked model type so prediction EM is absent; post-hoc lives on the experiment:
# xlm-models/mlm/configs/experiment/tinygsm_mlm.yaml (today)
defaults:
- override /datamodule: tinygsm_mlm
- override /model_type: mlm_tinygsm_seq2seq # fork of mlm_seq2seq minus EM
- override /model: rotary_transformer_mlm
# ...
post_hoc_evaluator:
_target_: xlm.tasks.composite_eval.CompositePostHocEvaluator
evaluators:
prediction:
_target_: xlm.tasks.tinygsm.Gsm8kCodeEval
# xlm-models/mlm/configs/model_type/mlm_tinygsm_seq2seq.yaml (today)
# Same loss/predictor as mlm_seq2seq, but only accumulated_loss — no prediction EM.
defaults:
- /metrics@reported_metrics.train.lm.accumulated_loss: accumulated_loss
- /metrics@reported_metrics.val.lm.accumulated_loss: accumulated_loss
- /metrics@reported_metrics.test.lm.accumulated_loss: accumulated_loss
loss:
_target_: mlm.loss_mlm.MLMLoss
predictor:
_target_: mlm.predictor_mlm.MLMPredictor
# ...
reported_metrics:
train/val/test.lm.accumulated_loss: ...
STAR uses shared mlm_seq2seq with EM baked into that model_type:
# star_easy_mlm.yaml (today)
defaults:
- override /model_type: mlm_seq2seq # includes prediction EM + token_accuracy
After
One seq2seq model_type for MLM; TinyGSM and STAR differ only by family-local metrics bundles.
# xlm-models/mlm/configs/model_type/mlm_seq2seq.yaml (after)
# @package _global_
lightning_module:
_target_: xlm.harness.Harness
loss:
_target_: mlm.loss_mlm.MLMLoss
predictor:
_target_: mlm.predictor_mlm.MLMPredictor
tokenizer: ${lightning_module:tokenizer}
noise_schedule: ${lightning_module:noise_schedule}
max_steps: ${block_size}
max_new_tokens: ${block_size}
top_k: 2
top_p: null
# no reported_metrics / diagnostic_metrics / metrics defaults here
tags:
model_type: mlm_seq2seq
# xlm-models/mlm/configs/metrics_bundle/lm_train_basic.yaml
# @package _global_
defaults:
- /metrics@reported_metrics.train.lm.accumulated_loss: accumulated_loss
- /metrics@reported_metrics.val.lm.accumulated_loss: accumulated_loss
- /metrics@reported_metrics.test.lm.accumulated_loss: accumulated_loss
reported_metrics:
train:
lm:
accumulated_loss:
prefix: train/lm
update_fn: mlm.metrics_mlm.mean_metric_update_fn
val:
lm:
accumulated_loss:
prefix: val/lm
update_fn: mlm.metrics_mlm.mean_metric_update_fn
test:
lm:
accumulated_loss:
prefix: test/lm
update_fn: mlm.metrics_mlm.mean_metric_update_fn
# xlm-models/mlm/configs/metrics_bundle/tinygsm.yaml
# @package _global_
defaults:
- lm_train_basic
# no prediction EM / token_accuracy
post_hoc_evaluator:
_target_: xlm.tasks.composite_eval.CompositePostHocEvaluator
evaluators:
prediction:
_target_: xlm.tasks.tinygsm.Gsm8kCodeEval
# xlm-models/mlm/configs/metrics_bundle/star_seq2seq.yaml
# @package _global_
defaults:
- lm_train_basic
- /metrics@reported_metrics.val.prediction.exact_match: seq2seq_exact_match
- /metrics@reported_metrics.test.prediction.exact_match: seq2seq_exact_match
- /metrics@reported_metrics.val.prediction.token_accuracy: seq2seq_token_accuracy
- /metrics@reported_metrics.test.prediction.token_accuracy: seq2seq_token_accuracy
reported_metrics:
val:
prediction:
exact_match:
prefix: val/prediction
update_fn: mlm.metrics_mlm.seq2seq_exact_match_update_fn
token_accuracy:
prefix: val/prediction
update_fn: mlm.metrics_mlm.seq2seq_token_accuracy_update_fn
test:
prediction:
exact_match:
prefix: test/prediction
update_fn: mlm.metrics_mlm.seq2seq_exact_match_update_fn
token_accuracy:
prefix: test/prediction
update_fn: mlm.metrics_mlm.seq2seq_token_accuracy_update_fn
# xlm-models/mlm/configs/experiment/tinygsm_mlm.yaml (after)
defaults:
- override /datamodule: tinygsm_mlm
- override /noise_schedule: dummy
- override /model_type: mlm_seq2seq # shared with STAR
- override /model: rotary_transformer_mlm
- /metrics_bundle: tinygsm # scoring story lives here (mlm config path)
# log_predictions unchanged (generated_text, answer, …)
# inline post_hoc_evaluator removed — owned by the bundle
# star_easy_mlm.yaml (after) — same model_type, different bundle
defaults:
- override /model_type: mlm_seq2seq
- /metrics_bundle: star_seq2seq
Delete after migration: mlm_tinygsm_seq2seq.yaml (and analogous forks for FlexMDM/ILM/IWSLT).
Same pattern for IWSLT × MLM: bundle = lm_train_basic + post_hoc_evaluator → iwslt14_mt; still model_type: mlm_seq2seq. FlexMDM gets xlm-models/flexmdm/configs/metrics_bundle/tinygsm.yaml with flexmdm.metrics_flexmdm.* update_fns — still no task×model matrix in core.
Optional: skip a metrics_bundle Hydra group and compose atomics directly in each experiment's defaults:; bundles are only for reuse (e.g. STAR easy/medium/hard).
Describe alternatives you've considered
- Partial move — only prediction reported metrics + post_hoc leave model_type; keep
accumulated_loss/diagnostics on model_type. Smaller diff, but scoring story remains split.
- Keep cloning model_types per task — status quo; does not scale.
- Host task×model bundles under
src/xlm/configs/lightning_train/metrics_bundle/ — rejected: core must not own family-qualified task scoring wiring.
- Single monolithic metrics YAML per experiment (no reusable family bundles) — clear per run, poor reuse across STAR easy/medium/hard.
Additional context
- Triggering cases: TinyGSM / IWSLT model_type forks vs STAR
*_seq2seq.
- Post-hoc is already experiment-scoped for TinyGSM/IWSLT; step metrics should join that story under family config paths.
- Step
update_fns stay model-specific inside family bundles (xlm-models/mlm/..., flexmdm/..., ilm/...), not inside model_type and not in core.
- Related: Harness diagnostic vs reported intent;
docs/guide/metrics.md.
Acceptance criteria
Is your feature request related to a problem? Please describe.
model_typecurrently owns too much:loss,predictorreported_metrics,diagnostic_metrics(while experiments separately ownpost_hoc_evaluator)Because task scoring differs (STAR wants prediction EM; TinyGSM/IWSLT want post-hoc only), we clone model types (
mlm_seq2seqvsmlm_tinygsm_seq2seqvsmlm_iwslt_seq2seq) that share the same loss/predictor and differ mostly in which metrics are listed. That creates a growing task × model config matrix for packaging, not for new generation modes.We want a full cleanup: metrics composition becomes a first-class, experiment-owned surface (composable packages under each model family), and
model_typeshrinks to loss + predictor only. Generation modes stay coarse (unconditional / seq2seq / …).Which component does this affect?
src/xlm/)xlm-models/)Describe the solution you'd like
Ownership
loss,predictormodel_type(model + mode only)configs/lightning_train/metrics/,post_hoc_evaluator/xlm-models/<family>/configs/metrics_bundle/(or inline on experiments)generated_text, refs)to_dictcontractCore must not host task×model bundles.
src/xlm/configs/lightning_train/keeps only reusable atomics. Family-qualified scoring bundles (with model-specificupdate_fns) live next to that family's experiments.Config shape
A bundle is a small
@package _global_config that fillsreported_metrics/diagnostic_metrics/post_hoc_evaluatorby composing existing atomics undermetrics/andpost_hoc_evaluator/.Reusable pieces (examples):
metrics_bundle/lm_train_basic.yaml—accumulated_losson train/val/testlmmetrics_bundle/star_seq2seq.yaml— prediction EM + token accuracy with that family'supdate_fnsmetrics_bundle/tinygsm.yaml— lm loss only +Gsm8kCodeEvalpost-hocmetrics_bundle/iwslt14.yaml— lm loss only +iwslt14_mtpost-hocmetrics_bundle/diagnostics_stopping.yaml— length loss / token CENot one mega-YAML for the whole repo — one composition story so opening the experiment (or its bundle) shows the full scoring picture.
Migration
model_typeYAMLs (keep loss/predictor/Harness).xlm-models/<family>/configs/metrics_bundle/packages for existing experiments; point experiments at them.mlm_tinygsm_seq2seq,*_iwslt_seq2seq,flexmdm_tinygsm_seq2seq, …) once unused.docs/guide/metrics.md,eval.md, adding-a-model / adding-a-task.lm_train_basic.Worked example: TinyGSM × MLM (before → after)
Today
tinygsm_mlmuses a forked model type so prediction EM is absent; post-hoc lives on the experiment:STAR uses shared
mlm_seq2seqwith EM baked into that model_type:After
One seq2seq model_type for MLM; TinyGSM and STAR differ only by family-local metrics bundles.
Delete after migration:
mlm_tinygsm_seq2seq.yaml(and analogous forks for FlexMDM/ILM/IWSLT).Same pattern for IWSLT × MLM: bundle =
lm_train_basic+post_hoc_evaluator→iwslt14_mt; stillmodel_type: mlm_seq2seq. FlexMDM getsxlm-models/flexmdm/configs/metrics_bundle/tinygsm.yamlwithflexmdm.metrics_flexmdm.*update_fns — still no task×model matrix in core.Optional: skip a
metrics_bundleHydra group and compose atomics directly in each experiment'sdefaults:; bundles are only for reuse (e.g. STAR easy/medium/hard).Describe alternatives you've considered
accumulated_loss/diagnostics on model_type. Smaller diff, but scoring story remains split.src/xlm/configs/lightning_train/metrics_bundle/— rejected: core must not own family-qualified task scoring wiring.Additional context
*_seq2seq.update_fns stay model-specific inside family bundles (xlm-models/mlm/...,flexmdm/...,ilm/...), not insidemodel_typeand not in core.docs/guide/metrics.md.Acceptance criteria
star_easy_mlmandtinygsm_mlmsharemodel_type: mlm_seq2seqand differ only bymetrics_bundle(underxlm-models/mlm/configs/).mlm_tinygsm_seq2seq(and parallel forks) removed or deprecated.model_typeYAMLs contain noreported_metrics/diagnostic_metrics/ metrics defaults.src/xlm/configs/lightning_train/.metrics_bundle/ experiment = all metrics + post-hoc; core = atomics only.