You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two (almost) identical simulations of a circuit in two different Ipython notebook. In one Ipython notebook the simulation is way faster than in the other. It is independent from the notebook because I know both cases happened in both notebooks. I appended a snippet of the logs of %prun at the end of the post. I checked in both cases the C++ compiler should be used (I assume this because of the usage of the _simulator.py:55(init) file in the log). I assume I did some initialization differently, but I do not know what. In the faster case the atexit.unregister function is used way longer, but I do not quite understand the effect of this function on the simulation.
I initialize the engine and circuit and do the measurement within the scipy.optimize.minimize function. So the broad code structure is
scipy.optimize.minimize(experiments, init_parameter, ...)
def experiments(parameter):
for in range(100):
eng = projectq.MainEngine(backend=projectq.backends.Simulator(gate_fusion=True), engine_list=[])
q = eng.allocate_qubit()
circuit(parameter, eng, q)
projectq.ops.Measure | q
eng.flush()
do some non-projectq related postprocessing
But I also tried to put all code in one function and initialize the engine at different spots, but it seems to not change the result.
Here a snapshot of the log of the fast computation
Are you able to reproduce this?
Did you export OMP_NUM_THREADS=1 for the fast version? Because if you only use a single qubit, you shouldn't be using multiple threads. Also, gate fusion should be turned off for a single qubit since the simulator will perform a bunch of matrix-matrix multiplications if it's on, instead of just matrix-vector mult.
I have two (almost) identical simulations of a circuit in two different Ipython notebook. In one Ipython notebook the simulation is way faster than in the other. It is independent from the notebook because I know both cases happened in both notebooks. I appended a snippet of the logs of %prun at the end of the post. I checked in both cases the C++ compiler should be used (I assume this because of the usage of the _simulator.py:55(init) file in the log). I assume I did some initialization differently, but I do not know what. In the faster case the atexit.unregister function is used way longer, but I do not quite understand the effect of this function on the simulation.
I initialize the engine and circuit and do the measurement within the scipy.optimize.minimize function. So the broad code structure is
But I also tried to put all code in one function and initialize the engine at different spots, but it seems to not change the result.
Here a snapshot of the log of the fast computation
and here from the slow computation
The text was updated successfully, but these errors were encountered: