rome¶
ROME: the RADICAL Optimizer for Model Enhancement.
ROME provides model improvement as a component you bolt onto a workflow you already have, rather than as a workflow you have to adopt. Three managers, each a configurable unit:
DataManager— gathers scored outputs from the workflow and builds them into a training dataset;Trainer— schedules training tasks and publishes checkpoints back to the workflow;Stream— runs inference and reward as persistent asynchronous streams and hot-swaps their weights when a checkpoint lands.
Manager wires the three together, so adoption is a few
API calls::
from radical.asyncflow import WorkflowEngine
import rome
flow = await WorkflowEngine.create(backend=backend)
manager = rome.Manager(
flow,
data_config=rome.DataConfig(min_samples=64),
trainer_config=rome.TrainerConfig(trainer=my_trainer),
stream_configs=[rome.StreamConfig(name="infer", process_func=my_infer)],
)
await manager.start()
MODEL_PATH_KEY
module-attribute
¶
Key holding the checkpoint the workflow should currently be using.
MODEL_VERSION_KEY
module-attribute
¶
Key holding the monotonically increasing checkpoint version.
Stream tasks poll this to decide when to hot-swap weights.
DataConfig
dataclass
¶
DataConfig(min_samples: int = 32, max_records: Optional[int] = None, score_key: str = 'score', min_score: Optional[float] = None, filter_func: Optional[Callable[[Dict[str, Any]], bool]] = None, dedup_key: Optional[Callable[[Dict[str, Any]], Any]] = None, sample_func: Optional[Callable[[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, sampling: str = 'all', shard_size: Optional[int] = None, consume_on_train: bool = True, metadata: Dict[str, Any] = dict())
Knobs for how the data manager turns raw scored outputs into a dataset.
Parameters:
-
min_samples(int, default:32) –How many unconsumed records must accumulate before the training manager considers a round possible. This is the "training starts automatically once enough data accumulates" threshold.
-
max_records(Optional[int], default:None) –Soft cap on corpus size. When exceeded, the oldest records are evicted on the next
DataManager.add.None(the default) keeps everything.Warning
On Dragon, leave this unset unless you have measured that you need it. Eviction is the only thing that pops from the corpus dictionary, and a Dragon
DDict.keys()scan silently returns a truncated list when another client pops concurrently — one measured scan returned 39 of 400 keys and reported success. With no evictions the corpus is never popped, so scans are exact and the training shard is complete. Seedocs/dragon.md. -
score_key(str, default:'score') –Field of a record holding its scalar quality score. Used by the built-in
top_ksampler and bymin_score. -
min_score(Optional[float], default:None) –Reject records scoring below this on the way in.
Noneaccepts all. -
filter_func(Optional[Callable[[dict], bool]], default:None) –Arbitrary admission predicate, applied after
min_score. ReturnFalseto drop the record. This is where IMPRESS-R plugs in its pLDDT/pTM/pAE thresholds. -
dedup_key(Optional[Callable[[dict], Any]], default:None) –Returns a hashable identity for a record. Records whose identity was already seen are dropped.
Nonedisables deduplication. -
sample_func(Optional[Callable[[List[dict]], List[dict]]], default:None) –Builds the training shard from the corpus. Overrides
sampling. -
sampling(str, default:'all') –Built-in shard builder:
'all'(default),'top_k'(bestshard_sizebyscore_key) or'recent'(newestshard_size). -
shard_size(Optional[int], default:None) –Number of records the built-in samplers draw.
Nonemeans no limit. -
consume_on_train(bool, default:True) –When
True(default) records handed to a training round count as consumed, so the next round waits formin_samplesnew records. The corpus itself is never deleted.
metadata
class-attribute
instance-attribute
¶
Extra fields stamped onto every record (run id, campaign name, ...).
DataManager
¶
DataManager(ddict: Namespace, config: Optional[DataConfig] = None)
Gathers scored outputs from the host workflow and creates a dataset.
The public surface is deliberately tiny — the slide deck's promise is that adopting ROME costs a few API calls:
add/add_batch— call from anywhere in the workflowget_dataset— what the training task trains onready_to_train/unconsumed_count— what the training manager polls
Parameters:
-
ddict(Namespace) –Shared state. Every ROME component in a run must be handed the same one (
Managerdoes this for you). -
config(DataConfig, default:None) –Defaults are used when omitted.
Source code in rome/data.py
consumed_count
property
¶
Number of records already folded into a completed training round.
unconsumed_count
property
¶
Records added since the last training round consumed the corpus.
model_version
property
¶
Version of the model currently published by the training manager.
Stamped onto each record so a later analysis can tell which model generated it — the "produced_under_version" idea from IMPRESS-R.
add
¶
Add one scored output to the corpus.
Everything is keyword-driven so the same call works for any domain::
rome.data.add(prompt=p, completion=c, score=reward)
rome.data.add(sequence=seq, pdb_path=pdb, score=plddt, pTM=ptm)
Parameters:
-
score(float, default:None) –The record's scalar quality. Stored under
config.score_key. -
uid(str, default:None) –Caller-supplied identity. Generated when omitted.
-
**fields(Any, default:{}) –Arbitrary payload, stored verbatim.
Returns:
-
Optional[str]–The record uid, or
Nonewhen the record was filtered out.
Source code in rome/data.py
add_batch
¶
Add many records at once; returns the uids that were accepted.
Source code in rome/data.py
get_records
¶
Every record in the corpus, oldest first.
Source code in rome/data.py
get_dataset
¶
Build the training dataset from the corpus.
Applies config.sample_func when set, otherwise the built-in
config.sampling strategy.
Parameters:
-
as_hf_dataset(bool, default:False) –Return a
datasets.Datasetinstead of a list of dicts. Requiresdatasetsto be installed; the LLM trainer needs it, the MPNN trainer does not, which is why it is opt-in.
Source code in rome/data.py
ready_to_train
¶
mark_consumed
¶
Record that count records were used for training.
Called by the training manager when a round completes. Defaults to the
whole current corpus. No-op when config.consume_on_train is off, so
a workflow that wants to retrain on everything every round can.
Source code in rome/data.py
clear
¶
Drop the entire corpus. Returns the number of records removed.
Manager
¶
Manager(asyncflow: Optional[WorkflowEngine] = None, *, backend: Any = None, data_config: Optional[DataConfig] = None, trainer_config: Optional[TrainerConfig] = None, stream_configs: Optional[List[StreamConfig]] = None, ddict: Optional[DDict] = None, ddict_kwargs: Optional[Dict[str, Any]] = None, auto_reload_streams: bool = True)
Manager class for handling tasks and data in the ROME framework.
Parameters:
-
asyncflow(WorkflowEngine, default:None) –The engine ROME submits its tasks to. Pass the host workflow's — for an IMPRESS campaign that is
impress_manager.flow, available once the manager has started — and ROME's rounds and streams are scheduled against the same allocation as the campaign's own tasks.Leave it
Noneand ROME builds its own engine atstartand shuts it down atstop. That is the right choice when ROME should manage its own tasks independently of the host, or when the host creates its engine internally and does not hand one out. -
backend(optional, default:None) –Execution backend for the engine ROME builds for itself. Ignored when
asyncflowis given. When both are omitted, asyncflow falls back to a local, in-process backend — fine for tests and CPU work, but wrong for a GPU fine-tune: a training round then runs inside this driver process, so the model's CUDA context stays resident for the whole campaign instead of being freed when the round ends. Pass a process-based backend (DragonExecutionBackendV3on Delta, or aConcurrentExecutionBackend(ProcessPoolExecutor())) so each round runs in a task process that releases its VRAM on exit. Seeexamples/impress_r/run_protein_binding_rome.py. -
data_config(DataConfig, default:None) –How scored outputs become a dataset, and how much data a training round needs.
-
trainer_config(TrainerConfig, default:None) –Which training algorithm to run and when. Required before training can start; may also be passed to
start. -
stream_configs(list[StreamConfig], default:None) –Inference and reward streams to bring up at
start. Streams can equally be started later viamanager.stream.start(...), or omitted entirely by workflows that only want the data + training halves. -
ddict(DDict, default:None) –Share the host workflow's dictionary instead of allocating one. ROME namespaces all of its keys, so sharing is safe, and passing the DDict object into a task is all it takes to reach it from another node — Dragon attaches the receiving process automatically.
-
ddict_kwargs(dict, default:None) –Passed to
DDict(...)when ROME allocates its own. Worth setting on a real campaign: Dragon's defaulttotal_memis 3 MiB, which a corpus of a few thousand records will exhaust, so ROME asks forDEFAULT_DDICT_KWARGSinstead. -
auto_reload_streams(bool, default:True) –Wire published checkpoints to stream reloads (default). Turn off if the workflow would rather decide when inference switches models.
Source code in rome/manager.py
model_version
property
¶
Version of the newest published checkpoint (0 = never trained).
start
async
¶
start(trainer_config: Optional[TrainerConfig] = None, stream_configs: Optional[List[StreamConfig]] = None) -> 'Manager'
Start the ROME manager: bring up the streams, then the trainer.
Order matters. Streams come up first so they are already draining requests by the time the first checkpoint lands, and the checkpoint hook is registered before the trainer can fire a round — otherwise a very fast first round could publish weights nobody is listening for.
Source code in rome/manager.py
stop
async
¶
Stop the ROME manager.
Trainer first: an in-flight round is waited out rather than cancelled, and letting the streams keep serving while it finishes means the final checkpoint still reaches them.
Source code in rome/manager.py
add_training_data
¶
add_training_data(prompt: Any = None, completion: Any = None, score: Optional[float] = None, **fields: Any) -> Optional[str]
Add training data to the manager, from anywhere in the workflow.
The prompt/completion/score triple is the LLM-shaped
convenience form; any other domain passes keywords instead::
rome.add_training_data(sequence=seq, pdb_path=pdb, score=plddt)
Returns the record uid, or None when the data manager's filters
rejected the sample.
Source code in rome/manager.py
add_training_batch
¶
get_training_dataset
¶
start_training
async
¶
Trigger a training round by hand; returns the new checkpoint path.
get_training_status
¶
get_training_status() -> TrainerStatus
get_current_model
¶
ready_to_train
¶
submit
¶
get_outputs
¶
reload_model
async
¶
Push a checkpoint into the running streams.
get_stream_status
¶
get_stream_status(stream: Optional[str] = None) -> List[StreamStatus]
report
¶
One-call snapshot of all three components.
Source code in rome/manager.py
Stream
¶
Stream(ddict: Namespace, asyncflow: Any)
Stream manager: owns every inference and reward stream in a run.
Each stream group gets its own DDict for requests and results, rather than sharing the manager's. A dictionary has no server-side prefix query, so a scan lists every key in it and filters client-side; sharing one dictionary would make the cost of a replica's poll grow with the corpus, coupling two rates that have nothing to do with each other. Per group, a scan covers only that group's in-flight work, which does not accumulate.
The manager's own dictionary is still used, read-only from here, for the published checkpoint — that is what the streams reload from.
Parameters:
-
ddict(Namespace) –ROME's shared state, holding the published checkpoint.
-
asyncflow(WorkflowEngine) –Engine the stream tasks are submitted to, as services.
Source code in rome/stream.py
start
async
¶
start(config: StreamConfig) -> List[StreamTask]
Start config.num_streams persistent tasks for one stream group.
Call it once per group — typically an inference group and a reward group — against the same manager.
Source code in rome/stream.py
submit
¶
Queue one request and return its id.
Requests round-robin across the group's replicas, so every task gets an even share without needing a shared claim protocol.
Source code in rome/stream.py
submit_batch
¶
get_outputs
¶
Collect finished results, oldest first.
Parameters:
-
stream(str, default:None) –Which group to read. Defaults to the only started group.
-
consume(bool, default:True) –Remove results as they are read (default). Pass
Falseto peek without draining — useful for progress displays.
Source code in rome/stream.py
get_output
async
¶
get_output(request_id: str, stream: Optional[str] = None, timeout: Optional[float] = None, poll_interval: float = 0.05) -> Optional[Dict[str, Any]]
Await one specific request's result.
Returns None on timeout rather than raising, so a caller polling
several requests can keep going.
Source code in rome/stream.py
pending
¶
signal_reload
¶
signal_reload(model_path: Optional[str] = None, stream: Optional[str] = None) -> List[StreamTask]
Raise the reload flag on the targeted tasks without waiting.
Each task swaps weights between batches on its own schedule, so this never interrupts an in-flight inference call.
Source code in rome/stream.py
reload_model
async
¶
reload_model(model_path: Optional[str] = None, stream: Optional[str] = None, wait_for_reload: bool = True, timeout: float = 300.0) -> None
Tell the streams to pick up new weights.
Called explicitly by the workflow, or implicitly by on_checkpoint
when the training manager publishes. model_path=None means "reload
whatever is currently published".
Source code in rome/stream.py
on_checkpoint
¶
Training-manager hook: a new checkpoint just landed.
Registered by Manager, so publishing a checkpoint
and hot-swapping the streams are the same event. Non-blocking by design.
Source code in rome/stream.py
get_status
¶
get_status(stream: Optional[str] = None) -> List[StreamStatus]
Status of every task, or of one group's tasks.
report
¶
Per-group summary for dashboards and logs.
Source code in rome/stream.py
stop
async
¶
Signal the stream tasks to stop, optionally waiting for them to finish.
Stopping does not release the group dictionaries — results drained on
the way down stay readable, which is the whole point of
drain_on_stop. Call close once those have been collected.
Source code in rome/stream.py
close
¶
Release the dictionaries this manager allocated for its groups.
Separate from stop so a workflow can collect what the streams
drained on the way down before their storage goes away. Idempotent.
Source code in rome/stream.py
StreamConfig
dataclass
¶
StreamConfig(name: str = 'default', kind: StreamKind = INFERENCE, process_func: Optional[Callable] = None, load_func: Optional[Callable] = None, stream_func: Optional[Callable] = None, model_path: Optional[str] = None, num_streams: int = 1, num_gpus: int = 1, num_nodes: int = 1, task_description: Optional[Dict[str, Any]] = None, as_service: bool = True, batch_size: int = 1, poll_interval: float = 0.1, auto_reload: bool = True, drain_on_stop: bool = True, on_output: Optional[Callable[[Dict[str, Any]], None]] = None, load_kwargs: Dict[str, Any] = dict(), ddict: Any = None, ddict_kwargs: Optional[Dict[str, Any]] = None)
Configuration for a group of identical stream tasks.
Parameters:
-
name(str, default:'default') –Identifies the stream group. Requests are routed by name, so a workflow can run several independent groups side by side.
-
kind(StreamKind, default:INFERENCE) –INFERENCEorREWARD. -
process_func(Callable, default:None) –The workflow's per-batch work:
(inputs, ctx) -> results, whereinputsis a list of payloads andresultsis a list of the same length. May be sync or async. A plain(inputs)function is accepted too, so existing code needs no signature change. -
load_func(Optional[Callable], default:None) –(model_path, ctx) -> model, called at startup and on every reload. The result becomesctx.model. Omit for streams that need no model (most reward functions). -
stream_func(Optional[Callable], default:None) –Full override:
(ctx) -> None, replacing the managed loop. The implementation must honourctx.should_stop()and callctx.maybe_reload()between batches.process_funcis ignored. -
model_path(Optional[str], default:None) –Initial checkpoint. When
Nonethe stream starts from whatever the training manager has already published, if anything. -
num_streams(int, default:1) –How many identical tasks to run for this group.
-
num_gpus(int, default:1) –Per-task resources, turned into an asyncflow
task_description. -
num_nodes(int, default:1) –Per-task resources, turned into an asyncflow
task_description. -
task_description(Optional[dict], default:None) –Backend-specific resource request, passed through to asyncflow verbatim. Overrides
num_gpus/num_nodeswhen set. -
as_service(bool, default:True) –Submit as an asyncflow service task (default). Streams outlive individual workflow stages, which is exactly what services are for.
-
batch_size(int, default:1) –Maximum requests handed to
process_funcin one call. -
poll_interval(float, default:0.1) –Seconds to idle when the request queue is empty.
-
auto_reload(bool, default:True) –Watch the published model version and reload without being asked — "the model is reloaded when the Stream Manager sees that a new model checkpoint is available". Turn off to reload only on an explicit
Stream.reload_model. -
drain_on_stop(bool, default:True) –Finish already-queued requests before stopping.
-
on_output(Optional[Callable[[dict], None]], default:None) –Called with each output record as it is produced. The manager uses this to pipe reward-stream results into the data manager.
-
load_kwargs(dict, default:dict()) –Extra keyword arguments for
load_func. -
ddict(DDict, default:None) –Dictionary backing this group's request and result queues. When
Nonethe stream manager allocates one and destroys it on stop. -
ddict_kwargs(dict, default:None) –Passed to
DDict(...)when the manager allocates the group's dictionary. Defaults toDEFAULT_STREAM_DDICT_KWARGS.
StreamContext
¶
StreamKind
¶
Bases: str, Enum
What a stream is for.
Both kinds run the same loop; the distinction is for routing and reporting. It matters because reward streams are the ones whose outputs feed the data manager.
StreamStatus
¶
Bases: Enum
Status of a single inference/reward stream task.
StreamTask
¶
StreamTask(index: int, config: StreamConfig, ddict: Namespace, root: Namespace, task_fut: Any = None)
One persistent inference or reward stream task.
Holds the asyncflow future for the running task plus its control signals. Status lives in the DDict rather than on the object, so a manager on another node can read it.
Source code in rome/stream.py
ddict
instance-attribute
¶
This stream group's slice of the DDict (requests, results, status).
claim
¶
Pop pending requests for this task.
Popping is what makes a request owned: each key is removed by exactly one claimer, so replicas never double-process a request.
Source code in rome/stream.py
maybe_reload
¶
Load the newest published checkpoint into this task, if there is one.
Source code in rome/stream.py
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>.
Source code in rome/train/base.py
Trainer
¶
Trainer(ddict: Namespace, data: DataManager, asyncflow: Any, config: Optional[TrainerConfig] = None)
Training manager in the ROME framework.
Parameters:
-
ddict(Namespace) –Shared state — the same DDict view every other ROME component uses.
-
data(DataManager) –Corpus the training rounds draw from.
-
asyncflow(WorkflowEngine) –Engine training tasks are submitted to.
-
config(TrainerConfig, default:None) –May also be supplied later to
start.
Source code in rome/trainer.py
model_version
property
¶
Version of the newest published checkpoint (0 = never trained).
train_task
property
¶
train_task: TrainTask
The configured trainer, wrapping a bare callable if needed.
start
async
¶
start(config: Optional[TrainerConfig] = None) -> Optional[Task]
Start the training manager.
With auto_train on this spawns the polling loop that fires a round
whenever the corpus crosses min_samples. With it off the manager
simply becomes available for manual train calls.
The poll loop is a plain asyncio task in the manager's own process — only the training rounds themselves go to the execution backend.
Source code in rome/trainer.py
stop
async
¶
Stop the training manager.
An in-flight round is not cancelled — killing a half-finished fine-tune would leave a torn checkpoint — so this waits it out instead.
Source code in rome/trainer.py
train
async
¶
Run one training round now — the workflow's manual trigger.
Returns the path to the new checkpoint, or None when the round was
skipped because the corpus was not ready (pass force=True to train
anyway) or another round is already in flight.
Failures propagate: a manual call is expected to surface its own
errors, unlike the auto-train loop which records them in
status.
Source code in rome/trainer.py
on_checkpoint
¶
get_status
¶
get_status() -> TrainerStatus
get_current_model
¶
report
¶
One-call summary for dashboards and logs.
Source code in rome/trainer.py
TrainerConfig
dataclass
¶
TrainerConfig(trainer: Any = None, checkpoint_dir: str = './rome_checkpoints', auto_train: bool = True, max_rounds: Optional[int] = None, poll_interval: float = 5.0, result_fallback_seconds: Optional[float] = 60.0, task_description: Optional[Dict[str, Any]] = None, train_kwargs: Dict[str, Any] = dict(), on_checkpoint: Optional[Callable[[str, int], None]] = None, stop_on_failure: bool = False, max_consecutive_failures: Optional[int] = None)
Configuration for the training manager.
Parameters:
-
trainer(TrainTask or Callable, default:None) –The training algorithm. A bare callable
(dataset, output_dir, **kwargs) -> checkpoint_pathis wrapped in aFunctionTrainerautomatically. -
checkpoint_dir(str, default:'./rome_checkpoints') –Root for published checkpoints; rounds land in
<checkpoint_dir>/<trainer name>/v<version>. -
auto_train(bool, default:True) –Poll the data manager and fire a round as soon as enough data has accumulated. Turn off to drive training purely by hand.
-
max_rounds(Optional[int], default:None) –Stop after this many completed rounds.
Noneruns until stopped. -
poll_interval(float, default:5.0) –Seconds between data-threshold checks in the auto-train loop.
-
result_fallback_seconds(Optional[float], default:60.0) –Grace period before a round whose checkpoint is already on disk is treated as finished even though the execution backend never delivered its result.
Nonedisables the fallback and waits on the backend forever.This exists because of a real backend defect, not as a convenience. Dragon pre-registers a running task's result key, so reading that key blocks rather than raising
KeyError. rhapsody's monitor sweeps its outstanding tasks in order, so a task that never completes -- which is exactly what a ROME inference stream is -- blocks the sweep on its own key forever, and every result behind it, including a finished training round, is never delivered. Confirmed by direct measurement::manager(0)['0-0'] -> STILL BLOCKED after 20s # the stream service manager(0)['0-1'] -> returned in 0.12s # the finished roundThe round itself is fine: it runs, and its checkpoint is on disk. Only the notification is lost, so the checkpoint is the sounder signal.
-
task_description(Optional[dict], default:None) –Backend-specific resource request forwarded to asyncflow. When
None, one is derived from the trainer'sgpus/nodes. -
train_kwargs(dict, default:dict()) –Extra keyword arguments forwarded to every
TrainTask.traincall. -
on_checkpoint(Optional[Callable[[str, int], None]], default:None) –Called with
(checkpoint_path, version)after each successful round. The manager registers the stream manager's hot-swap hook here. -
stop_on_failure(bool, default:False) –Move to
FAILEDand end the auto-train loop when a round raises. WhenFalse(default) the failure is recorded and polling continues. -
max_consecutive_failures(Optional[int], default:None) –Stop the auto-train loop after this many consecutive failed rounds.
None(default) retries indefinitely. Resets to zero on a successful round.
TrainerStatus
¶
Bases: Enum
Status of the ROME training manager.
NOT_ENOUGH_DATA and WAITING are both idle, but they answer different
questions: the first says a round is not currently possible, the second
says it is possible and about to start.
Namespace
¶
Bases: MutableMapping
A prefixed view over a Dragon DDict (or any mapping).
Every operation goes through a handle owned by the calling thread — see
thread_handle — so views may be shared freely across the manager
and its stream workers.
Parameters:
-
ddict(MutableMapping) –The shared dictionary. Normally a
dragon.data.ddict.DDict; any mapping works, which is what makes the components unit-testable. -
prefix(str, default:'') –Prepended to every key this view touches.
Source code in rome/utils.py
namespace
¶
Derive a child view: ns.namespace("record") -> keys record|….
Source code in rome/utils.py
get
¶
Read key, returning default when absent.
Goes through __getitem__ rather than DDict.get so the behaviour
is identical whichever mapping is underneath.
Source code in rome/utils.py
pop
¶
Remove key and return its value.
This is ROME's claim protocol: whoever pops a key owns that item, so two stream replicas draining the same queue never process a request twice. Correctness rests on the underlying pop being atomic, which is why it delegates rather than doing read-then-delete — a Dragon DDict resolves the contention manager-side, and measurably: four threads racing over 120 keys claim 120 with zero duplicates.
The single-argument form is deliberate. dict.pop(k, default)
returns the default while DDict.pop(k, default) raises
DDictKeyError regardless, so asking for the default would behave
differently on the two backings; catching KeyError (which
DDictKeyError subclasses) behaves the same on both.
Source code in rome/utils.py
increment
¶
Bump an integer counter and return the new value.
Only safe when a single component owns the counter — ROME keeps to
that (the training manager owns model_version, and so on).
Source code in rome/utils.py
keys
¶
Namespace-relative keys, optionally filtered by a further prefix.
Source code in rome/utils.py
items
¶
(key, value) pairs under prefix, skipping keys that vanish mid-scan.
Source code in rome/utils.py
drain
¶
Pop and return up to limit (key, value) pairs under prefix.