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
Add concurrency support for effective_hamiltonian in labs (#8081)
**Context:**
Implements concurrency in `effective_hamiltonian` to support running
parallel jobs.
**Description of the Change:**
**Benefits:**
**Possible Drawbacks:**
**Related GitHub Issues:**
"""Only used to initialize accumulators for summing Fragments"""
@@ -39,14 +41,25 @@ def effective_hamiltonian(
39
41
fragments: dict[Hashable, Fragment],
40
42
order: int,
41
43
timestep: float=1.0,
44
+
num_workers: int=1,
45
+
backend: str="serial",
42
46
):
43
-
r"""Compute the effective Hamiltonian :math:`\hat{H}_{eff} = \hat{H} + \hat{\epsilon}` that corresponds to a given product formula.
47
+
r"""Compute the effective Hamiltonian :math:`\hat{H}_{eff} = \hat{H} + \hat{\epsilon}` that
48
+
corresponds to a given product formula.
44
49
45
50
Args:
46
-
product_formula (ProductFormula): A product formula used to approximate the time-evolution operator for a Hamiltonian.
47
-
fragments (Dict[Hashable, :class:`~.pennylane.labs.trotter_error.Fragment`): The fragments that sum to the Hamiltonian. The keys in the dictionary must match the labels used to build the :class:`~.pennylane.labs.trotter_error.ProductFormula` object.
51
+
product_formula (ProductFormula): A product formula used to approximate the time-evolution
52
+
operator for a Hamiltonian.
53
+
fragments (Dict[Hashable, :class:`~.pennylane.labs.trotter_error.Fragment`): The fragments
54
+
that sum to the Hamiltonian. The keys in the dictionary must match the labels used to
55
+
build the :class:`~.pennylane.labs.trotter_error.ProductFormula` object.
48
56
order (int): The order of the approximatation.
49
57
timestep (float): The timestep for simulation.
58
+
num_workers (int): the number of concurrent units used for the computation. Default value is
59
+
set to 1.
60
+
backend (string): the executor backend from the list of supported backends.
61
+
Available options : "mp_pool", "cf_procpool", "cf_threadpool", "serial", "mpi4py_pool",
62
+
"mpi4py_comm". Default value is set to "serial".
50
63
51
64
**Example**
52
65
@@ -78,15 +91,38 @@ def effective_hamiltonian(
78
91
raiseValueError("Fragments do not match product formula")
0 commit comments