Skip to content
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

Issue with running MQT Bench's QAOA and Portfolio Optimization QAOA on hybrid_qasm_simulator and path_sim_qasm_simulator #251

Closed
rentristandelacruz opened this issue Jun 15, 2023 · 1 comment · Fixed by #431
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@rentristandelacruz
Copy link

mqt.ddsim version

1.17.3.dev18+gfbfe86a

OS

Linux Mint 21.1

Python version

Python 3.10

C++ compiler

11.3.0

Additional environment information

Content of input file qaoa_indep_qiskit_3.qasm:

// Benchmark was created by MQT Bench on 2022-12-15
// For more information about MQT Bench, please visit https://www.cda.cit.tum.de/mqtbench/
// MQT Bench version: 0.2.2
// Qiskit version: {'qiskit-terra': '0.22.3', 'qiskit-aer': '0.11.1', 'qiskit-ignis': '0.7.0', 'qiskit-ibmq-provider': '0.19.2', 'qiskit': '0.39.3', 'qiskit-nature': '0.5.1', 'qiskit-finance': '0.3.4', 'qiskit-optimization': '0.4.0', 'qiskit-machine-learning': '0.5.0'}

OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg meas[3];
creg meas0[3];
h q[0];
h q[1];
rzz(3.47521905147808) q[0],q[1];
h q[2];
rzz(3.47521905147808) q[0],q[2];
rx(-3.9630316145815) q[0];
rzz(3.47521905147808) q[1],q[2];
rx(-3.9630316145815) q[1];
rzz(-3.7141963075006) q[0],q[1];
rx(-3.9630316145815) q[2];
rzz(-3.7141963075006) q[0],q[2];
rx(-12.2750719749294) q[0];
rzz(-3.7141963075006) q[1],q[2];
rx(-12.2750719749294) q[1];
rx(-12.2750719749294) q[2];
barrier q[0],q[1],q[2];
measure q[0] -> meas[0];
measure q[1] -> meas[1];
measure q[2] -> meas[2];
barrier q[0],q[1],q[2];
measure q[0] -> meas0[0];
measure q[1] -> meas0[1];
measure q[2] -> meas0[2];

Content of input file portfolioqaoa_indep_qiskit_3.qasm:

// Benchmark was created by MQT Bench on 2022-12-15
// For more information about MQT Bench, please visit https://www.cda.cit.tum.de/mqtbench/
// MQT Bench version: 0.2.2
// Qiskit version: {'qiskit-terra': '0.22.3', 'qiskit-aer': '0.11.1', 'qiskit-ignis': '0.7.0', 'qiskit-ibmq-provider': '0.19.2', 'qiskit': '0.39.3', 'qiskit-nature': '0.5.1', 'qiskit-finance': '0.3.4', 'qiskit-optimization': '0.4.0', 'qiskit-machine-learning': '0.5.0'}

OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg meas[3];
creg meas0[3];
u2(0.41951949,-pi) q[0];
u2(0.41620669,-pi) q[1];
rzz(-0.420917333908502) q[0],q[1];
u2(0.41905329,-pi) q[2];
rzz(-0.421016123405307) q[0],q[2];
u3(2.2348228,1.2558831,-pi/2) q[0];
rzz(-0.420940441831552) q[1],q[2];
u3(2.2348228,1.2087537,-pi/2) q[1];
rzz(-5.98815838177421) q[0],q[1];
u3(2.2348228,1.2492507,-pi/2) q[2];
rzz(-5.98956380537088) q[0],q[2];
u3(0.56042125,-1.2358007,pi/2) q[0];
rzz(-5.98848712542991) q[1],q[2];
u3(0.56042125,-1.2880621,pi/2) q[1];
rzz(-6.64023274758061) q[0],q[1];
u3(0.56042125,-1.2431553,pi/2) q[2];
rzz(-6.6417912133385) q[0],q[2];
rx(-4.06512402388918) q[0];
rzz(-6.64059728943955) q[1],q[2];
rx(-4.06512402388918) q[1];
rx(-4.06512402388918) q[2];
barrier q[0],q[1],q[2];
measure q[0] -> meas[0];
measure q[1] -> meas[1];
measure q[2] -> meas[2];
barrier q[0],q[1],q[2];
measure q[0] -> meas0[0];
measure q[1] -> meas0[1];
measure q[2] -> meas0[2];

Description

When running MQT Bench's (https://www.cda.cit.tum.de/mqtbench/) QAOA and Portfolio Optimization with QAOA circuits (target independent, compiler = Qiskit), e.g. portfolioqaoa_indep_qiskit_3.qasm, qaoa_indep_qiskit_3.qasm, using hybrid_qasm_simulator and path_sim_qasm_simulators, error logs are encountered.

When running the circuits using hybrid_qasm_simulator, the following log appears:
ValueError: Only StandardOperations are supported for now.

When running the circuits using path_sim_qasm_simulator, the following log appears:
ValueError: DD for non-unitary operation not available!

Expected behavior

No response

How to Reproduce

  1. Download some QAOA and Portfolio Optimization with QAOA circuits (target independent, compiler = Qiskit) from MQT Bench's (https://www.cda.cit.tum.de/mqtbench/).
  2. Run the circuits using the hybrid_qasm_simulator and path_sim_qasm_simulator backends. Sample scripts:
    Path Simulator script:
import sys                                                                                                                              
from qiskit import *                                                                                 
from mqt    import ddsim                                                                                                                                                                                  
qasmFilename     = sys.argv[1]                                                                       
quantumCircuit   = QuantumCircuit.from_qasm_file(qasmFilename)                                 
backendSimulator = ddsim.DDSIMProvider().get_backend("path_sim_qasm_simulator")                               
myJob            = execute(quantumCircuit, backendSimulator)                                         
print(myJob.result()) 

Hybrid Simulator script:

import sys                                                                                                                              
from qiskit import *                                                                                 
from mqt    import ddsim                                                                                                                                                                                  
qasmFilename     = sys.argv[1]                                                                       
quantumCircuit   = QuantumCircuit.from_qasm_file(qasmFilename)                                 
backendSimulator = ddsim.DDSIMProvider().get_backend("hybrid_qasm_simulator")                               
myJob            = execute(quantumCircuit, backendSimulator)                                         
print(myJob.result()) 
  1. Observe the error logs appear.
@rentristandelacruz rentristandelacruz added the bug Something isn't working label Jun 15, 2023
@burgholzer
Copy link
Member

Sorry for not getting back to you on this earlier. Since we stumbled upon this today at the qrisp community meeting:

The errors you are seeing here are essentially due to the duplicate measurements in these circuits taken from MQT Bench.

As for the QAOA circuit, this has definitely been fixed in MQT Bench. The resulting circuit there is now:

// Benchmark was created by MQT Bench on 2024-03-18
// For more information about MQT Bench, please visit https://www.cda.cit.tum.de/mqtbench/
// MQT Bench version: 1.1.0
// Qiskit version: 1.0.2

OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg meas[3];
h q[0];
h q[1];
rzz(5.094008139994057) q[0],q[1];
h q[2];
rzz(5.094008139994057) q[0],q[2];
rx(-6.860310317223841) q[0];
rzz(5.094008139994057) q[1],q[2];
rx(-6.860310317223841) q[1];
rzz(-5.141522309483603) q[0],q[1];
rx(-6.860310317223841) q[2];
rzz(-5.141522309483603) q[0],q[2];
rx(8.165927224507852) q[0];
rzz(-5.141522309483603) q[1],q[2];
rx(8.165927224507852) q[1];
rx(8.165927224507852) q[2];
barrier q[0],q[1],q[2];
measure q[0] -> meas[0];
measure q[1] -> meas[1];
measure q[2] -> meas[2];

The portfolio QAOA circuit that is downloadable from the website still contains the duplicate measurements. This has been fixed in cda-tum/mqt-bench#364, but we haven't come around to regenerate the MQT Bench circuit database since then. The correct circuit is available via the mqt.bench CLI though. If you have a recent uv version installed, then

uvx --from mqt.bench mqt.bench.cli --algorithm portfolioqaoa --level indep --num-qubits 3 --compiler qiskit

should yield something comparable to

OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg meas[3];
u2(-2.2153343779813284,-pi) q[0];
u2(-2.2046418772975507,-pi) q[1];
rzz(-4.083687560158023) q[0],q[1];
u2(-2.1987929080465562,-pi) q[2];
rzz(-4.083620518646561) q[0],q[2];
u3(1.178605356771574,-1.7921159382230245,pi/2) q[0];
rzz(-4.083742192346308) q[1],q[2];
u3(1.1786053567715737,-1.77618209398317,pi/2) q[1];
rzz(-6.085465265062668) q[0],q[1];
u3(1.178605356771574,-1.7674660257999388,pi/2) q[2];
rzz(-6.085365360556431) q[0],q[2];
u3(1.8486282685867204,2.369613989111852,-pi/2) q[0];
rzz(-6.085546677335095) q[1],q[2];
u3(1.8486282685867204,2.371713711680157,-pi/2) q[1];
rzz(-0.8019275551676139) q[0],q[1];
u3(1.8486282685867204,2.372862293578896,-pi/2) q[2];
rzz(-0.801914389998979) q[0],q[2];
rx(-12.580569066809241) q[0];
rzz(-0.8019382834754334) q[1],q[2];
rx(-12.580569066809241) q[1];
rx(-12.580569066809241) q[2];
barrier q[0],q[1],q[2];
measure q[0] -> meas[0];
measure q[1] -> meas[1];
measure q[2] -> meas[2];

Both simulators are failing here because they only support a rather limited gate-set. More precisely, they only support measurements at the very end of the circuit.

Even though this is mostly an issue with the circuits themselves, I guess the error message in both cases could be improved. So I will keep this ticket open for now and see whether I can get a quick fix in over the coming days.

@burgholzer burgholzer assigned burgholzer and unassigned hillmich Sep 10, 2024
@burgholzer burgholzer added the documentation Improvements or additions to documentation label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
Status: Done
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants