Threading for RHF?


I’m running a test RHF/STO-3G calculation on a H24C48S2 molecule, against a Conda-based Psi4 installation. (I’m using the openfermionpsi4 interface, but the question is kind of in between Psi4 and the interface) The calculation is proceeding fine, but I notice I’m only getting a single thread in spite of asking for 4.

from openfermion.hamiltonians import MolecularData
from openfermionpsi4 import run_psi4
import psi4

psi4.core.set_memory_bytes(5000000000, True)
geometry = [...]
basis = 'sto-3g'
multiplicity = 1
charge = 0
my_mol = MolecularData(geometry, basis, multiplicity, charge)
my_mol = run_psi4(my_mol, run_scf = True, run_mp2 = False, run_cisd = False, run_ccsd = False, run_fci = False)
print(f'Hartree-Fock energy = {my_mol.hf_energy}')

Would this approach lead to observable CPU utilization around 400% via, e.g., htop? I’ve looked at the run_psi4 interface and it doesn’t have a thread count argument, but I’m hoping I can avoid customizing it to pass a thread count argument if there’s a trick. Thanks in advance.

I can’t give a definitive answer without looking into the guts of OpenFermion, but I’d expect that supplying set_num_threads should parallelize.

Are you trying that and not seeing parallelization, or are you asking before you’ve even tried? If you need additional support on this, please state your OS.

I should also state as a disclaimer: I don’t understand why you would study a system with this many orbitals if your interests are in quantum computing, and I don’t understand why you would use OpenFermion if your interests aren’t in quantum computing. If you are sure you know what you’re doing, carry on.

Looks like openferming does a system call OpenFermion-Psi4/ at master · quantumlib/OpenFermion-Psi4 · GitHub and does not use the python layer.

In this case you need to get set_num_threads(4) in the input file openfermion writes, or modify the system call with adding -n <nthreads> (maybe an alias like alias psi4=psi4 -n 4 would already work)

From the code the run_psi4 function will accept some sort of template file, maybe check out as well.

Hi Jonathon, thanks. I did actually try it, but before getting too much deeper wanted to make sure there wasn’t a well-known trick. I’ve wanted to use Psi4 for awhile, but this is the first time I had good reason to start.

Re: quantum computing, it will be an active space calculation. We’re just exploring bounds of NISQ for now, and the phenomenon we’re interested in is primarily contained in a smallish active space around the frontier orbitals. Still working out whether and how the QC frameworks represent the aufbau core of systems; if they don’t, then we have our next proposal. If they do, then we’ll see how far we can push the active space.

Hi Holger,

Thanks, that was my analysis too. I didn’t see the template file in my prior glance, so I’ll look at that some more as well, thank you!

Cheers; Chris