Closed 1ucian0 closed 1 year ago
I'll try this, will write back this weekend if there is any progress
Great! let us know!
I think one possible approach is to make DiagonalGate
a subclass of UnitaryGate
. So qasm
method can be inherited.
any update on this. I am new here and looking to get started with some issue and getting to know the code base
It seems the issue is a bit complicated. The problem plagues the rest of the classes in quantum_initializer as well: `from qiskit import QuantumCircuit
qc = QuantumCircuit(2) qc.ucrz([0,0], [0],[1]) qasm = qc.qasm() QuantumCircuit.from_qasm_str(qasm)`
I tried making DiagonalGate
a subclass of UnitaryGate
as @1ucian0 suggested, but the issue there is that DiagonalGate
constructor builds with params = diag
where diag
is a 1D array with diagonal elements and UnitaryGate
constructor builds with params = matrix
where matrix is a 2D array with matrix elements. A lot of tests rely on that (in particular \qiskit-terra\test\python\circuit\test_diagonal_gate.py
) and for that reason inheriting DiagonalGate from UnitaryGate seems cumbersome.
I am still actively working on a (perhaps more global at this point) solution, if you have any ideas I would be very curious to listen to them :)
The course of action would be as follows in my current understanding: either make everything a subclass of UnitaryGate
and use its qasm constructor. Or (I prefer this option personally) make a qasm constructor for every class in quantum_initializer
. This involves translating the multiplexed gates into gates that qasm understands.
Also I think it would be good to leave the spirit of the code as it is since it is stated in the header that it is a semester thesis. Perhaps contacting the person in question would be a good idea.
Hi @artemiyburov , thanks for looking into this. I agree with adding a modified qasm method to the needed classes. I think the best path forward is to abstract the qasm method from UnitaryGate
into either a role or a class decorator which can be reused for any gates that have to be synthesized before exporting to qasm.
ping @artemiyburov ? Are you still working on this?
Hey, In case @artemiyburov is no longer working on the issue, I'd be happy to try and solve it.
I'm not working on this at the moment
It was decided by the core team that all the QASM-related code will be removed out of the terra component. I'm putting this issue on hold
until the new repo is set.
There's also a similar issue with multiple controlled Z gates.
c8z as generated in QASM is not recognized when imported back.
This was fixed at some point in the past, though I don't know when.
Information
What is the current behavior?
The line
diagonal(1,1) q[0];
is not valid OPENQASM 2.0.Steps to reproduce the problem
What is the expected behavior?
Qiskit should generate QASM that can be consumed by Qiskit.
Suggested solutions
Not sure. Is it possible to synthesize like with
unitary
?