-
Notifications
You must be signed in to change notification settings - Fork 117
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
After applying simplifications the unitary matrices change. #195
Comments
When you do |
Hi @jvdwetering, I tried using 'g' instead of 'g.copy()', but the result was the same. After doing several tests, I think the error is due to 'extract_circuit' method. In this example I start from a very simple circuit, convert it to the equivalent graph, extract a circuit from the graph and compare the unitary matrices. Example without any simplification process
Output:
|
Ah, I see what is going wrong. You are calling The docstring of |
Thank you for your reply and your explanation. Taking into account what you have told me, I have modified the test to use the two functions present in Despite this, I do not get the expected result, even though a second call to 'zx.simplify.is_graph_like' returns
OUTPUT
Is the result I get when invoking these two new functions what I expected? Sorry, I don't know if I'm making other incorrect assumptions that avoid getting matrix equality. |
The function |
The new commit I just pushed should fix this issue. |
Thank you again for your reply and the update :)
OUTPUT:
|
I think it is because that function has a stricter definition of what graph-like is. In particular, I think it disallows Hadamard edges directly connected to inputs and outputs, or spiders that are both connected to an input and an output. Both of these are fine for the extraction. |
Can this be closed? |
Yes, @jvdwetering. Thank you for your support. |
I'm trying out some of the simplifications of pyzx, applying them to the pyzx graph coming from a Qiskit circuit.
To check that pyzx has not altered the semantics of the circuit, I check whether the unitary matrix of the original circuit and that of the resulting circuit change.
I have used the same circuit example as in https://github.com/Quantomatic/pyzx/blob/a6e34d90b62ecb1f42b1d7378c4fa65b73005880/tests/test_qasm.py#L214 and I have applied different simplifications.
Below, I indicate two different tests carried out (2 different executions).
In both, I replaced https://github.com/Quantomatic/pyzx/blob/a6e34d90b62ecb1f42b1d7378c4fa65b73005880/tests/test_qasm.py#L242 by:
Simplification test 1
Simplification test 2
Failing https://github.com/Quantomatic/pyzx/blob/a6e34d90b62ecb1f42b1d7378c4fa65b73005880/tests/test_qasm.py#L248
in both tests.
I´m using pyzx 0.8.0 and Qiskit 0.46.0 to execute the unittest.
In addition, I created a notebook and I retrieved the same results using Qiskit 1.0 and qasm v2 exporters/importers from Qiskit.
Is it a bug or is the way I apply the simplifications incorrect?
I am very confused with the results obtained because keep circuit semantics is a fundamental feature of ZX-Calculus simplifications.
Note: I assumed that I should run
to_gh(g)
before both simplifications but even without running it, both tests are incorrect.The text was updated successfully, but these errors were encountered: