QuTech-Delft / qx-simulator

QX Simulator
Other
16 stars 12 forks source link

qx.execute() freeze for shots > 2 #67

Closed prince-ph0en1x closed 5 years ago

prince-ph0en1x commented 5 years ago

test_qxl.py

from openql import openql as ql
import os

def tryInstall():
    config_fn = os.path.abspath('/media/sf_QWorld/Intel/OpenQL-0.6.0/tests/test_cfg_none_simple.json')
    platform = ql.Platform('platform_none', config_fn)
    total_qubits = 1
    prog = ql.Program('p_name', platform, total_qubits)
    k1 = ql.Kernel('QK1',platform, total_qubits)
    k1.gate("h",[0])
    k1.gate("measure",[0])
    prog.add_kernel(k1)
    prog.compile()
tryInstall()

from qxelarator import qxelarator

qx = qxelarator.QX()
qx.set('test_output/p_name.qasm')

shots = 3
p_soln = 0

for i in range(shots):
    qx.execute()
    c0 = qx.get_measurement_outcome(0)
    print('{}'.format(c0))
    if c0 == False:
        p_soln = p_soln+1

print(p_soln)

Output:

aritra@virtue:/media/sf_QWorld/QX_Simulator$ python3 test_qxl.py 
[QXELERATOR]/media/sf_QWorld/QX_Simulator/qx-simulator/qxelarator/qxelarator/qx_simulator.h:97 Creating quantum register of 1 qubits... 
[QXELERATOR]/media/sf_QWorld/QX_Simulator/qx-simulator/qxelarator/qxelarator/qx_simulator.h:128 Loaded 2 circuits.
True
[QXELERATOR]/media/sf_QWorld/QX_Simulator/qx-simulator/qxelarator/qxelarator/qx_simulator.h:97 Creating quantum register of 1 qubits... 
[QXELERATOR]/media/sf_QWorld/QX_Simulator/qx-simulator/qxelarator/qxelarator/qx_simulator.h:128 Loaded 2 circuits.
True
[QXELERATOR]/media/sf_QWorld/QX_Simulator/qx-simulator/qxelarator/qxelarator/qx_simulator.h:97 Creating quantum register of 1 qubits... 
[QXELERATOR]/media/sf_QWorld/QX_Simulator/qx-simulator/qxelarator/qxelarator/qx_simulator.h:128 Loaded 2 circuits.
^Z
[8]+  Stopped                 python3 test_qxl.py

Is this related to https://github.com/QE-Lab/qx-simulator/issues/2 I am using Ubuntu 18.04 Works always for shots 1 or 2. It freezes in the qx.execute(), not qx.get_measurement_outcome(0)

prince-ph0en1x commented 5 years ago

@anneriet is having the same issue. She is getting segmentation fault for any runs more than once. She is running on Ubuntu 16.04 and qx-simulator 0.3.

Even doing this doesn't work.

p_soln = 0

qx = qxelarator.QX()
qx.set('test_output/p_name.qasm')
qx.execute()
c0 = qx.get_measurement_outcome(0)
print('{}'.format(c0))
if c0 == False:
    p_soln = p_soln+1

qx2 = qxelarator.QX()
qx2.set('test_output/p_name.qasm')
qx2.execute()
c0 = qx2.get_measurement_outcome(0)
print('{}'.format(c0))
if c0 == False:
    p_soln = p_soln+1
anneriet commented 5 years ago

I also ran into some issues running the automated test suite, and discovered that running the tests inside the qx-simulator folder (python3 -m pytest) also gives the segmentation fault (core dumped)

imranashraf commented 5 years ago

@anneriet , @prince-ph0en1x . fixed in https://github.com/QE-Lab/qx-simulator/pull/70. please pull the develop and test on your machines.

prince-ph0en1x commented 5 years ago

yes, works for me!