subflow
Specifies a subflow for a flow, task, or another subflow.
Schema¶
Properties¶
Property | Type | Description | References |
---|---|---|---|
name |
str |
Name of the task. | |
conditions |
executionConditions | None |
Conditions for execution of the task. | executionConditions |
retry |
retryStrategy | None |
Task failure retry strategy. | retryStrategy |
batch_group |
str | None |
Name of the batch group that the task should use. | |
tasks |
List[task | subflow] |
List of tasks to be executed within the subflow. | task, subflow |
dependencies |
List[str] | None |
List of task dependencies. |
Remarks¶
The batch_group
property must be either empty or reference one of the batch groups defined by the flow via the flow.batch_groups
property. If it is not specified, the subflow will be:
- run for each qubit separately if it is specified in the
flow.stages.experiments.qubits
, - run once if it is specified elsewhere.
The batch groups that a subflow references must be defined in the flow.batch_groups
property.
Examples¶
Grouping related tasks¶
At its core, a subflow can be used to simply group tasks together. For instance, if you have the following measurements to perform:
- a T1 measurement, defined in
t1.ipynb
, - a T2 echo measurement, defined in
t2-echo.ipynb
, - a T2
* , defined inmeasurement t2-star-ramsey.ipynb
,
you can group them all in a subflow called t-measurements
:
name: t-measurements
tasks:
- name: t1
- name: t2-echo
dependencies:
- t1
- name: t2-star-ramsey
dependencies:
- t2-echo
Conditional execution¶
Subflows can be used to group tasks that share the same conditions for conditional execution. Continuing with the subflow from the previous example, you might want to use a skip-t-measurements
flag to skip the t-measurements
subflow. To do this, you can specify the conditions
property of the subflow:
name: t-measurements
conditions:
skip_on_flags:
- skip-t-measurements
tasks:
- name: t1
- name: t2-echo
dependencies:
- t1
- name: t2-star-ramsey
dependencies:
- t2-echo
Timeout and retry¶
Similar to single tasks, a subflow can specify its retry strategy, in which case it applies to the entire subflow as a whole. For instance, if you want a subflow to be retried at least 3 times after a failure (for a total of 4 attempts at executing it), you can do so with the following:
name: t-measurements
retry:
limit: 3
tasks:
- name: t1
- name: t2-echo
dependencies:
- t1
- name: t2-star-ramsey
dependencies:
- t2-echo
Parallel execution using batch groups¶
If you are running a subflow in the experiments.qubits
stage, you can specify batch groups for the subflow as a whole. For instance, if you have a batch group called parallel-qubits
defined in the flow, you can apply it to the subflow as a whole by using the batch_group
property: