unitaryfund / mitiq

Mitiq is an open source toolkit for implementing error mitigation techniques on most current intermediate-scale quantum computers.
https://mitiq.readthedocs.io
GNU General Public License v3.0
358 stars 157 forks source link

Flaky behavior with ZNE Braket example #937

Closed rmlarose closed 2 years ago

rmlarose commented 2 years ago

Sometimes the final plot looks good: (https://mitiq.readthedocs.io/en/latest/examples/braket_mirror_circuit.html)

image

Other times its nonsensical: (https://mitiq.readthedocs.io/en/stable/examples/braket_mirror_circuit.html)

image

I believe this is due to how the noisy simulation is done with braket.

Desired behavior

Having the example (https://github.com/unitaryfund/mitiq/blob/master/docs/source/examples/braket_mirror_circuit.md) reliably produce the first plot.

andreamari commented 2 years ago

FYI I am repeatedly building the stable docs from the readthedocs admin page untill the correct plot will appear (I hope). Not an optimal solution, but at least it should be enough to fix the stable version of the documentation.

nathanshammah commented 2 years ago

That could be understandable for a stochastic (quantum trajectory-like) simulator without many repetitions. But a density matrix simulator should be deterministic, unless is a stochastic ~photocurrent + deterministic simulator.

I am not sure what is the physics behind DensityMatrixSimulator. I see it here that itself seems to depend on BaseLocalSimulator, but it assumes no noise there.

There are some noise specifications elsewhere

_NOISE_INSTRUCTIONS = frozenset(
    instr.lower().replace("_", "")
    for instr in [
        "amplitude_damping",
        "bit_flip",
        "depolarizing",
        "generalized_amplitude_damping",
        "kraus",
        "pauli_channel",
        "phase_flip",
        "phase_damping",
        "two_qubit_dephasing",
        "two_qubit_depolarizing",

Knowing the physics behind the noise simulation is important, even if the simulator stops being inconsistent, so we should find it out.

rmlarose commented 2 years ago

FYI I am repeatedly building the stable docs from the readthedocs admin page untill the correct plot will appear (I hope). Not an optimal solution, but at least it should be enough to fix the stable version of the documentation.

Thanks. Fine as a patch fix while keeping this open until an actual fix.

andreamari commented 2 years ago

FYI I am repeatedly building the stable docs from the readthedocs admin page untill the correct plot will appear (I hope). Not an optimal solution, but at least it should be enough to fix the stable version of the documentation.

Thanks. Fine as a patch fix while keeping this open until an actual fix.

@rmlarose Actually the trick of re-building the stable docs doesn't seem work. I did it several times and the plot looks always bad.

After playing a bit with the example, I realized that the problem is a small bug in the computation of the correct bitstring in mirror circuits (see #940). So the AWS simulator is ok.