protocols
errors
- exception qmetro.protocols.errors.EnvDimsError(env_inp_dim, env_out_dim, *args, **kwargs)[source]
Bases:
ValueErrorRaised when channel’s environment input and output dimensions are not the same.
- Parameters:
env_inp_dim (int) – Environment input dimension.
env_out_dim (int) – Environment output dimension.
- exception qmetro.protocols.errors.UnitalDimsError(inp_dims, out_dims, *args, **kwargs)[source]
Bases:
ValueErrorRaised when comb’s teeth are unital but channel input and output dimensions are not the same.
- Parameters:
inp_dims (list[int]) – Input dimensions.
out_dims (list[int]) – Output dimensions.
iss
- qmetro.protocols.iss.iss_adaptive_qfi(channel, number_of_channels, ancilla_dim, artificial_noise_after=None, env_inp_state=None, **kwargs)[source]
Computes quantum Fisher information channels in an adaptive control system called quantum comb using iterative see-saw (ISS) algorithm [22, 27].
In this approach we consider n copies of a quantum channel Phi:
Phi_i: L(env_i (x) in_i) -> L(env_i+1 (x) out_i) for i = 0, …, n - 1,
put in a quantum comb C from a set:
Comb[(Null, in_0), (out_0, in_1), …, (out_n-2, in_n-1 (x) anc)],
and a measurement at the end:
P: L(out_n-1 (x) anc) -> R,
where (x) denotes a tensor product of Hilbert spaces.
The input of the first environment space (env_0) is initialized with env_inp_state and the last environment spcace (env_n) is traced out.
- Parameters:
channel (ParamChannel) – Channel to compute quantum Fisher information for. In case this argument is a comb created from single channels the control operation (comb’s tooth) will be put between every single channel.
number_of_channels (int) – Number of channel uses. In case channel is a comb created from m single channels the total number of channels will be equal to number_of_channels * m.
ancilla_dim (int) – Dimension of the ancilla space connecting controls (teeth), dim(anc).
artificial_noise_after (bool, optional) – Whether auxiliary noise is added after the channel: - True : auxiliary noise is added after the channel, - False : auxiliary noise is added before the channel, - None : auxiliary noise is not used. By default True.
env_inp_state (np.ndarray | None, optional) – Density matrix of the initial state of the environment. If None then it becomes a maximally mixed state.
- Returns:
qfi (float) – Quantum Fisher information.
qfis (list[floats]) – A list of quantum Fisher informations acvhieved in each iteration. The last value in the list is the final solution.
comb (np.ndarray) – Choi matrix of the optimal comb with spaces in order: inp_0, …, inp_n-1, anc, out_0, …, out_n-2.
L (np.ndarray) – Optimal syymetric logaritmic derivative (SLD) matrix with spaces in order: out_n-1, anc.
status (bool) – True if the algorithm converged, False otherwise.
- Return type:
tuple[float, list[float], ndarray, ndarray, bool]
- qmetro.protocols.iss.iss_channel_qfi(channel, ancilla_dim=1, env_inp_state=None, artificial_noise_after=True, **kwargs)[source]
Computes quantum Fisher information for a single parametrized channel using iterative see-saw (ISS) method [22, 27].
- Parameters:
channel (ParamChannel) – Channel to compute quantum Fisher information for. In case this argument is a comb created from single channels the whole comb will be treated as a single channel.
ancilla_dim (int, optional) – Dimension of the ancilla, by default 1.
env_inp_state (np.ndarray | None, optional) – Density matrix of the initial state of the environment. If None then it becomes a maximally mixed state.
artificial_noise_after (bool | None, optional) – Whether auxiliary noise is added after the channel: - True : auxiliary noise is added after the channel, - False : auxiliary noise is added before the channel, - None : auxiliary noise is not used. By default True.
kwargs – Additional arguments passed on to
iss_optseeIssConfigfor details.
- Returns:
qfi (float) – Quantum Fisher information.
qfis (list[float]) – QFI per algorithm iteration number.
input_state (np.ndarray) – Density matrix of the optimal input state. The input space of the channel goes first and the ancilla second.
sld (np.ndarray) – Symmetric loagarithmic derivative. The output space of the channel goes first and the ancilla second.
status (bool) – True if the algorithm converged, False otherwise.
- Return type:
tuple[float, list[float], ndarray, ndarray, bool]
- qmetro.protocols.iss.iss_parallel_qfi(channel, number_of_channels, ancilla_dim, artificial_noise_after=None, env_inp_state=None, **kwargs)[source]
Computes quantum Fisher information for channels in parallel using iterative see-saw (ISS) algorithm [17, 27].
In parallel strategy all channels are simultaneously probed by an entangled input state and their output is collectively measured.
- Parameters:
channel (ParamChannel) – Channel to compute quantum Fisher information for.
number_of_channels (int) – Number of channel uses. In case channel is a comb created from m single channels the total number of channels will be equal to number_of_channels * m.
ancilla_dim (int) – Dimension of the ancilla space.
artificial_noise_after (bool | None, optional) – Whether auxiliary noise is added after the channel: - True : auxiliary noise is added after the channel, - False : auxiliary noise is added before the channel, - None : auxiliary noise is not used. By default None.
env_inp_state (np.ndarray | None, optional) – Density matrix of the initial state of the environment. If None then it becomes a maximally mixed state.
kwargs – Additional arguments passed on to iss optimization function.
- Returns:
qfi (float) – Qunatum Fisher information.
qfis (list[float]) – QFI per algorithm iteration number.
input_state (np.ndarray) – Density matrix of the optimal input state. The input spaces of the channels go first and the ancilla goes last.
sld (np.ndarray) – Symmetric loagarithmic derivative. The output spaces of the channels go first and the ancilla goes last.
status (bool) – True if the algorithm converged, False otherwise.
- Return type:
tuple[float, list[float], ndarray, ndarray, bool]
- qmetro.protocols.iss.iss_tnet_adaptive_qfi(channel, number_of_channels, ancilla_dim, unital_teeth=False, initial_teeth=None, initial_sld=None, artificial_noise_after=True, fixed_teeth=None, env_inp_state=None, **kwargs)[source]
Computes quantum Fisher information in an adaptive control system called quantum comb using iterative see-saw (ISS) algorithm [22, 27].
In this approach we consider n copies of a quantum channel Phi:
Phi_i: L(env_i (x) in_i) -> L(env_i+1 (x) out_i) for i = 0, …, n - 1,
intertwined with n maps called teeth: - input state (or 0-th tooth):
T_0: C -> L(in_0 (x) anc_0),
(proper) teeth:
T_i: L(out_i-1 (x) anc_i-1) -> L(in_i (x) anc_i) for i = 1, …, n - 1,
which constitute an adaptive control system called quantum comb and a measurement at the end:
P: L(out_n-1 (x) anc_n-1) -> R.
The input of the first environment space (env_0) is initialized with env_inp_state and the last environment spcace (env_n) is traced out.
- Parameters:
channel (ParamChannel) – Channel to compute quantum Fisher information for. In case this argument is a comb created from single channels the control operation (tooth) will be put between every single channel.
number_of_channels (int) – Number of channel uses. In case channel is a comb created from m single channels the total number of channels will be equal to number_of_channels * m.
ancilla_dim (int) – Dimension of the ancilla space connecting controls (teeth), dim(anc_i).
unital_teeth (bool, optional) – If True than all proper teeth (T_i with i>0) are constrained to be unital, that is they preserve identity matrix T_i(Id) = Id, by default False.
initial_teeth (list[np.ndarray] | None, optional) – Initial values of teeth: [T_0, T_1, …]. First element that is the value for the input state should be its density matrix with spaces in the order: (inp_0, anc_0). For proper teeth it should be Choi matrices with spaces in the order: (inp_i, anc_i, out_i-1, anc_i-1), by default None.
initial_sld (np.ndarray | None, optional) – Initial value of SLD matrix with spaces in order (out_n-1, anc_n-1), by default None.
artificial_noise_after (bool, optional) – Whether auxiliary noise is added after the channel: - True : auxiliary noise is added after the channel, - False : auxiliary noise is added before the channel, - None : auxiliary noise is not used. By default True.
fixed_teeth (list[tuple[int, np.ndarray]] | None, optional) – Teeths to be fixed during optimization. Element (i, Ti) in the list means that tooth number i will be fixed to Ti. Note that this value will replace the value given in initial_teeth argument, by default None.
env_inp_state (np.ndarray | None, optional) – Density matrix of the initial state of the environment. If None then it becomes a maximally mixed state.
- Returns:
qfi (float) – Quantum Fisher information.
qfis (list[floats]) – A list of quantum Fisher informations acvhieved in each iteration. The last value in the list is the final solution.
Ts (list[np.ndarray]) – List of optimal teeth in the form of density matrix and Choi matrices. For the i-th element - T_i spaces are in order: - (inp_0, anc_0) for i=0, - (inp_i, anc_i, out_i-1, anc_i-1) for i>0.
L (np.ndarray) – Optimal syymetric logaritmic derivative (SLD) matrix with spaces in order: out_n-1, anc.
status (bool) – True if the algorithm converged, False otherwise.
- Return type:
tuple[float, list[float], list[ndarray], ndarray, bool]
- qmetro.protocols.iss.iss_tnet_collisional_qfi(channel, number_of_channels, ancilla_dim, mps_bond_dim, measure_bond_dim, unital_teeth=False, initial_teeth=None, artificial_noise_after=True, fixed_teeth=None, env_inp_state=None, **kwargs)[source]
Returns the quantum Fisher information in a scenario with channels in a comb whose teeth have separate ancillas using the iterative see-saw (ISS) algorithm [17, 22, 27]. This is a very similar structure to the one in the adaptive strategy the only difference being that the comb’s teeth cannot communicate with each other using their common ancilla space.
More precisely, in this approach we consider n copies of a quantum channel Phi:
Phi_i: L(env_i (x) in_i) -> L(env_i+1 (x) out_i) for i = 0, …, n - 1,
an input state:
rho0 in L(in_0 (x) anc_0 (x) … (x) anc_n-2),
controls called also teeth:
T_i: L(out_i-1 (x) anc_i-1) -> L(in_i (x) anc’_i-1) for i = 1, …, n - 1,
and measurement at the end:
P: L(anc’_0 (x) … (x) anc’_n-2 (x) out_n-1) -> R.
The input of the first environment space (env_0) is initialized with env_inp_state and the last environment spcace (env_n) is traced out.
- Parameters:
channel (ParamChannel) – Channel to compute quantum Fisher information for. In case this argument is a comb created from single channels the control operation (comb’s tooth) will be put between every single channel.
number_of_channels (int) – Number of channel uses. In case channel is a comb created from m single channels the total number of channels will be equal to number_of_channels * m.
ancilla_dim (int) – Dimension of the ancilla space connecting controls (teeth).
mps_bond_dim (int) – Dimension of the bond space of the input state which is a matrix product state.
measure_bond_dim (int) – Dimension of the bond space of the measurement (SLD matrix) which is a matrix product operator.
unital_teeth (bool, optional) – If True than all proper teeth (T_i with i>0) are constrained to be unital, that is they preserve identity matrix T_i(Id) = Id, by default False.
initial_teeth (list[np.ndarray] | None, optional) – Initial values of teeth: [T_1, …]. For T_i it should be its Choi matrix with spaces in the order: (inp_i, anc’_i-1, out_i-1, anc_i-1), by default None.
artificial_noise_after (bool, optional) – Whether auxiliary noise is added after the channel: - True : auxiliary noise is added after the channel, - False : auxiliary noise is added before the channel, - None : auxiliary noise is not used. By default True.
fixed_teeth (list[tuple[int, np.ndarray]] | None, optional) – Teeths to be fixed during optimization. Element (i, Ti) in the list means that tooth number i will be fixed to Ti. Note that this value will replace the value given in initial_teeth argument, by default None.
env_inp_state (np.ndarray | None, optional) – Density matrix of the initial state of the environment. If None then it becomes a maximally mixed state.
- Returns:
qfi (float) – Quantum Fisher information.
qfis (list[floats]) – A list of quantum Fisher informations computed in each iteration. The last value in the list is the final solution.
input_state (list[np.array]) – The optimal matrix product state (MPS). The i-th tensor on the list - R_i is the input of the i-th channel except the last which is the part going to ancilla. Its indices are in the order: bond space connecting to the previous tensor (if it exists), input state of the channel/ancilla, bond space connecting to the next tensor (if it exists).
Ts (list[np.ndarray]) – List of optimal teeth [T_1, T_2, …] in the form of their Choi matrices. For the i-th element - T_i spaces are in order (inp_i, anc’_i-1, out_i-1, anc_i-1).
sld (list[np.array]) – Matrix product operator (MPO) of the optimal symmetric logarithmic derivative (SLD). For i < n-1 i-th tensor on the list is a sld element on anc’_i then the last tensor on the list is a sld element on space out_n-1. Indices/spaces of the i-th tnesor are in the order: bond space connecting to the previous tensor (if it exists), out_n-1 or anc’_i-1, bond space connecting to the next tensor (if it exists).
status (bool) – True if the algorithm converged, False otherwise.
- Return type:
tuple[float, list[float], list[ndarray], list[ndarray], list[ndarray], bool]
- qmetro.protocols.iss.iss_tnet_parallel_qfi(channel, number_of_channels, ancilla_dim, mps_bond_dim, measure_bond_dim, artificial_noise_after=None, env_inp_state=None, **kwargs)[source]
Computes quantum Fisher information for channels in parallel using iterative see-saw algorithm and tensor networks [17, 27].
In the parallel strategy all channels are simultaneously probed by an entangled input state and their output is collectively measured.
In the approach with tensor networks the input state is expressed as a tensor network in a shape of a line where i-th tensor represents part of the input state that goes to the i-th probe channel and has is connected with two other tensors (one tensor in case of the first and the last one) with bond spaces/indices.
The measurement and then the symmetric logarithmic derivative (SLD) matrix is expressed as an analogous tensor network (representing operators instead of states) called matrix product operator (MPO).
- Parameters:
channel (ParamChannel) – Channel to compute quantum Fisher information for.
number_of_channels (int) – Number of channel uses. In case channel is a comb created from m single channels the total number of channels will be equal to number_of_channels * m.
ancilla_dim (int) – Dimension of the ancilla space.
mps_bond_dim (int) – Dimension of the bond space of the input state which is a matrix product state (MPS).
measure_bond_dim (int) – Dimension of the bond space of the measurement (SLD) which is a matrix product operator.
artificial_noise_after (bool | None, optional) – Whether auxiliary noise is added after the channel: - True : auxiliary noise is added after the channel, - False : auxiliary noise is added before the channel, - None : auxiliary noise is not used. By default None.
env_inp_state (np.ndarray | None, optional) – Density matrix of the initial state of the environment. If None then it becomes a maximally mixed state.
kwargs – Additional arguments passed on to iss optimization function.
- Returns:
qfi (float) – Qunatum Fisher information.
qfis (list[float]) – QFI per algorithm iteration number.
input_state (list[np.array]) – The optimal matrix product state (MPS). The i-th tensor on the list - R_i is the input of the i-th channel except the last which is the part going to ancilla. Its indices are in the order: bond space connecting to the previous tensor (if it exists), input state of the channel/ancilla, bond space connecting to the next tensor (if it exists).
sld (list[np.array]) – Matrix product operator (MPO) of the optimal symmetric logarithmic derivative (SLD). The i-th tensor on the list - L_i is sld MPO elemnt on the output of the i-th channel except the last one which is on ancilla. Its indices/spaces are in the order: bond space connecting to the previous tensor (if it exists), channel output or ancilla, bond space connecting to the next tensor (if it exists).
status (bool) – True if the algorithm converged, False otherwise.
- Return type:
tuple[float, list[float], list[ndarray], list[ndarray], bool]
mop
- qmetro.protocols.mop.mop_adaptive_qfi(channel, number_of_channels, env_control=False, env_inp_state=None, input_pure_qfi=0, **kwargs)[source]
Computes the comb QFI using minimization over purifications method (MOP) [19, 22, 27].
This function computes the QFI of comb consisting of
number_of_channelsparameter-encoding channels connected with their environments.Notice that
channelmay be a single channel or a comb created by the user. The resulting QFI is achievable when arbitrary adaptive control can be applied in each step. Control may act between channels, but also between different teeth ofchannel, whenchannelrepresents a comb.- Parameters:
channel (ParamChannel) – Parametrized channel characterizing signal encoding. Might be a single channel or a comb.
number_of_channels (int) – Number of elementary channels/combs linked to create the full comb of interest.
env_control (bool | tuple[bool, bool], optional) – If True, then adaptive control may also act on first input and last output environment. If tuple, then its elements refer to input and output environment respectively.
env_inp_state (np.ndarray | None, optional) – Density matrix of the initial state of the environment. If None then it becomes a maximally mixed state. This argument is ignored when environment input is controlled.
input_pure_qfi (float, optional) – The QFI of an additional pure parameter-dependent state. This state can be treated as a first tooth of estimated comb. By default, there is no such a state (input_pure_qfi = 0). Non-zero values are typically used to calculate bounds.
**kwargs – Additional keyword arguments passed to the CVXPY
solvemethod (see docs).
- Returns:
Quantum Fisher Information optimized over all comb controls.
- Return type:
float
- qmetro.protocols.mop.mop_channel_qfi(channel, env_inp_state=None, **kwargs)[source]
Computes quantum Fisher information for a single parametrized channel using the minimization over purifications (MOP) method [12, 22, 27].
- Parameters:
channel (ParamChannel) – Channel to compute quantum Fisher information for. In case this argument is a comb created from single channels the whole comb will be treated as a single channel.
env_inp_state (np.ndarray | None, optional) – Density matrix of the initial state of the environment. If None then it becomes a maximally mixed state.
**kwargs –
Additional keyword arguments passed to the CVXPY
solvemethod (see docs).
- Returns:
qfi – maximal QFI of a single channel.
- Return type:
float
- qmetro.protocols.mop.mop_parallel_qfi(channel, number_of_channels, env_inp_state=None, **kwargs)[source]
Computes quantum Fisher information in a scenario with parallel channels [12, 27].
- Parameters:
channel (ParamChannel) – Channel to compute quantum Fisher information for.
number_of_channels (int, optional) – Number of channel uses. In case
channelis a comb created frommsingle channels the total number of channels will be equal tonumber_of_channels * m.env_inp_state (np.ndarray | None, optional) – Density matrix of the initial state of the environment. If None then it becomes a maximally mixed state.
**kwargs –
Additional keyword arguments passed to the CVXPY
solvemethod (see docs).
- Returns:
qfi – Qunatum Fisher information.
- Return type:
float
other
- qmetro.protocols.other.multiple_measurements_qfi(single_qfis, ns=None)[source]
For a list of QFIs for measurements with n = 1, 2, …, max_n probes computes optimal QFI for each number of probes ditributed among multiple measurments.
If QFI at some point starts to scale with number of probes sublinearly for example:
QFI1 = 1, QFI2 = 2.1, QFI3 = 2.7, …
then it is advantegous to use probes in multiple measurements. In this case:
QFI1_opt = QFI1, QFI2_opt = QFI2, QFI3_opt = 3 * QFI1, …
In general, it requires solving a special case of a knapsack problem .
- Parameters:
single_qfis (list[float]) – List of QFIs obtained in a single measurement such that single_qfi[i] is QFI obtained with i + 1 probes.
ns (list[int] | None, optional) – If provided number of probes for single_qfi[i] is ns[i], by default None.
- Returns:
qfis (list[float]) – List of optimal QFIs such that single_qfi[i] is QFI obtained with i probes (note the shift -1 shift from single_qfis ordering).
strategies (list[list[int]]) – List of optimal strategies. The element strategies[i] is a list of single measurements constituting the optimal strategy for i probes.
- Return type:
tuple[list[float], list[list[int]]]
- qmetro.protocols.other.state_cfi(state, povm, eps=1e-07)[source]
Calculates classical Fisher information of a quantum state represented by density matrix and its derivative over estimated parameter for a given measurement represented by POVM.
- Parameters:
state (tuple[np.ndarray, np.ndarray]) –
- A tuple containing:
- rho: np.ndarray
Density matrix
- drho: np.ndarray
Derivative of density matrix over estimated parameter
povm (list[np.ndarray]) – List of operators defining a generalized measurement (POVM)
eps (float, optional) – probabilities smaller then eps will not contribute to cfi
- Returns:
Classical Fisher information for input state and measurement
- Return type:
float
- qmetro.protocols.other.state_qfi(state, **kwargs)[source]
Calculates quantum Fisher information of a quantum state represented by density matrix and its derivative over estimated parameter.
- Parameters:
state (tuple[np.ndarray, np.ndarray]) –
- A tuple containing:
- rho: np.ndarray
Density matrix
- drho: np.ndarray
Derivative of density matrix over estimated parameter
**kwargs –
Additional keyword arguments passed to the CVXPY
solvemethod (see docs).
- Returns:
float – State qfi
np.ndarray – Symmetric logarithmic derivative (SLD) matrix
- Return type:
tuple[float, ndarray]