Skip to content

DDSim has segmentation fault when running QAOA and Portfolio Optimization with QAOA circuits from MQT Bench #248

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

Closed
rentristandelacruz opened this issue Jun 14, 2023 · 6 comments · Fixed by #249
Assignees
Labels
bug Something isn't working

Comments

@rentristandelacruz
Copy link

mqt.ddsim version

1.17.2

OS

Linux Mint 21.1

Python version

3.10

C++ compiler

11.3.0

Additional environment information

No response

Description

I am simulating some circuits from the MQT Bench (https://www.cda.cit.tum.de/mqtbench/) using DDSim. Specifically, I am the using qasm_simulator backend and for the circuits I download a set of target-independent (compiler: qiskit) qasm files from the MQT Bench web page. I am currently using the DDSim v1.17.2.

When I recently run a QAOA or Portfolio Optimization with QAOA circuits (e.g. portfolioqaoa_indep_qiskit_3.qasm, qaoa_indep_qiskit_3.qasm.) using the qasm_simulator backend I encounter segmentation faults. I did not encounter the segmentation fault issue with the other circuits from the set (i.e. Deutsch-Jozsa, GHZ, Grover's, etc).

I was simulating the same set of circuits a couple of months ago and I did not encounter the segmentation fault when running the QAOA-related circuits. Upon checking, I was using DDSim v1.13.1. I prepared different Python virtual environments and installed different versions of mqt.ddsim. The segmentation fault when running QAOA-related circuits started occurring in version 1.17.0. Version 1.16.0 can run the QAOA and Portfolio Optimization with QAOA circuits without the segmentation fault occurring.

Expected behavior

No response

How to Reproduce

  1. Create a Python virtual environment and install mqt.ddsim v.1.17.0.
  • mdkir ddsim-1.17.0
  • python3.10 -m venv ddsim-1.17.0
  • source ddsim-1.17.0/bin/activate
  • pip install --force-reinstall -v "mqt.ddsim==1.17.0"
  1. Download one qasm QAOA circuit and one Portfolio Optimization with QAOA circuit (target-independet, compiler:qiskit ) from MQT Bench page (https://www.cda.cit.tum.de/mqtbench/). e.g. portfolioqaoa_indep_qiskit_3.qasm, qaoa_indep_qiskit_3.qasm.
  2. Create a Python script, used the ddsim qasm_simulator backend and simulate both qaoa and portfolioqaoa circuit.
    e.g. script:
import sys                                                                                                                              
from qiskit import *                                                                                 
from mqt    import ddsim                                                                                                                                                                                  
qasmFilename     = sys.argv[1]                                                                       
quantumCircuit   = QuantumCircuit.from_qasm_file(sys.argv[1])                                        
backendSimulator = ddsim.DDSIMProvider().get_backend("qasm_simulator")                               
myJob            = execute(quantumCircuit, backendSimulator)                                         
print(myJob.result()) 
@rentristandelacruz rentristandelacruz added the bug Something isn't working label Jun 14, 2023
@hillmich
Copy link
Contributor

Thanks for bringing up this issue. I can reproduce the segmentation fault locally but unfortunately I did not find the cause yet.

Some observations:

  1. The circuit runs fine when passing the file to the c++ command line version.
  2. The circuit runs fine in python when removing the rzz gates.
  3. In principle the rzz should work as they do in test_standalone_simulator.py (test_native_two_qubit_gates)

hillmich added a commit to munich-quantum-toolkit/core that referenced this issue Jun 14, 2023
This PR fixes a bug where the parameters of parameterized gates are not
saved when reading in circuits from `QasmQobjExperiments`. Previously
the `params` list was always empty.

Related:

- munich-quantum-toolkit/ddsim#190
- munich-quantum-toolkit/ddsim#248
hillmich added a commit that referenced this issue Jun 14, 2023
hillmich added a commit that referenced this issue Jun 14, 2023
hillmich added a commit that referenced this issue Jun 15, 2023
@hillmich
Copy link
Contributor

The latest commit to the main branch should fix the problem. Could you test this as well? I will add a new test for the fix later and create a new release.

@rentristandelacruz
Copy link
Author

The update works. I no longer encounter segmentation faults when running QAOA-related circuits using the qasm_simulator backend. Thank you for the quick fix.

Some additional information: I'm running MQT Bench's circuits on the different DDSim backends including hybrid_qasm_simulator and path_sim_qasm_simulator. I'm encountering something QAOA-related again but this time when using hybrid_qasm_simulator and path_sim_qasm_simulator backends.

When running a QAOA circuit using the hybrid_qasm_simulator (in either dd or amplitude mode) , the following log appears: ValueError: Only StandardOperations are supported for now.

When running a QAOA circuit using the path_sim_qasm_simulator (in any of the modes), the following log appears: ValueError: DD for non-unitary operation not available!

Is this expected behavior or is it a possible issue? (maybe related to rzz gates again?) I can open a separate issue with replication procedure if you think this is a bug. Thanks!

@hillmich
Copy link
Contributor

The hybrid_qasm_simulator and path_sim_qasm_simulator only support standard operations, i.e. unitary operations. For the QAOA example you provided you should be fine with removing the measurements at the end.

In fact, the simulator should automatically remove the measurements at the end of the circuit but I guess the barriers are blocking the removal. Maybe something @burgholzer can also comment on?

@burgholzer
Copy link
Member

I am fairly sure that the barrier statements are the problem.
IIRC measurements at the end are already removed automatically in both of these simulators.
Should be an easy fix by just skipping over barrier statements.

@rentristandelacruz would you mind creating a separate issue for that?

@rentristandelacruz
Copy link
Author

I am fairly sure that the barrier statements are the problem. IIRC measurements at the end are already removed automatically in both of these simulators. Should be an easy fix by just skipping over barrier statements.

@rentristandelacruz would you mind creating a separate issue for that?

I created a separate issue for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants