Replicas
replicas allows you to run multiple instances of the same task, either in parallel or sequentially. This is useful for scaling workloads, running parameter sweeps, or executing benchmarks with different configurations.
Basic Usage
To create multiple identical copies of a task:
workflow:
name: demo
tasks:
- name: worker
replicas:
count: 4
policy: parallel
script:
- echo "I am replica $SFLOW_REPLICA_INDEX"
This creates 4 parallel workers (worker_0, worker_1, worker_2, worker_3), each running the same script.
Configuration Options
| Field | Type | Default | Description |
|---|---|---|---|
count | positive int or ${{ }} expression | null | Number of replicas to create. Has no numeric default — when omitted, the count is taken from the variables sweep size (below). 0/negative are rejected. |
policy | parallel | sequential | ${{ }} expression | parallel | How replicas are scheduled. May be an expression that resolves to parallel/sequential. |
variables | list of variable names | none | Variables to sweep over (creates a Cartesian product) |
count and variablesProvide count, variables, or both. With variables only, the replica count equals
the size of the swept domain(s). With both, the sizes must match (see Combining Count
and Variables).