graphix icon indicating copy to clipboard operation
graphix copied to clipboard

[Bug]: Wrong Pauli measurements for axes `YZ` and `XZ`

Open thierry-martinez opened this issue 1 year ago • 0 comments

Axes conventions have been changed in 81e1a652 for measurements during simulation, but Pauli preprocessing was not updated, leading to inconsistencies for Pauli measurements outside the XY axis. The following test currently succeeds only on the XY axis but not on YZ and XZ.

    @pytest.mark.parametrize("plane", Plane)
    @pytest.mark.parametrize("angle", [0., 0.5, 1., 1.5])
    def test_pauli_measurement_single(self, plane: Plane, angle: float, use_rustworkx: bool = True) -> None:
        pattern = Pattern(input_nodes=[0, 1])
        pattern.add(E(nodes=[0, 1]))
        pattern.add(M(node=0, plane=plane, angle=angle))
        pattern_ref = pattern.copy()
        pattern.perform_pauli_measurements(use_rustworkx=use_rustworkx)
        state = pattern.simulate_pattern()
        state_ref = pattern_ref.simulate_pattern(pr_calc=False, rng=IterGenerator([0]))
        assert np.abs(np.dot(state.flatten().conjugate(), state_ref.flatten())) == pytest.approx(1)

Axes conventions are defined in pauli.py. The current convention is:

Plane cos sin
XY X Y
YZ Z Y
XZ Z X

The former convention was:

Plane cos sin
XY X Y
YZ Y Z
XZ X Z

thierry-martinez avatar Jul 28 '24 17:07 thierry-martinez