Closed kevinsung closed 3 years ago
I think we need to have noise models declare themselves as "monte carlo unitary safe" or something like that in order for this to work properly.
I was thinking the simulator could just raise a runtime error if it encounters a gate it can't simulate, but your solution is probably better.
I think we should add is_mixture_of_unitaries
and is_coherent
methods/properties to NoiseModel.
We decided at #2440 to make the simulator do all the work instead of letting noise models declare whether they can be simulated.
In the specific case of the wave functio nsimulator being given a noise model, it should be understood that if you give a noise model it can't handle then you will get an error.
Is this just a matter of copying the noise preprocessing code from density matrix simulator to the sparse simulator? https://github.com/quantumlib/Cirq/blob/e46f62eb1cfec26b876411042f756f6187a52285/cirq/sim/density_matrix_simulator.py#L265
Is this just a matter of copying the noise preprocessing code from density matrix simulator to the sparse simulator?
Prior discussion on this issue suggests that there's a degree of validation required here. There are effectively three types of noise that a NoiseModel can generate, and the sparse simulator only supports two of them:
Without some nontrivial changes in the sparse simulator, (3) must be rejected. I think you can handle this with two checks:
cirq.has_mixture(gate) # true for mixtures and gates, but not channels
cirq.is_measurement(gate) # true for measurements, which aren't "noise" but don't have a mixture
Now that CircuitOperation
exists, this check will need to be recursive.
Incidentally, this check should be very similar (but not identical) to the is_noisy
check defined in #3799.
It can simulate mixtures and coherent noise models.