dbac.gci¶
Runs the DBAC recursion. GCI (group commutator iteration) applies a step function from
dbac.dbqite again and again, each time to the previous output, and records the energy,
fidelity and state after every step.
See Running the recursion for both modes of GCI and a guide to its
output.
|
Run the DBAC recursion: apply a step function k times, each time to the output of the previous step, and track energy and fidelity. |
Run the recursion and return everything it recorded. |
|
|
Find where a cooling curve first reaches a target fidelity. |
Running the recursion¶
- class GCI(gci_step, state_of_recursion, nmb_steps, times_dbr, please_be_verbose=True)[source]¶
Run the DBAC recursion: apply a step function k times, each time to the output of the previous step, and track energy and fidelity.
The step durations are chosen in one of two modes, selected by nmb_steps:
fixed schedule (
nmb_steps=None): times_dbr lists the duration of each step,[s_1, ..., s_k].greedy line search (
nmb_steps=k): times_dbr lists candidate durations; every step uses the candidate that gives the lowest energy. A warning is emitted if the best candidate is at the edge of the list.
Nothing is computed until execute_gci is called.
- Parameters:
gci_step (Callable) – Step function
step(psi, s) -> state, e.g.dbac.dbqite.QITE_dme_select_M(1)ordbac.dbqite.ideal_DME.state_of_recursion (np.ndarray) – Initial state, a (2, 1) state vector or 2x2 density matrix (or a qibo
Circuit).nmb_steps (int or None) – Number of steps for the line-search mode, or None for the fixed-schedule mode.
times_dbr (sequence[float]) – The schedule (fixed mode) or the candidate durations (line-search mode).
please_be_verbose (bool) – Unused; kept for backwards compatibility.
Example
>>> import numpy as np >>> from dbac.gci import GCI >>> from dbac.dbqite import QITE_dme_select_M >>> from dbac.utils import rx_sweep >>> psi = rx_sweep([0.5])[0] >>> results = GCI(QITE_dme_select_M(1), psi, None, [np.pi / 4, np.pi / 4]).execute_gci() >>> [round(float(F), 3) for F in results[-1]] # fidelity with |0> after 0, 1, 2 steps [0.5, 0.75, 0.875]
- compute_moments(psi)[source]¶
Energy moments of a state with respect to H = -Z.
- Returns:
(E, E2, variance)withE = <H>,E2 = <H^2>andvariance = E2 - E^2. For a density matrix the values are complex-typed (takenp.real); for a qibo circuit onlyEis computed.- Return type:
- execute_gci()[source]¶
Run the recursion and return everything it recorded.
Every list in the result has one entry for the initial state followed by one entry per step.
- Returns:
An 11-tuple, best read from both ends (
results[0]for energies,results[-1]for fidelities,results[-2]for the final state):energies:
Tr(rho H)after each step (takenp.real).step sizes: the durations used, starting with 0.
variances: energy variance after each step.
durations: cumulative evolution time, the sum of
s_j ** 2.label: display label of the step function.
marker: matplotlib marker of the step function.
circuit depths: for qibo-circuit states only, else None.
circuits: for qibo-circuit states only, else None.
states: the state after each step.
final state: the last entry of states.
fidelities: fidelity with
|0>after each step.
- Return type:
Summarizing a cooling curve¶
- max_excitation(thetas, fidelity, target_fidelity, initial_tolerance=1e-05, max_tolerance=0.2, step=0.001)[source]¶
Find where a cooling curve first reaches a target fidelity.
Scans
(thetas[i], fidelity[i])in order and returns the firstthetas[i]whose fidelity is within a tolerance of target_fidelity. The tolerance starts at initial_tolerance and grows by step until a match is found or it exceeds max_tolerance. With a sweep ordered from hot to cold, the result is the hottest initial state that is still cooled to the target: everything colder ends up at least as cold.- Parameters:
thetas (sequence[float]) – x-values of the curve, e.g. the initial fidelities or angles of a sweep.
fidelity (sequence[float]) – Final fidelity for each x-value.
target_fidelity (float) – Fidelity to look for.
initial_tolerance (float) – Starting tolerance.
max_tolerance (float) – Largest tolerance tried before giving up.
step (float) – Increment of the tolerance.
- Returns:
The matching x-value, or None if no point is within max_tolerance of the target.
- Return type:
float or None
Example
>>> from dbac.gci import max_excitation >>> max_excitation([0.1, 0.2, 0.3, 0.4], [0.5, 0.7, 0.9, 0.95], target_fidelity=0.9) 0.3