rome.train¶
Training algorithms available to ROME's training manager.
Adding one is a single task: subclass TrainTask,
implement train(dataset, output_dir) -> checkpoint_path, and hand the
instance to a TrainerConfig. The LLM/GRPO trainer here is
imported lazily so a workflow that does not use it never pays for TRL.
The ProteinMPNN trainer is not here: it is an IMPRESS-R integration, not
framework core, so it ships with that example —
examples/impress_r/mpnn.py (from examples.impress_r.mpnn import
ProteinMPNNTrainer, ProteinMPNNConfig).
FunctionTrainer
¶
FunctionTrainer(func, *, gpus: int = 1, nodes: int = 1, name: Optional[str] = None, wants_hf_dataset: bool = False)
Bases: TrainTask
Adapter that turns a bare function into a TrainTask.
The cheapest possible way to plug an existing training script into ROME::
rome = Manager(trainer=FunctionTrainer(my_finetune, gpus=4))
where my_finetune(dataset, output_dir, **kwargs) -> checkpoint_path.
Source code in rome/train/base.py
as_command
¶
Optionally run this round as an executable task instead of a function.
Return (shell_command, checkpoint_path) to have the training manager
submit shell_command as an executable task — a subprocess on the
allocation's resources, the way IMPRESS submits its wrapper scripts —
rather than pickling train into a worker. checkpoint_path is
where the command will write the checkpoint, since an executable task's
return value is not the path.
Return None (the default) to run train in-process as a
function task. A GPU fine-tune should prefer the command form: the
subprocess exits when the round ends, releasing its VRAM.
Completion contract: the command MUST write a file named
train_complete (rome.trainer.TRAIN_COMPLETE_MARKER) into its
output_dir as its final action, after the checkpoint is safely on
disk. The training manager polls for that marker to detect the round
finished, because on Dragon a task can run to completion and never
resolve its future (a running service blocks result delivery — see
docs/dragon.md). The marker, not the checkpoint, is the signal: with
publish-in-place the checkpoint path already exists from the prior round.
Source code in rome/train/base.py
validate
¶
Raise if dataset cannot be trained on.
Called by the training manager before a task is scheduled, so an unusable corpus fails fast on the manager instead of burning an HPC allocation. The default check is just "not empty".
Source code in rome/train/base.py
prepare_output_dir
staticmethod
¶
Standard checkpoint layout: <base_dir>/<name>/v<version>.
Source code in rome/train/base.py
TrainTask
¶
Abstract base for ROME training algorithms.
Subclasses implement train. Everything else — when to run, where
the data comes from, who hears about the new checkpoint — belongs to the
training manager.
Parameters:
-
gpus(int, default:1) –GPUs a single training task needs. The training manager forwards this to the workflow engine when submitting the task.
-
nodes(int, default:1) –Nodes a single training task needs.
-
name(str, default:None) –Human-readable label used in status reporting and checkpoint paths. Defaults to the class name.
Source code in rome/train/base.py
wants_hf_dataset
class-attribute
instance-attribute
¶
Set on subclasses that want a datasets.Dataset rather than a list.
train
¶
Train on dataset and write a checkpoint under output_dir.
Parameters:
-
dataset(Any) –Whatever
rome.data.DataManager.get_datasetproduced — a list of record dicts by default, or adatasets.Datasetwhen the trainer asked for one viawants_hf_dataset. -
output_dir(str) –Directory the checkpoint should be written to. Already created.
-
**kwargs(Any, default:{}) –Forwarded from
rome.trainer.Trainer.train; implementations should tolerate unknown keys.
Returns:
-
str–Path to the checkpoint the stream manager should load. Returning
output_diritself is the common case.
Source code in rome/train/base.py
as_command
¶
Optionally run this round as an executable task instead of a function.
Return (shell_command, checkpoint_path) to have the training manager
submit shell_command as an executable task — a subprocess on the
allocation's resources, the way IMPRESS submits its wrapper scripts —
rather than pickling train into a worker. checkpoint_path is
where the command will write the checkpoint, since an executable task's
return value is not the path.
Return None (the default) to run train in-process as a
function task. A GPU fine-tune should prefer the command form: the
subprocess exits when the round ends, releasing its VRAM.
Completion contract: the command MUST write a file named
train_complete (rome.trainer.TRAIN_COMPLETE_MARKER) into its
output_dir as its final action, after the checkpoint is safely on
disk. The training manager polls for that marker to detect the round
finished, because on Dragon a task can run to completion and never
resolve its future (a running service blocks result delivery — see
docs/dragon.md). The marker, not the checkpoint, is the signal: with
publish-in-place the checkpoint path already exists from the prior round.
Source code in rome/train/base.py
validate
¶
Raise if dataset cannot be trained on.
Called by the training manager before a task is scheduled, so an unusable corpus fails fast on the manager instead of burning an HPC allocation. The default check is just "not empty".
Source code in rome/train/base.py
prepare_output_dir
staticmethod
¶
Standard checkpoint layout: <base_dir>/<name>/v<version>.