Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default atol for sub_state_vector is too picky for default precision of simulator #4786

Closed
Strilanc opened this issue Dec 29, 2021 · 0 comments · Fixed by #4877
Closed

Default atol for sub_state_vector is too picky for default precision of simulator #4786

Strilanc opened this issue Dec 29, 2021 · 0 comments · Fixed by #4877
Labels
area/simulation area/state-vector-simulator kind/bug-report Something doesn't seem to work. triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on

Comments

@Strilanc
Copy link
Contributor

The following raises an exception instead of finishing successfully:

import cirq
a, b = cirq.LineQubit.range(2)
final_state_vector = cirq.Simulator().simulate(cirq.Circuit(
    cirq.H(a),
    cirq.H(b),
    cirq.CZ(a, b),
    cirq.measure(a),
)).final_state_vector.reshape((2, 2))
print(cirq.sub_state_vector(final_state_vector, [0]))

Giving atol=1e-6 to the sub_state_vector method fixes it. The default of atol=1e-8 seems to be too strict given that this simple example fails it.

@Strilanc Strilanc added the kind/bug-report Something doesn't seem to work. label Dec 29, 2021
@viathor viathor added area/simulation area/state-vector-simulator triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on labels Jan 12, 2022
CirqBot pushed a commit that referenced this issue Jan 26, 2022
rht pushed a commit to rht/Cirq that referenced this issue May 1, 2023
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this issue Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/simulation area/state-vector-simulator kind/bug-report Something doesn't seem to work. triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants