geope.grape¤
geope.grape.Grape
¤
Gradient/Hessian-based GRAPE optimiser for quantum gate synthesis.
Mirrors the Geope usage pattern: it is constructed from a Parameters
object (the single source of truth for all configuration and the live
optimisation state), while the optimiser method, its hyperparameters
and max_steps are arguments of :meth:optimize.
Attributes:
| Name | Type | Description |
|---|---|---|
params |
The bound |
|
precision |
Target fidelity threshold. |
|
method |
Optimiser method from the most recent :meth: |
|
step_size |
Transient last step size (always 0 for GRAPE). |
|
history |
Optional |
__dict__
class-attribute
¤
__doc__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__module__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__weakref__
property
¤
list of weak references to the object
__init__(params, precision=0.9999999, verbose=False, history=None)
¤
Initialise the Grape optimiser.
Grape requires a Parameters object — the engine, initial
parameters, drift, seed, initialisation spread, projective flag and
param_transform are all read from it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
Parameters
|
A |
required |
precision
|
float
|
Target fidelity. Defaults to 0.9999999. |
0.9999999
|
verbose
|
bool
|
Whether to print progress. Defaults to False. |
False
|
history
|
History | None
|
Optional |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
init(init_parameters=None, drift_parameters=None, seed=None)
¤
(Re-)initialise optimiser state.
Sets up initial parameters, drift parameters and the live state
(params.parameters / params.fidelity), and records step 0
into history when one is attached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
init_parameters
|
ndarray | None
|
Initial parameter array. Defaults to random. |
None
|
drift_parameters
|
ndarray | None
|
Fixed drift parameter values. Defaults to ones. |
None
|
seed
|
int | Array | None
|
Random seed (int) or JAX key for reproducibility. |
None
|
optimize(max_steps=100, method='nr-trm', **optimizer_kwargs)
¤
Run the GRAPE optimisation loop.
Iterates gradient/Hessian update steps until the fidelity exceeds
self.precision or max_steps is reached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_steps
|
int
|
Maximum number of optimisation steps. Defaults to 100. |
100
|
method
|
str
|
|
'nr-trm'
|
**optimizer_kwargs
|
float
|
Method hyperparameters — |
required |
Returns:
| Type | Description |
|---|---|
Parameters
|
The bound |
Parameters
|
|
Parameters
|
trajectory and |
Parameters
|
|