Consider a circuit as depicted in the image below.
Here, both a and b are four-qubit registers. The X-gate is applied to each qubit of a controlled by the corresponding qubit in b, which can be written as following pseudocode:
for i in range(len(a)):
a[i].x().controlled_by(b[i])
Currently, implementing such a loop in Bartiq is not straightforward, and might be achieved as follows:
Create a wrapper operation (say loop), which accepts a and b as inputs and outputs.
Place a node (say op) in loop with two single-qubit inputs.
Wrap op in split-merge pair, so that a single qubit is splitted from a and b and passed to op
Set custom aggregation of resources in loop, e.g. such that loop.n_toffs = len(a) * op.n_toffs (or generally, for additive resources set them to the sum of children resources multiplied by the number of repetitions in the loop.
The structure of such operation would then look like this:
What can we do?
If we find that this is an operation that the users commonly use, we should try coming up with an easier and less involved way of defining such loop in Bartiq.
For reference, this is the QREF yaml used to generate the diagram above:
Consider a circuit as depicted in the image below. Here, both
a
andb
are four-qubit registers. The X-gate is applied to each qubit ofa
controlled by the corresponding qubit inb
, which can be written as following pseudocode:Currently, implementing such a loop in Bartiq is not straightforward, and might be achieved as follows:
loop
), which acceptsa
andb
as inputs and outputs.op
) inloop
with two single-qubit inputs.op
in split-merge pair, so that a single qubit is splitted froma
andb
and passed toop
loop
, e.g. such thatloop.n_toffs = len(a) * op.n_toffs
(or generally, for additive resources set them to the sum of children resources multiplied by the number of repetitions in the loop.The structure of such operation would then look like this:
What can we do? If we find that this is an operation that the users commonly use, we should try coming up with an easier and less involved way of defining such loop in Bartiq.
For reference, this is the QREF yaml used to generate the diagram above: