Skip to content

flow

Defines the structure and properties of a Qruise flow.

Schema

YAML
name: str
schedules: List[cronSchedule] | None
qubits: List[str]
couplings: List[Tuple[str, str]]
stages: stages
batch_groups: List[batchGroup] | None

Properties

Property Type Description References
name str Name of the flow.
schedules List[cronSchedule] | None Scheduled execution times for scheduled flows. cronSchedule
qubits List[str] List of qubits targeted by the flow.
couplings List[Tuple[str, str]] List of couplings targeted by the flow.
stages stages Flow stages. stages
batch_groups List[batchGroup] | None Definition of batch groups. batchGroup

Examples

The following examples highlight how to use the properties of the flow object itself, without going into detail about its nested objects. We’ll therefore exclude some of the details, replacing the missing fields with a commented-out ellipsis (# ...) and providing references to appropriate resources.

Basic flow

At its core, a flow can be defined by utilizing just the required properties, i.e. name, qubits, couplings, and stages. Suppose that we want to run a flow named Basic flow on a linear topology QPU with four qubits (i.e. Q1, Q2, Q3, and Q4), with couplings between two consecutive qubits. We can do so with the following snippet:

name: Basic flow
qubits: [Q1, Q2, Q3, Q4]
couplings:
  - [Q1, Q2]
  - [Q2, Q3]
  - [Q3, Q4]
stages:
  init:
    # ...
  experiments:
    # ...
  final:
    # ...

Flow with scheduled triggers

For scheduled flows, the scheduling triggers can be defined using the schedules property. For instance, assume that we want to run the flow introduced in the previous example every Monday and Wednesday at 02:00 UTC time. To do so, we can add two cron schedules to the flow definition, highlighted in the code block below:

name: Basic flow
schedules:
  - cron: 2 0 * * 1
  - cron: 2 0 * * 3
qubits: [Q1, Q2, Q3, Q4]
couplings:
  - [Q1, Q2]
  - [Q2, Q3]
  - [Q3, Q4]
stages:
  init:
    # ...
  experiments:
    # ...
  final:
    # ...

You can learn more about cron and its syntax in this article.

Flow with batch groups

If you plan on using batch groups, you must define them all using the flow.batch_groups property before they can be used in tasks and subflows. For instance, if you wanted to divide qubits for the flow introduced in Basic flow example into batch groups based on qubit ordinal number parity, you could do so with the following:

name: Basic flow
schedules:
  - cron: 2 0 * * 1
  - cron: 2 0 * * 3
qubits: [Q1, Q2, Q3, Q4]
couplings:
  - [Q1, Q2]
  - [Q2, Q3]
  - [Q3, Q4]
batch_groups:
  - name: qubits_by_parity
    qubits:
      - [Q1, Q3]
      - [Q2, Q4]
stages:
  init:
    # ...
  experiments:
    # ...
  final:
    # ...