Closed pavoljuhas closed 5 months ago
I have got consistent failures for the cirq-core/cirq/circuits/circuit_test.py::test_final_state_vector
test on my Debian-based desktop which were bisected to #6522.
For some reason these do not show in CI runs, but it is preferable to
have passing tests in local environments too.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 97.79%. Comparing base (
1bec6b5
) to head (43cb287
). Report is 1 commits behind head on main.:exclamation: Current head 43cb287 differs from pull request most recent head 754f40e. Consider uploading reports for the commit 754f40e to get more accurate results
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
maybe we should remove it normalization then?
The normalization does help for your original round-off example in #6402.
I think the case where it worsen the outcome is for state vectors with few
nonzero elements. Here is how test_final_state_vector
fails on my
desktop (the outcome may be different for other OS or CPU versions):
>>> x = np.exp(1j * np.pi/4, dtype=np.complex64)
>>> xn = x / np.linalg.norm(x)
>>> abs(x * x.conj() - 1)
5.960464477539063e-08
>>> abs(xn * xn.conj() - 1)
1.1920928955078125e-07
where the latter value for normalized xn is above the test tolerance.
With this PR the test passes and the round-off is better for #6402.
This fixes failure of
check/pytest -n0 cirq-core/cirq/circuits/circuit_test.py::test_final_state_vector
which happened because normalization of a state vector at
np.complex64
precision can subtly increase the overall round-off error.Follow up to #6522 and #6402