-
Notifications
You must be signed in to change notification settings - Fork 61
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
Bug: 2-qubit decomposition #1501
Comments
This is not exactly a bug. The documentation of I gues that the issue here is that the current decomposition is not general enough. The same reference provides in Eq. (6) a more general decomposition for unitaries that are in the In [1]: from qibo import set_backend
...: from qibo.backends import NumpyBackend
...: from qibo.hamiltonians import SymbolicHamiltonian
...: from qibo.symbols import *
...: from qibo.transpiler.unitary_decompositions import two_qubit_decomposition
...:
...: set_backend("numpy")
...:
...: backend = NumpyBackend()
...:
...: L = 7
...:
...: H_def = sum([ Z(x)*Z(x+1) +X(x)*X(x+1) +Y(x)*Y(x+1) +0.5*X(x) for x in range(L-1)])
...: H_sym = SymbolicHamiltonian(H_def)
...:
...: circ = H_sym.circuit(.1)
...:
...: for k, gate in enumerate(circ.queue):
...: try:
...: gate_decomposition = two_qubit_decomposition(
...: *gate.qubits, gate.matrix(backend), backend=backend
...: )
...: print(f"worked {k}")
...: except:
...: print(f"fail {k}")
...:
[Qibo 0.2.13|INFO|2024-10-23 14:28:25]: Using numpy backend on /CPU:0
[Qibo 0.2.13|ERROR|2024-10-23 14:28:25]: Given state is not real in the magic basis.
fail 0
worked 1
worked 2
worked 3
worked 4
worked 5
worked 6
worked 7
worked 8
worked 9
worked 10
[Qibo 0.2.13|ERROR|2024-10-23 14:28:25]: Given state is not real in the magic basis.
fail 11 |
Thanks @renatomello ! Are you saying that
which would be a 3 CZ decomposition? What I mean is that qibo/src/qibo/transpiler/unitary_decompositions.py Lines 292 to 305 in 45eae7f
and decompose the 2 qubit unitary into 3 CZ. It seems to fail in the magic basis decomposition though qibo/src/qibo/transpiler/unitary_decompositions.py Lines 271 to 279 in 45eae7f
The two_qubit_decomposition function should manage to decompose into 3 CZs any 2 qubit unitary. If it throws an error for XXZ which is already in the canonical form then it seems it is a bug because it throws an error while the 3 CZ decomposition can be provided 'by hand' and exists |
Added notes:
|
@marekgluza @Sam-XiaoyueLi The most immediate solution is to extend the current decomposition to when the magic-basis expansion has non-zero imaginary part, i.e. extend from Eq. (24) of |
Ok. I will take a look. |
@renatomello I am not familiar with the paper |
Hi Changsoo, we have a workaround from cirq (qibo is failing at the magic
basis decomposition but eg cirq can be used for that step) but eventually a
working decomposition within qibo would be great for it to have a complete
operational capacity
…On Fri, 25 Oct 2024, 21:01 Changsoo Kim, ***@***.***> wrote:
@renatomello <https://github.com/renatomello> I am not familiar with the
paper arXiv:quant-ph/0307177 used in the code. Instead, I will review
arXiv:quant-ph/0308006 and look for alternatives. @Sam-XiaoyueLi
<https://github.com/Sam-XiaoyueLi>, is this urgent?
—
Reply to this email directly, view it on GitHub
<#1501 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABU6DWEAZYUAGPJ3NCNQJOLZ5I6JLAVCNFSM6AAAAABQOKPEYOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZXG4YTONRZGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
The following code throws an error on Mac (apple silicon, regardless of qibo backend) but no error on i7:
Error message:
The text was updated successfully, but these errors were encountered: