paraqeet.model.differentiable_hamiltonian.DifferentiableHamiltonian#
- class paraqeet.model.differentiable_hamiltonian.DifferentiableHamiltonian(drives=None)#
Bases:
Differentiable,HamiltonianA Hamiltonian that also satisfies the differentiable interface. It requires a gradient function that works on a per timestep basis and provides a vectorized mapping to evaluate multiple time values.
- Parameters:
drives (list[Drive] | None)
Methods
__init__([drives])Return the dimension of the Hilbert space of this Hamiltonian.
Return a list tuples of decay rates and collapse operators for each subsystem.
get_gradient_at_timestep(time)Compute the gradient of this Hamiltonian wrt to parameters for a single timestep.
Return all parameters of this class that can be optimized.
get_value(times)Return the matrix representation of the Hamiltonian.
get_value_and_gradient(times)Compute value and gradient for given timesteps.
get_value_at_timestep(timestep)Return the matrix representation of the Hamiltonian.
set_all_optimizable_parameters(all_params)Set all optimizable parameters in the optimization.
set_optimizable_parameters(params)Set which parameters associated with the object shall be considered during optimization.
Attributes
Get the optimizable parameters
Return the list of Drives of the system.
Get the name of the parameter.
Get the optimizable parameters
- property all_optimizable_parameters: list[Quantity]#
Get the optimizable parameters
- Returns:
The list of all the optimizable parameters considered in the optimization
- Return type:
list[Quantity]
- abstract dimension()#
Return the dimension of the Hilbert space of this Hamiltonian.
- Returns:
Returns the dimension of the Hilbert space of this Hamiltonian.
- Return type:
int
- property drives: list[Drive]#
Return the list of Drives of the system.
- Returns:
Returns a list of time-dependent drives of the system.
- Return type:
list[Drive]
- abstract get_collapseops()#
Return a list tuples of decay rates and collapse operators for each subsystem.
- Returns:
List of collapse operators
- Return type:
list[Tuple[Array, Array]]
- abstract get_gradient_at_timestep(time)#
Compute the gradient of this Hamiltonian wrt to parameters for a single timestep.
- Parameters:
time (float)
- Return type:
Array
- abstract get_parameters()#
Return all parameters of this class that can be optimized.
- Raises:
NotImplementedError – Subclasses derived from this class must implement this method.
- Return type:
list[Quantity]
- get_value(times)#
Return the matrix representation of the Hamiltonian.
The default implementation calls get_value_at_timestep for each time step. Subclasses can override this function for a more efficient implementation.
- Parameters:
times (Array) – Vector of time samples.
- Returns:
Hamiltonian of shape [t, n, n] with ‘t’ as time and ‘n’ as the Hilbert space dimension.
- Return type:
Array
- get_value_and_gradient(times)#
Compute value and gradient for given timesteps. The gradient call uses vmap over at_timestep methods.
- Parameters:
times (Array)
- Return type:
tuple[Array, Array]
- abstract get_value_at_timestep(timestep)#
Return the matrix representation of the Hamiltonian.
- Parameters:
timestep (float) – One time point.
- Returns:
Hamiltonian of shape [n, n] with n as the Hilbert space dimension.
- Return type:
Array
- property name: str | None#
Get the name of the parameter.
- Returns:
Name of the parameter.
- Return type:
str | None
- property optimizable_parameters: list[Quantity]#
Get the optimizable parameters
- Returns:
The list of optimizable parameters associated with the object.
- Return type:
list[Quantity]
- set_all_optimizable_parameters(all_params)#
Set all optimizable parameters in the optimization.
- set_optimizable_parameters(params)#
Set which parameters associated with the object shall be considered during optimization.
All quantities that are not in the response of get_parameters will be filtered out. This function is called by the optimizer before gradient based optimization to tell the layers which gradients to compute.
- Parameters:
params (list[Quantity]) – List of optimizable parameters to be set.
- Return type:
None