Skip to content

Inconsistent number of threads used by the geometry optimizers #402

@q-posev

Description

@q-posev

Describe the bug

I noticed a discrepancy in the number of threads used by the QChem code (Psi4) during geometry optimization with 3 optimizers: pyberny, geometric, optking initiated via compute_procedure.

  1. only geometric correctly picks up the number of threads (8 in the example below) specified via task_config (ncores key) argument of compute_procedure (same hold for the memory key)
  2. berny assigns 6 threads in this example (a wild guess: I have 12 cores on my machine, so 6=12/2 makes sense..)
  3. optking goes for the serial execution

For example, running the code from the next section, the output can be the following:

Optimizing with berny
Number of threads used by berny: 6
Memory used by berny: 11.576
Optimizing with geometric
Number of threads used by geometric: 8
Memory used by geometric: 2000.0
Optimizing with optking
Number of threads used by optking: 1
Memory used by optking: 0.524

To Reproduce

import qcelemental as qcel
import qcengine

mol = qcel.models.Molecule.from_data("pubchem:water")

input_spec = qcel.models.procedures.QCInputSpecification(
   driver="gradient",
   model={
       "method": "b3lyp",
       "basis": "6-31g"
       },
   keywords={"scf_type": "df"}
)

opt_input = qcel.models.OptimizationInput(
   initial_molecule=mol,
   input_specification=input_spec,
   protocols={"trajectory": "all"},
   keywords={
       "coordsys": "tric",
       "maxiter": 50,
       "threads": 8,
       "program": "psi4"
       }
)

for optimizer in ['berny', 'geometric', 'optking']:

   print(f"Optimizing with {optimizer}")
   ret = qcengine.compute_procedure(opt_input, optimizer, task_config={"ncores": 8, "memory": "2000", "retries": 1}, raise_error=True)
   assert ret.success

   traj0 = ret.trajectory[0].dict()
   print(f"Number of threads used by {optimizer}: {traj0['provenance']['nthreads']}")
   print(f"Memory used by {optimizer}: {traj0['provenance']['memory']}")

Expected behavior

I expect the nthreads field of the provenance to be 8 for all aforementoned cases.

Additional context

  • qcelemental 0.25.1 via psi4 channel
  • qcengine 0.26.0 via psi4 channel
  • geometric 1.0 via pypi
  • pyberny 0.6.3 via pypi
  • OptKing 0.2.1 via psi4 channel
  • psi4 1.7+6ce35a5 via psi4 channel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions