qiboteam / qibojit-benchmarks

Benchmark code for qibojit performance accessment
Apache License 2.0
2 stars 3 forks source link

QASM error with Supremacy circuit #13

Closed mlazzarin closed 2 years ago

mlazzarin commented 2 years ago

If I run

python main.py --circuit supremacy

Qibo raises a QASM error:

ValueError: QASM command sx is not recognized.
stavros11 commented 2 years ago

Does this happen when you use the main branch of this repository? Because in my case it works with no issue:

Screenshot from 2021-10-12 16-34-05

The way the supremacy circuit is constructed is by using Cirq's generate_boixo_2018_supremacy_circuits_v2, translating it to Qasm and then using qibo's Circuit.from_qasm to create the corresponding qibo circuit, so the error you are quoting is possible but I haven't seen it.

By the way, you may also want to try the libraries branch which allows to benchmark other libraries to, as this is the most up-to-date branch at the moment. However main should still work for qibo only benchmarks.

mlazzarin commented 2 years ago

The problem appears when upgrading to Cirq 0.12.0. In particular, Cirq uses a new gate named sx, which is not recognized by Qibo.

stavros11 commented 2 years ago

Just adding that the new sx gate corresponds to rx(pi*0.5) from Cirq 0.11. Also this issue does not appear in CI because Cirq is installed via OpenFermion which is required for the BasisChange circuit and apparently pins Cirq's version to 0.11.1. This issue may appear once they upgrade Cirq's version and a potential solution would be to substitute sx with the rx gate, eg. using qasm.replace("sx", "rx(pi*0.5)) on the qasm string.

stavros11 commented 2 years ago

It seems that openfermion updated the cirq version requirement and now this issue appears here. I have pushed the simple fix described above in #11 (branch libraries). @mlazzarin, if you have time you can check and let me know if it works for you now.

mlazzarin commented 2 years ago

Now it works, thank you.

mlazzarin commented 2 years ago

We can close this issue once #11 is merged.