From d361f4bacb9c143cfb7c4dcd64aac4e4c414c08b Mon Sep 17 00:00:00 2001 From: John Long Date: Mon, 29 Jul 2024 13:23:36 -0400 Subject: [PATCH 1/4] Added docstring for RydbergHamiltonian --- src/bloqade/emulate/ir/state_vector.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/bloqade/emulate/ir/state_vector.py b/src/bloqade/emulate/ir/state_vector.py index 33ffbc3f4..fd28522ba 100644 --- a/src/bloqade/emulate/ir/state_vector.py +++ b/src/bloqade/emulate/ir/state_vector.py @@ -298,6 +298,19 @@ def tocsr(self, time: float) -> csr_matrix: @dataclass(frozen=True) class RydbergHamiltonian: + """Hamiltonian for a given task. + With the `RydbergHamiltonian` you can convert the Hamiltonian to CSR matrix form + as well as obtaining the average energy/variance of a register. + + Attributes: + emulator_ir (EmulatorProgram): A copy of the original program + used to generate the RydbergHamiltonian + space (Space): The Hilbert space of the Hamiltonian, should align with the register the + Hamiltonian is being applied on for average energy/variance + rydberg (NDArray): Rydberg interaction operator + detuning_ops (List[DetuningOperator]): Detuning Operators of the Hamiltonian + rabi_ops (List[RabiOperator]): Rabi Operators of the Hamiltonian + """ emulator_ir: EmulatorProgram space: Space rydberg: NDArray From 0c4c9d676f3a24e91a58197a7a321c29b37ec7e9 Mon Sep 17 00:00:00 2001 From: John Long Date: Mon, 29 Jul 2024 13:26:02 -0400 Subject: [PATCH 2/4] run linter --- src/bloqade/emulate/ir/state_vector.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bloqade/emulate/ir/state_vector.py b/src/bloqade/emulate/ir/state_vector.py index fd28522ba..d9a8024f2 100644 --- a/src/bloqade/emulate/ir/state_vector.py +++ b/src/bloqade/emulate/ir/state_vector.py @@ -298,8 +298,8 @@ def tocsr(self, time: float) -> csr_matrix: @dataclass(frozen=True) class RydbergHamiltonian: - """Hamiltonian for a given task. - With the `RydbergHamiltonian` you can convert the Hamiltonian to CSR matrix form + """Hamiltonian for a given task. + With the `RydbergHamiltonian` you can convert the Hamiltonian to CSR matrix form as well as obtaining the average energy/variance of a register. Attributes: @@ -311,6 +311,7 @@ class RydbergHamiltonian: detuning_ops (List[DetuningOperator]): Detuning Operators of the Hamiltonian rabi_ops (List[RabiOperator]): Rabi Operators of the Hamiltonian """ + emulator_ir: EmulatorProgram space: Space rydberg: NDArray From f5f59f40f626793156db2d01bcb2c02875db575a Mon Sep 17 00:00:00 2001 From: John Long Date: Tue, 30 Jul 2024 09:48:55 -0400 Subject: [PATCH 3/4] Add docstring for hamiltonian generation method --- src/bloqade/ir/routine/bloqade.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/bloqade/ir/routine/bloqade.py b/src/bloqade/ir/routine/bloqade.py index 4140f0faf..8f7d12d30 100644 --- a/src/bloqade/ir/routine/bloqade.py +++ b/src/bloqade/ir/routine/bloqade.py @@ -503,7 +503,31 @@ def hamiltonian( waveform_runtime: str = "interpret", cache_matrices: bool = False, ) -> List[BloqadeEmulation]: + """ + Generates a list of BloqadeEmulation objects which contain the Hamiltonian of your program. + + If you have a variable(s) in your program you have assigned multiple values via `batch_assign()` + there will be multiple `BloqadeEmulation` objects, one for each value. On the other hand + if the program only assumes a singular value per each variable, there will only be + one `BloqadeEmulation` object but it will still be encapsulated in a list. + + + Args: + *args (LiteralType): If your program has a variable that was declared as run-time assignable + via `.args` you may pass a value to it here. If there are multiple + variables declared via `.args` the order in which you assign values to those variables + through this argument should follow the order in which the declaration occurred. + blockade_radius (float): The radius in which atoms blockade eachother. Default value is 0.0 micrometers. + use_hyperfine (bool): Should the Hamiltonian account for hyperfine levels. Default value is False. + waveform_runtime (str): Specify which runtime to use for waveforms. If "numba" is specify the waveform + is compiled, otherwise it is interpreted via the "interpret" argument. Defaults to "interpret". + cache_matrices (bool): Speed up Hamiltonian generation by reusing data (when possible) from previously generated Hamiltonians. + Default value is False. + Returns: + + + """ ir_iter = self._generate_ir( args, blockade_radius, waveform_runtime, use_hyperfine ) From c422a1da544184d39122eec7d05b6c12d2856c6b Mon Sep 17 00:00:00 2001 From: John Long Date: Tue, 30 Jul 2024 11:24:08 -0400 Subject: [PATCH 4/4] Add return to hamiltonian() docstring --- src/bloqade/ir/routine/bloqade.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bloqade/ir/routine/bloqade.py b/src/bloqade/ir/routine/bloqade.py index 8f7d12d30..f991fe06f 100644 --- a/src/bloqade/ir/routine/bloqade.py +++ b/src/bloqade/ir/routine/bloqade.py @@ -525,7 +525,7 @@ def hamiltonian( Default value is False. Returns: - + List[BloqadeEmulation] """ ir_iter = self._generate_ir(