TrainingTask tells Dromeus what to train: how to build the model, what a batch looks like, how to compute the loss for each record, and which optimizer to use. Every node in a group builds the identical task from the same code. This guide builds the task from the example, a complete regression task in about 120 lines that imports only from dromeus.
Write the task
my_training.py
Model
model_factory builds a fresh model. It must create only public initial state, because it runs when the draft is written and on every node. Parameters must be dense float32; represent a scalar parameter as shape [1].
Batches
TensorBatchAdapter describes one batch. example is a public or synthetic batch of at least two records: Dromeus uses it to check the model and loss without reading anyone’s records. Batches can be tuples, lists or string-keyed dicts of tensors, with records on axis 0 and fixed shapes after it. Pad variable-length sequences to a declared length.
Loss
loss_per_record(model, batch) runs the forward pass and returns a differentiable float tensor of shape [B], one loss per record. Don’t call backward() or step an optimizer: Dromeus does both. Don’t mix information across records.
Optimizer
Usedromeus.Optimizer.sgd, dromeus.Optimizer.adam or dromeus.Optimizer.adamw. For any other PyTorch optimizer, pass an OptimizerRegistration. See Register an optimizer.
Shared definitions
The three definitions are short descriptions of what the code means. They become hashes in the draft, so every node must use the exact same text. Change the text whenever you change the meaning.implementation_hash identifies the code itself. dromeus.code_hash(...) hashes the files you pass, so pass every module your task depends on.
Report public metrics
Addpublic_evaluate to see model quality each round. It receives the model and returns a dict of named floats. It must use public data only, never a node’s own records:
Provide each node’s local data
Each node wraps its own records inLocalData:
data_identity, so use a stable identifier such as a hash of the data file.
To run a node from the command line, expose a function that returns both the task and the node’s data. The example reads the data path from an environment variable:
dromeus run --task my_training:setup uses it. Dromeus imports my_training from the current directory.
What Dromeus checks
Before any record is read, Dromeus checks the model on the publicexample batch. It supports custom containers of compatible operations, tied parameters, declared frozen parameters and immutable public buffers. It rejects BatchNorm, cross-record losses, unsafe trainable-layer buffers, uncontrolled model randomness, unbounded streams and changing record populations, naming the module path and the missing capability. There is no silent layer replacement.
See the TrainingTask reference for every field, token data and frozen weights.
Next
Run a group
Write the shared draft and start every node.