Options in mcsolve don't work

62 views
Skip to first unread message

Ming Gong

unread,
Dec 29, 2016, 11:44:11 PM12/29/16
to QuTiP: Quantum Toolbox in Python
I am tring to modify the options in the mcsolve to speed up the process. Some options in mcsolve do work, but the others don't. My code is followed:

opt=Options()
opt.atol=1e-3
opt.rtol=1e-3
 
opt.num_cpus=8
opt.ntraj=100000

output = mcsolve(H, psi0, tlist, [], [sm1.dag() * sm1,sm2.dag()*sm2,a.dag()*a],options=opt)
 
Here, opt.atol and opt.rtol work. When I increase them, the total time decrease. However, neither opt.num_cpus nor opt.ntraj do their job. There is no difference when changing them. By setting num_cpus=8, the total cpus used is still one core, and the total time is the same as num_cpus=1. It is similar when changing opt.ntraj。 No effort takes when modify these two important parameters.

I have tried with Windows 10 and Ubuntu 1610. Could anybody tell me why and how to fix it? Thanks!

Alex Pitchford

unread,
Dec 30, 2016, 1:09:08 AM12/30/16
to qu...@googlegroups.com
Check your qutip settings by using:
qutip.about()

Report back pls.
Focus on ubuntu. Windows won't help you because multiprocessing on Windows is as good as useless, because it takes so long to spawn a process.

--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul Nation

unread,
Dec 30, 2016, 1:51:30 AM12/30/16
to QuTiP Group
Seems to work fine.  Ran this script and got the expected results:

import numpy as np
import time
from qutip import *

times = np.linspace(0.0, 10.0, 200)
psi0 = tensor(fock(2, 0), fock(10, 5))
a  = tensor(qeye(2), destroy(10))
sm = tensor(destroy(2), qeye(10))

H = 2 * np.pi * a.dag() * a + 2 * np.pi * sm.dag() * sm + 2 * np.pi * 0.25 * (sm * a.dag() + sm.dag() * a)

opt = Options()

opt.num_cpus = 1
st = time.time()
mcsolve(H, psi0, times, [np.sqrt(0.1) * a], [a.dag() * a, sm.dag() * sm], options=opt)

opt.num_cpus = 2
st = time.time()
mcsolve(H, psi0, times, [np.sqrt(0.1) * a], [a.dag() * a, sm.dag() * sm], options=opt)

opt.ntraj = 1
st = time.time()
mcsolve(H, psi0, times, [np.sqrt(0.1) * a], [a.dag() * a, sm.dag() * sm], options=opt)


--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.

Ming Gong

unread,
Dec 30, 2016, 2:22:31 AM12/30/16
to QuTiP: Quantum Toolbox in Python
Hello Alex,

The settings are:

QuTiP: Quantum Toolbox in Python
Copyright (c) 2011 and later.
Paul D. Nation & Robert J. Johansson

QuTiP Version:      3.1.0
Numpy Version:      1.11.0
Scipy Version:      0.17.0
Cython Version:     0.25.1
Matplotlib Version: 1.5.1
Fortran mcsolver:   False
scikits.umfpack:    False
Python Version:     2.7.12
Platform Info:      Linux (x86_64)
Installation path:  /home/qubits0/.local/lib/python2.7/site-packages/qutip


在 2016年12月30日星期五 UTC+8下午2:09:08,Alex Pitchford写道:
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.

Paul Nation

unread,
Dec 30, 2016, 3:51:39 AM12/30/16
to qu...@googlegroups.com

What do you get as the run times for the following script:

import numpy as np
from qutip import *

times = np.linspace(0.0, 10.0, 200)
psi0 = tensor(fock(2, 0), fock(10, 5))
a  = tensor(qeye(2), destroy(10))
sm = tensor(destroy(2), qeye(10))

H = 2 * np.pi * a.dag() * a + 2 * np.pi * sm.dag() * sm + 2 * np.pi * 0.25 * (sm * a.dag() + sm.dag() * a)

opt = Options()

opt.num_cpus = 1

mcsolve(H, psi0, times, [np.sqrt(0.1) * a], [a.dag() * a, sm.dag() * sm], options=opt)

opt.num_cpus = 2
mcsolve(H, psi0, times, [np.sqrt(0.1) * a], [a.dag() * a, sm.dag() * sm], options=opt)

opt.ntraj = 1
mcsolve(H, psi0, times, [np.sqrt(0.1) * a], [a.dag() * a, sm.dag() * sm], options=opt)

December 30, 2016 at 00:22
Hello Alex,

The settings are:

QuTiP: Quantum Toolbox in Python
Copyright (c) 2011 and later.
Paul D. Nation & Robert J. Johansson

QuTiP Version:      3.1.0
Numpy Version:      1.11.0
Scipy Version:      0.17.0
Cython Version:     0.25.1
Matplotlib Version: 1.5.1
Fortran mcsolver:   False
scikits.umfpack:    False
Python Version:     2.7.12
Platform Info:      Linux (x86_64)
Installation path:  /home/qubits0/.local/lib/python2.7/site-packages/qutip


在 2016年12月30日星期五 UTC+8下午2:09:08,Alex Pitchford写道:
--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
December 29, 2016 at 23:09
Check your qutip settings by using:
qutip.about()

Report back pls.
Focus on ubuntu. Windows won't help you because multiprocessing on Windows is as good as useless, because it takes so long to spawn a process.


--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
December 29, 2016 at 21:44

Alex Pitchford

unread,
Dec 30, 2016, 4:34:49 AM12/30/16
to qu...@googlegroups.com
I am guessing you might now have the multiprocessing package.
I see you are using qutip 3.1. I think in those days we didn't report num_cpus in about(). 
We have just made a release of 4.0. You will find it on the website. I would suggest that you install that.
I would also suggest that you install anaconda python (before qutip4). Preferably for Python 3, unless you have good reason to use Python 2. The default env will include the multiprocessing.
Anaconda is a pretty big install (~4GB). I see you installed qutip into your .local, which perhaps suggest you don't have sudo access.
If you need a lighter install, then try miniconda. If you go this way you will want to install packages:
pip, mkl, numpy, scipy, multiprocessing, cython, matplotlib, nose
probably also:
spyder, jupyter, notebooks
currently best way to install qutip 4 (after setting up the env) would be:
$ pip install qutip

I am just working (now) on conda packages, (soon) on updating instructions for installing qutip.


To unsubscribe from this group and stop receiving emails from it, send an email to qutip+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
December 29, 2016 at 23:09
Check your qutip settings by using:
qutip.about()

Report back pls.
Focus on ubuntu. Windows won't help you because multiprocessing on Windows is as good as useless, because it takes so long to spawn a process.


--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
December 29, 2016 at 21:44
I am tring to modify the options in the mcsolve to speed up the process. Some options in mcsolve do work, but the others don't. My code is followed:

opt=Options()
opt.atol=1e-3
opt.rtol=1e-3
 
opt.num_cpus=8
opt.ntraj=100000

output = mcsolve(H, psi0, tlist, [], [sm1.dag() * sm1,sm2.dag()*sm2,a.dag()*a],options=opt)
 
Here, opt.atol and opt.rtol work. When I increase them, the total time decrease. However, neither opt.num_cpus nor opt.ntraj do their job. There is no difference when changing them. By setting num_cpus=8, the total cpus used is still one core, and the total time is the same as num_cpus=1. It is similar when changing opt.ntraj。 No effort takes when modify these two important parameters.

I have tried with Windows 10 and Ubuntu 1610. Could anybody tell me why and how to fix it? Thanks!
--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+unsubscribe@googlegroups.com.

Ming Gong

unread,
Jan 3, 2017, 7:52:58 AM1/3/17
to QuTiP: Quantum Toolbox in Python
Hi Alex and Paul:

Thanks for your help. Now I have tried your recommendations and have the multi-cpu work properly. However, there is still some issue bothering me.

My environment is:
QuTiP Version:      4.0.1
Numpy Version:      1.11.1
Scipy Version:      0.18.1
Cython Version:     0.24.1
Matplotlib Version: 1.5.3
Python Version:     3.5.2
Number of CPUs:     16
BLAS Info:          INTEL MKL
INTEL MKL Ext:      True
Platform Info:      Linux (x86_64)
Installation path:  /home/qubits0/anaconda3/lib/python3.5/site-packages/qutip

The code, which is just modified from your code, is:
 
import numpy as np
import time
from qutip import *

about()

times = np.linspace(0.0, 10.0, 20)
psi0 = tensor(fock(2, 0), fock(10, 5))
a  = tensor(qeye(2), destroy(10))
sm = tensor(destroy(2), qeye(10))

H0 = 2 * np.pi * a.dag() * a + 2 * np.pi * sm.dag() * sm + 2 * np.pi * 0.25 * (sm * a.dag() + sm.dag() * a)

#H=[H0,[sm.dag() * sm,'A*np.sin(w*t)']]
#args={'A':0.01*2*np.pi,'w':0.1*2*np.pi}

H=[H0,[sm.dag() * sm, 0.01*2*np.pi*np.sin(0.1*2*np.pi*times)]]

opt = Options()

opt.ntraj = 1000
opt.rhs_reuse = True
opt.num_cpus = 16
opt.gui=True

st = time.time()
c_op_list=[np.sqrt(0.1) * a]
output=mcsolve(H, psi0, times, c_op_list, [a.dag() * a, sm.dag() * sm],  options=opt)

st = time.time()
c_op_list=[]
output=mcsolve(H, psi0, times, c_op_list, [a.dag() * a, sm.dag() * sm],  options=opt)

Here, it is found that for  c_op_list=[], there is no gui showing the process. The time cost is also too short. Besides, the time cost will not increase even though I increase the opt.ntraj to 1000000. It looks not correct for that case. It seems that for c_op_list=[], mcsolve is not running, but the mesolve is running. I don't know if it is a bug.

在 2016年12月30日星期五 UTC+8下午5:34:49,Alex Pitchford写道:
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
December 29, 2016 at 23:09
Check your qutip settings by using:
qutip.about()

Report back pls.
Focus on ubuntu. Windows won't help you because multiprocessing on Windows is as good as useless, because it takes so long to spawn a process.


--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
December 29, 2016 at 21:44
I am tring to modify the options in the mcsolve to speed up the process. Some options in mcsolve do work, but the others don't. My code is followed:

opt=Options()
opt.atol=1e-3
opt.rtol=1e-3
 
opt.num_cpus=8
opt.ntraj=100000

output = mcsolve(H, psi0, tlist, [], [sm1.dag() * sm1,sm2.dag()*sm2,a.dag()*a],options=opt)
 
Here, opt.atol and opt.rtol work. When I increase them, the total time decrease. However, neither opt.num_cpus nor opt.ntraj do their job. There is no difference when changing them. By setting num_cpus=8, the total cpus used is still one core, and the total time is the same as num_cpus=1. It is similar when changing opt.ntraj。 No effort takes when modify these two important parameters.

I have tried with Windows 10 and Ubuntu 1610. Could anybody tell me why and how to fix it? Thanks!
--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.

Paul Nation

unread,
Jan 3, 2017, 9:13:11 AM1/3/17
to QuTiP Group
If you have no collapse operators, then there is no point doing Monte Carlo as all the trajectories are the same.  As such, the monte-carlo solver just returns the Schodinger equation result.

-P

To unsubscribe from this group and stop receiving emails from it, send an email to qutip+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages