The downstream evaluation pipeline in Modalities is a callback system that executes at configurable step intervals during the training loop.
The order of execution inside Trainer.train is:
checkpointing_callback: Saves the PyTorch/FSDP checkpoint to disk.downstream_evaluation_callback: (Optional) Runs external evaluation tools (like OLMES) on the newly created HF checkpoint.
Location: src/modalities/evaluator.py
The DownstreamEvaluator checks for the existence of an HF checkpoint, launches an evaluation script via a subprocess, tracks active processes, and syncs OLMES metrics to the active W&B run.
- Triggered if
num_train_steps_done % eval_interval == 0. - Only executes on
global_rank == 0. - Reads
last_checkpoint_info.jsonto find the latest checkpoint. - Checks if
{checkpoint_path}/hf_checkpointexists. If it does NOT exist, evaluation is skipped with a warning (assuming conversion failed or was disabled). - If the HF checkpoint exists, it formats the
olmes_command_templateand launches it asynchronously usingsubprocess.Popen(cmd, shell=True). - Process Tracking: Stores
(Popen, step, hf_model_dir)tuples inself.active_processes. - Graceful Exit:
wait_for_evaluations()iterates overactive_processes, calls.wait(), and syncs metrics after each evaluation completes. - W&B Metric Sync: Extracts
primary_scorefor each task alias from the OLMES output file and logs them to the activewandb.runasdownstream/{alias}at the correct training step. Gracefully skips if W&B is disabled or not installed.
The olmes_command_template string can use the following placeholders:
{hf_model_dir}: The path to the{checkpoint_path}/hf_checkpointdirectory.{tasks}: A space-separated string of the tasks provided in the config.{step}: The currentnum_train_steps_done.
downstream_evaluator:
component_key: downstream_evaluator
variant_key: default
config:
tokenizer:
instance_key: tokenizer
pass_type: BY_REFERENCE
tasks:
- "arc_challenge::olmes"
- "hellaswag::olmes"
eval_interval: 100
checkpoint_dir: ${settings.paths.experiments_root_path}/${settings.experiment_id}
global_rank: ${settings.cuda_env.global_rank}
olmes_command_template: "bash scripts/evaluation/run_olmes_sbatch.sh {hf_model_dir} '{tasks}' {step} 1024 1"