zxcalc / pyzx

Python library for quantum circuit rewriting and optimisation using the ZX-calculus
Apache License 2.0
385 stars 116 forks source link

SWAP gates are not supported. #121

Closed bredamatt closed 1 year ago

bredamatt commented 1 year ago

I am currently trying to load a quantum volume circuit generated with Qiskit from a .qasm file into PyZX, using:

zx.Circuit.load("file.qasm")

I encounter the following:

TypeError: Unknown gate name: swap q2,q3

The same applies when I use the zx.Circuit.from_qasm_file("file.qasm"), or directly: zx.Circuit.from_qasm(circ.qasm(formatted=False)).

It seems it is not possible for the QASMParser to translate the swap gate into a valid PyZX representation. Is this correct, or am I missing something?

It would be useful to support this since SWAP gates are used by quantum volume circuits which need to be transpiled for optimization purposes before benchmarking the underlying device.

jvdwetering commented 1 year ago

I'm surprised this hasn't come up before, but yes it looks like swap is actually not implemented in the qasmparser. I will a push a fix to this.