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

Flake in test_decompose_to_diagonal_and_circuit #5574

Closed
dabacon opened this issue Jun 22, 2022 · 4 comments
Closed

Flake in test_decompose_to_diagonal_and_circuit #5574

dabacon opened this issue Jun 22, 2022 · 4 comments
Assignees
Labels
area/ci area/decompose area/testing 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

@dabacon
Copy link
Collaborator

dabacon commented Jun 22, 2022

v = array([[-0.61070603+0.1365783j , -0.5391698 -0.27113172j, -0.13448845+0.33649975j, 0.07048975+0.3284511j ],
[-...[-0.144254 +0.16332075j, 0.23525491+0.0989278j , -0.29602534+0.62655133j, -0.28742015-0.56971717j]], dtype=complex64)
@pytest.mark.parametrize(
"v",
[
cirq.unitary(random_two_qubit_circuit_with_czs(3)),
cirq.unitary(random_two_qubit_circuit_with_czs(2)),
np.diag(np.exp(1j * np.pi * np.random.random(4))),
],
)
deftest_decompose_to_diagonal_and_circuit(v):
b, c = cirq.LineQubit.range(2)
diagonal, ops = two_qubit_matrix_to_diagonal_and_cz_operations(b, c, v, atol=1e-6)
assert cirq.is_diagonal(diagonal)
combined_circuit = cirq.Circuit(cirq.MatrixGate(diagonal)(b, c), ops)
circuit_unitary = combined_circuit.unitary(qubits_that_should_be_present=[b, c])

  cirq.testing.assert_allclose_up_to_global_phase(circuit_unitary, v, atol=1e-5)

E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 16 / 16 (100%)
E Max absolute difference: 6.1219725e-05
E Max relative difference: 0.00010682
E x: array([[ 0.384335+4.938793e-01j, -0.014804+6.033021e-01j, 0.361728-2.215727e-02j, 0.266857-2.040258e-01j],
E [ 0.619436-1.967203e-01j, -0.672573-1.093492e-01j, -0.196227+1.505381e-01j, -0.16237 -1.604927e-01j],
E [-0.215903+3.031191e-01j, -0.21768 +2.428720e-01j, -0.19194 -5.389726e-01j, -0.650181-7.116976e-02j],
E [ 0.209275+6.065131e-02j, -0.011074-2.549549e-01j, 0.692938-5.960464e-08j, -0.392396+5.032529e-01j]], dtype=complex64)
E y: array([[ 0.384375+4.938332e-01j, -0.014821+6.033215e-01j, 0.361702-2.214911e-02j, 0.266861-2.040445e-01j],
E [ 0.619446-1.967466e-01j, -0.672537-1.093988e-01j, -0.196237+1.505618e-01j, -0.162392-1.604833e-01j],
E [-0.215881+3.031079e-01j, -0.217704+2.428641e-01j, -0.191879-5.389693e-01j, -0.650208-7.117966e-02j],
E [ 0.209292+6.066049e-02j, -0.011051-2.549695e-01j, 0.692963+5.960464e-08j, -0.392335+5.032508e-01j]], dtype=complex64)
cirq-core/cirq/transformers/analytical_decompositions/two_qubit_to_cz_test.py:268: AssertionError

@dabacon dabacon added the kind/bug-report Something doesn't seem to work. label Jun 22, 2022
@tanujkhattar
Copy link
Collaborator

xref #5533

@vtomole
Copy link
Collaborator

vtomole commented Jun 23, 2022

@dabacon
Copy link
Collaborator Author

dabacon commented Jun 24, 2022

__________________ test_decompose_to_diagonal_and_circuit[v1] __________________
E         
E         v = array([[-0.04917413+0.31887117j, -0.21023309-0.17613545j,  0.03311536-0.84780866j, -0.29627275-0.11413992j],
E                [-...[-0.00090575+0.2908945j ,  0.29029933+0.5300961j ,  0.33330664-0.02012963j, -0.33348376+0.5721835j ]], dtype=complex64)
E         
E             @pytest.mark.parametrize(
E                 "v",
E                 [
E                     cirq.unitary(random_two_qubit_circuit_with_czs(3)),
E                     cirq.unitary(random_two_qubit_circuit_with_czs(2)),
E                     np.diag(np.exp(1j * np.pi * np.random.random(4))),
E                 ],
E             )
E             def test_decompose_to_diagonal_and_circuit(v):
E                 b, c = cirq.LineQubit.range(2)
E                 diagonal, ops = two_qubit_matrix_to_diagonal_and_cz_operations(b, c, v, atol=1e-6)
E                 assert cirq.is_diagonal(diagonal)
E                 combined_circuit = cirq.Circuit(cirq.MatrixGate(diagonal)(b, c), ops)
E                 circuit_unitary = combined_circuit.unitary(qubits_that_should_be_present=[b, c])
E         >       cirq.testing.assert_allclose_up_to_global_phase(circuit_unitary, v, atol=1e-5)
E         E       AssertionError: 
E         E       Not equal to tolerance rtol=1e-07, atol=1e-05
E         E       
E         E       Mismatched elements: 5 / 16 (31.2%)
E         E       Max absolute difference: 2.4261433e-05
E         E       Max relative difference: 4.014266e-05
E         E        x: array([[-0.320549-3.669657e-02j,  0.167792-2.169474e-01j,  0.848454-8.940697e-08j,  0.102486-3.005073e-01j],
E         E              [ 0.226037-4.611170e-01j,  0.028327-5.401294e-01j,  0.107656+7.426675e-02j, -0.561706+3.333432e-01j],
E         E              [ 0.366648-6.427520e-01j, -0.10464 +5.059708e-01j,  0.192138-3.385318e-01j,  0.075745-1.680024e-01j],
E         E              [-0.290706+1.045696e-02j, -0.518354+3.107907e-01j,  0.03313 +3.322693e-01j, -0.584769-3.108764e-01j]], dtype=complex64)
E         E        y: array([[-0.320[547](https://github.com/quantumlib/Cirq/runs/7044934576?check_suite_focus=true#step:5:548)-3.669108e-02j,  0.167796-2.169475e-01j,  0.848455+4.097819e-08j,  0.102489-3.005019e-01j],
E         E              [ 0.226045-4.611138e-01j,  0.02834 -5.401317e-01j,  0.107655+7.426722e-02j, -0.[561](https://github.com/quantumlib/Cirq/runs/7044934576?check_suite_focus=true#step:5:562)709+3.333324e-01j],
E         E              [ 0.366656-6.427467e-01j, -0.104649+5.059704e-01j,  0.192147-3.385260e-01j,  0.075747-1.680016e-01j],
E         E              [-0.290708+1.044859e-02j, -0.518362+3.107679e-01j,  0.033123+3.322670e-01j, -0.584763-3.108972e-01j]], dtype=complex64)
E         
E         cirq-core/cirq/transformers/analytical_decompositions/two_qubit_to_cz_test.py:268: AssertionError

@viathor viathor added area/testing area/decompose area/ci triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on labels Jun 24, 2022
@dabacon
Copy link
Collaborator Author

dabacon commented Jun 29, 2022

We have rolled back the change in default #5636 so these should no longer be occurring

@dabacon dabacon closed this as completed Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ci area/decompose area/testing 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

No branches or pull requests

4 participants