I want to run simulations of noisy circuits (e.g. with a random Pauli error [I, X, Y, Z]
with weights [1-3p, p, p, p]
after each gate) in Yao.jl.
My first thought was to use full density matrix simulations, but it seems that there is no support for time evolution of DensityMatrix
es.
My second thought was running a BatchedArrayReg
through a UnitaryChannel
, i.e. like this
# initialize the computational zero state on all states in the register
state = zeros(ComplexF32, 2^2, 3)
state[1,:] .= 1.
reg = BatchedArrayReg(state, 3)
# create a circuit corresponding to the depolarizing channel
noisechannel = UnitaryChannel([igate(1), X, Y, Z], [0.4, 0.2, 0.2, 0.2])
circuit = put(2, 1=>noisechannel)
# and apply the circuit to the register
apply!(reg, circuit)
But it seems that apply!()
samples one of the gates in the noisechannel
and then applies the same gate to all states in the batch. Is there a way, that a different gate gets applied to all states in the register?
And tangentially related: What is the use of the BatchedArrayRegister
when all states in the batch evolve under exactly the same circuit?