- Compilation/
Phase gradient
Phase gradient
Here we take a look at a modification of the implementation of
rotations via phase gradients to implement controlled
rotations instead. In particular, we will look at constructions that leverage
TemporaryAND, or elbow
gates to attach control structure to the individual components.
We will use the alternative construction provided at the end of the
rotations tab.
Where to put the control nodes?
Naively, controlling a subcircuit as a whole requires us to attach a corresponding control node to each component in the subcircuit. However, there are multiple properties of the rotation implementation via phase gradients that allow us to get away with fewer control nodes.
As we will see, attaching controls to the angle loading stage is cheaper than attaching them to the adder.
Controlling a compute-uncompute pattern
As discussed on the compute-uncompute page,
controlling a pattern with the structure U^\dagger V U can be done by only attaching the control
node(s) to the middle V gate. The phase gradient construction has exactly this structure,
where U is the angle-loading operation combined with the
fan-out that modifies the adder into a subtractor as discussed at the
end of the rotations tab.
V in turn is the
SemiAdder itself.
Thus, our first option for controlling the phase gradient implementation is
|ψ> ┬: ──────────╭●───────────────────┤ ┬ ≈C-R_Z(θ)|ψ>
╰: ───────╭○─│──────────╭○────────┤ ╯
|0> : ─╭load─│──├SemiAdder─│──╭load†─┤ |0>
|0> : ─├load─│──├SemiAdder─│──├load†─┤ |0>
|0> : ─╰load─├──├SemiAdder─├──╰load†─┤ |0>
╭: ───────├X─├SemiAdder─├X────────┤ ╮
|∇_b> ┤: ───────├X─├SemiAdder─├X────────┤ ├ |∇_b>
╰: ───────╰X─╰SemiAdder─╰X────────┤ ╯
Adding the first control node to Gidney's
SemiAdder costs b
Toffoli
gates [2], which can be
implemented with 7b T gates, or 4b T gates by using
TemporaryAND
gates and an additional auxiliary wire. Note that this additional wire is not already available in the
context above and its inclusion truly increases the required work space for the overall implementation.
Adding further c-1 control nodes can be done using c-1 elbow gates and c-1 auxiliary wires, for a total of 7b+4c-1 T gates and c-1 auxiliary wires, or 4b+4c-1 T gates and c auxiliary wires.
Leveraging the fixed input state
Another property of the phase gradient rotation implementation is its specific input state on all
qubits except the target of the rotation. In particular, the
SemiAdder
(and its controlled modification into a subtractor) reduces to the identity
if we skip the angle encoding before it. This implies that if we want to control the
entire construction, we can attach the control nodes to the loaders instead, activating the
phase-creating
SemiAdder
only if the control node is in the state |1\rangle.
The resulting circuit looks like this:
|ψ> ┬: ─╭●─────────────────────╭●─────┤ ┬ ≈C-R_Z(θ)|ψ>
╰: ─│─────╭○────────────╭○─│──────┤ ╯
|0> : ─├load─│──╭SemiAdder─│──├load†─┤ |0>
|0> : ─├load─│──├SemiAdder─│──├load†─┤ |0>
|0> : ─╰load─├──├SemiAdder─├──╰load†─┤ |0>
╭: ───────├X─├SemiAdder─├X────────┤ ╮
|∇_b> ┤: ───────├X─├SemiAdder─├X────────┤ ├ |∇_b>
╰: ───────╰X─╰SemiAdder─╰X────────┤ ╯
Adding a single control node to the data loading yields a fan-out, as we used
at first for the uncontrolled rotation.
Once we add more control nodes, we obtain non-Clifford gates.
A useful implementation for this again is based on
TemporaryAND gates
and comes at the cost of 4(c-1) T gates and (c-1) auxiliary wires. There are two such loaders
but we can cancel the (c-1) right elbows of the first loader with the (c-1) left elbows of the
second loader, reducing the cost of the pair back to the cost of a single multi-controlled loader.
Note that if we are using the Gidney adder implementation for
SemiAdder, we have b-1
auxiliary wires available to use for this, as they are in the |0\rangle state before and
after the adder, and the controlled loading returns them into this state
as well.
Comparison
Let us compare the additional T gate count and auxiliary qubits for the three
options discussed above.
For the C(SemiAdder) with
Toffoli,
we found an overhead of 4(k-1)+7b T gates using c-1 auxiliary qubits.
Replacing the Toffoli by an elbow construction, the overhead
is mildly reduced to 4(k-1+b) T gates, but it requires c auxiliary qubits.
Controlling the data loading is notably cheaper, at an overhead of
4(c-1) T gates and (c-1) auxiliary qubits. Note in particular that there is no scaling
with the number of bits b used for the angle encoding.
In the next tab we will find that multiplexing phase gradient-based rotations yields a circuit similar to the circuit controlling the data loaders above.