-
Notifications
You must be signed in to change notification settings - Fork 69
Description
QuantumClifford.jl has the apply! function that allows one to apply a quantum operator to a stabilizer state, including other operators. The functionality to apply an operator to another is crucial for a circuit simulator.
The typical way to apply a quantum operation to a quantum state is to multiply the operator to the left.
sHadmard(1)
sHadmard(1)
We are focused only on multiplying two operators for now:
The result is stored in T (This operation shall be denoted by T
However, there is no way to easy and fast way to apply an operator to the right of another operator and stored in the former. This operation is:
The result is stored in T (This operation shall be denoted by T
Why this is required
This functionality is useful for #551 - Circuit simulation using backtracking, which requires building the inverse of a circuit.
Given a circuit:
The inverse of this is
This inverse cannot be built by simply using the original apply! function to the inverses:
This does not give the correct inverse
Therefore, we actually need to run apply_right! to the inverses to build the correct circuit inverse
This gives the correct circuit inverse
Current alternative
function apply_right!(l::CliffordOperator, r::AbstractCliffordOperator; phases=false)
apply!(CliffordOperator(r, nqubits(l)), l; phases=phases)
end
T = apply_right!(T, C)However, this method is especially slow (can be sped up using kernels that apply operations directly instead of converting to a dense clifford first. Also, C is destroyed in the process.
Second alternative
For circuit:
circuit = one(CliffordOperator, n)
apply!(circuit, C_1)
apply!(circuit, C_2)
apply!(circuit, C_3)
circuit_inv = inv(circuit)
measure!(circuit_inv, sMZ)
circuit = inv(circuit)
apply!(circuit, C_4)How to build this
The Stim library has functions that are able to multiply right many symbolic operators fast.
I have been building this functionality into QuantumClifford.jl, and plan to submit a draft PR soon.