param_channel

creators

qmetro.param_channel.creators.cmarkov_channel(channels, trans_mat)[source]

Creates a channel encoding classical Markovian correlations between a list of channels with transition probabilities given by the transition matrix.

It is a channel G such that G.link_env(G, …, G) is a comb representing a Markov chain of channels from the input list.

Formally, for a list of channels F0, F1, …, Fn-1 of the form L(H) -> L(K) and a transition matrix T, the function constructs a channel G: L(H x E) -> L(K x E), where E is a newly created environment space of dimension n. When the environment is in the i-th state G applies Fi and changes the state of the environment to j with probability T[i, j]. In this way, the state of the environment encodes which channel from the list will be applied next.

Parameters:
  • channels (list[ParamChannel]) – List of channels F0, …, Fn-1to be connected in a chain. All must have the same input and output space dimensions, be single (not comb) and have trivial environments.

  • trans_mat (np.ndarray) – Transition matrix defining the transition probabilities, that is T[i, j] is the probability of transiting from channel i to channel j.

Returns:

channel – Channel G encoding the Markovian correlations.

Return type:

ParamChannel

qmetro.param_channel.creators.depolarization(p, noise_first=True, eta=None, **kwargs)[source]

Returnes paramtrised channel of a qubit channel where:

  • the signal is rotating Bloch sphere around the z-axis,

  • noise shrinks uniformly the whole Bloch ball.

See more details in the documentation.

Parameters:
  • p (float) – Probability that the input state will remain unchanged.

  • noise_first (bool, optional) – Whether noise is before signal, by default True.

  • eta (float | None, optional) – Alternative method of determining the noise strength that when provided is used instead of p (either p or eta argument has to be provided). In this parametrisation eta is the factor by which Bloch sphere gets shrunken.

  • **kwargs (dict, optional) – Arguments that will be passed to ParamChannel constructor.

Returns:

channel – Parametrised channel.

Return type:

ParamChannel

qmetro.param_channel.creators.par_amp_damping(p, noise_first=True, **kwargs)[source]

Returnes parametrised channel of a qubit channel where:

  • the signal is rotating Bloch sphere around the z-axis,

  • noise models decay from state |1⟩ to |0⟩.

See more details in the documentation.

Parameters:
  • p (float) – Noise strength. For p = 1 there is no noise for p = 0 the noise is maximal.

  • noise_first (bool, optional) – Whether noise is before signal, by default True.

  • **kwargs (dict, optional) – Arguments that will be passed to ParamChannel constructor.

Returns:

channel – Parametrised channel.

Return type:

ParamChannel

qmetro.param_channel.creators.par_dephasing(p, noise_first=True, eps=None, rot_like=False, c=None, **kwargs)[source]

Returnes paramtrised channel of a qubit channel where:

  • the signal is rotating Bloch sphere around the z-axis,

  • noise shrinks the xy-plane preserving the z-axis.

See more details in the documentation.

Parameters:
  • p (float) – Probability that the input state will remain unchanged.

  • noise_first (bool, optional) – Whether noise is before signal, by default True.

  • eps (float | None, optional) –

    Alternative way of determining the noise strength:

    p = cos(eps/2)**2,

    that when provided is used instead of p (p argument is ignored).

  • rot_like (bool, optional) –

    If True then Kraus operators of noise are:

    K+ = exp(-1j/2 * eps * sigma_z) / sqrt(2), K- = exp(+1j/2 * eps * sigma_z) / sqrt(2),

    where p = cos(eps/2)**2, by default False.

  • c (float | None, optional) – Correlation parameter from the interval [-1, 1]. When set it will put rot_like=True and create a channel with environment space such that K+ and K- will be correlated (see also cmarkov_channel() ). They are fully correlated for c=1, no correlated for c=0 and anticorrelated for c=-1. If None creates ParamChannel without environment space. By default None.

  • **kwargs (dict, optional) – Arguments that will be passed to ParamChannel constructor.

Returns:

channel – Parametrised channel.

Return type:

ParamChannel

qmetro.param_channel.creators.per_amp_damping(p, noise_first=True, **kwargs)[source]

Returnes paramtrised channel of a qubit channel where:

  • the signal is rotating Bloch sphere around the z-axis,

  • noise models decay from state |+⟩ to |-⟩.

See more details in the documentation.

Parameters:
  • p (float) – Noise parametrization. For p = 1 there is no noise for p = 0 the noise is maximal.

  • noise_first (bool, optional) – Whether noise is before signal, by default True.

  • **kwargs (dict, optional) – Arguments that will be passed to ParamChannel constructor.

Returns:

channel – Parametrised channel.

Return type:

ParamChannel

qmetro.param_channel.creators.per_dephasing(p, noise_first=True, **kwargs)[source]

Returnes paramtrised channel of a qubit channel where:

  • the signal is rotating Bloch sphere around the z-axis,

  • noise shrinks the yz-plane preserving the x-axis.

See more details in the documentation.

Parameters:
  • p (float) – Probability that the input state will remain unchanged.

  • noise_first (bool, optional) – Whether noise is before signal, by default True.

  • **kwargs (dict, optional) – Arguments that will be passed to ParamChannel constructor.

Returns:

channel – Parametrised channel.

Return type:

ParamChannel

ParamChannel

class qmetro.param_channel.param_channel.ParamChannel(*, krauses=None, choi=None, dkrauses=None, dchoi=None, env_dim=1, sdict=<qmetro.qmtensor.classes.tensors.SpaceDict object>, input_dim=None, output_dim=None)[source]

Class representing parametrized channels which can additionally act on an “environment” space that is used to construct correlations between multiple channels [22, 27].

More precisely it is representing a CPTP map parametrized by t:

F_t: L(E_i (x) I) -> L(E_o (x) O),

where L(X) is the space of linear operators on Hilbert space X and - (x) is a tensor product of spaces, - I and O are spaces of input and output respectively, - E_i and E_o are input and output environment spaces respectively.

Note that formally the input space of F_t is E_i (x) I. Thus to avoid confusion E_i (x) I is called ‘total input space’ and I is called ‘input space’. Anlogously, E_o (x) O is called ‘total output space’ and O is called ‘output space’.

Objects can be initialized in two different ways: 1) By providing kraus operators and their derivatives 2) By providing choi matrix and its derivative.

Class constructor takes keyword-only arguments.

Parameters:
  • krauses (list[np.ndarray] | None, optional) – Kraus operators, by default None. Each operator is assumed to act from E_i (x) I to E_o (x) O.

  • choi (np.ndarray | None, optional) – Choi matrix, by default None. It is assumed to be a matrix on E_o (x) O (x) E_i (x) I.

  • dkrauses (list[np.ndarray] | None, optional) – Derivatives of Kraus operators, by default None. Each operator is assumed to act from E_i (x) I to E_o (x) O.

  • dchoi (np.ndarray | None, optional) – Derivative of Choi matrix, by default None. It is assumed to be a matrix on E_o (x) O (x) E_i (x) I.

  • env_dim (int | tuple[int,int], optional) – Environment dimension, that is the value of dimE_i = dimE_o or a tuple (E_i, E_o). By default 1.

  • sdict (SpaceDict, optional) – Space distionary of the tensor, by default DEFAULT_SDICT.

  • input_dim (int | None, optional) – Dimenion of input space I or for I = I_0 (x) … (x) I_n-1 it should be a list [dimI_0, …, dimI_n-1]. If None then this dimension is derived from other arguments, by default None.

  • output_dim (int | None, optional) – Dimenion of output space O or for O = O_0 (x) … (x) O_n-1 it should be a list [dimO_0, …, dimO_n-1]. If None then this dimension is derived from other arguments, by default None.

kraus_like_inp

Whether the object was initialized using Kraus operators.

Type:

bool

choi_like_inp

Whether the object was initialized using Choi matrix.

Type:

bool

input_dim

Dimension of input space I.

Type:

int

output_dim

Dimension of output space O.

Type:

int

input_dims

Dimensions of factors of input space I.

Type:

list[int]

output_dims

Dimensions of factors of output space O.

Type:

list[int]

env_inp_dim

Dimension of environment input space E_i.

Type:

int

env_out_dim

Dimension of environment output space E_o.

Type:

int

id

Unique identifier of the object.

Type:

int

sdict

Space dictionary of the object.

Type:

SpaceDict

input_spaces

Names of factors of input space I.

Type:

list[Hashable]

output_spaces

Names of factors of output space O.

Type:

list[Hashable]

env_inp

Name of environment input space E_i.

Type:

Hashable

env_out

Name of environment output space E_o.

Type:

Hashable

Raises:

ValueError – Raised when 2 possible input modes are mixed or when env_dim and/or channel_out_dim are incompatible with the shape of Kraus operators/Choi matrix.

Attributes:
is_comb

Whether the object represent a comb (True) or a single channel (False).

single_tooth

Tells whether the channel is a single-tooth comb (i.e.

total_input_dim

Dimension of the total input space, dim E_i (x) I.

total_input_dims

Dimensions of spaces in the total input space, [dimE_i, I_0, …].

total_input_spaces

Names of factors in the total input space, [E_i, I_0, …].

total_output_dim

Dimension of the total output space, dim E_o (x) O.

total_output_dims

Dimensions of spaces in the total output space, [dimE_o, O_0, …].

total_output_spaces

Names of factors in the total output space, [E_o, O_0, …].

trivial_env

Tells whether the channel has trivial environment.

trivial_env_inp

Tells whether the input environment space E_i is trivial.

trivial_env_out

Tells whether the input environment space E_o is trivial.

Parameters:
  • krauses (list[np.ndarray] | None)

  • choi (np.ndarray | None)

  • dkrauses (list[np.ndarray] | None)

  • dchoi (np.ndarray | None)

  • env_dim (int | tuple[int, int])

  • sdict (SpaceDict)

  • input_dim (int | list[int] | None)

  • output_dim (int | list[int] | None)

Methods

__call__(state)

Call self as a function.

act(state)

Act on a state with the channel.

add(other)

Adds two ParamChannels by adding their chois and dchois.

choi()

Compute Choi matrix of the channel.

compose(*others[, simplify_krauses])

Returns the sequential composition of self and others.

dchoi()

Compute derivative of the Choi matrix of the channel.

dkrauses([force_computation])

Computes Kraus operatiors of the channel.

duplicate()

Create new ParamChannel object representing the same channel but with different names of spaces.

krauses([force_computation])

Computes Kraus operators of the channel.

kron(*others)

Computes Kronecker product of channels A (x) B (x) C (x) ...

kron_pow(n)

Creates a n-th Kronecker power of channel with trivial environment space.

link_env(*others)

Computes link product of channels A * B * C * .

markov_series(n)

Computes link product of n channel copies each connected by their environment space.

merge_spaces()

Merges spaces of the channel to make it single-tooth.

scalar_mul(factor)

Multiplies the channel by scalar by multiplying its choi and dchoi.

tensor([input_spaces, output_spaces, ...])

Returns parametrized tensor of self's Choi matrix.

trace_env([env_inp_state])

Trace environment input space using provided input state and then trace environment output space.

trace_env_inp([env_inp_state])

Trace environment input space using provided input state.

trace_env_out()

Trace environment output space.

property single_tooth: bool

Tells whether the channel is a single-tooth comb (i.e. it has only one input and one output space).

Returns:

Value of len(self.input_spaces) == 1.

Return type:

bool

property trivial_env_inp: bool

Tells whether the input environment space E_i is trivial.

Returns:

Value of self.env_inp_dim == 1.

Return type:

bool

property trivial_env_out: bool

Tells whether the input environment space E_o is trivial.

Returns:

Value of self.env_out_dim == 1.

Return type:

bool

property trivial_env: bool

Tells whether the channel has trivial environment.

Returns:

Value of self.trivial_env_inp and self.trivial_env_out.

Return type:

bool

property total_input_dim: int

Dimension of the total input space, dim E_i (x) I.

Returns:

Dimension.

Return type:

int

property total_output_dim: int

Dimension of the total output space, dim E_o (x) O.

Returns:

Dimension.

Return type:

int

property total_input_dims: list[int]

Dimensions of spaces in the total input space, [dimE_i, I_0, …].

Returns:

List of dimensions.

Return type:

list[int]

property total_output_dims: list[int]

Dimensions of spaces in the total output space, [dimE_o, O_0, …].

Returns:

List of dimensions.

Return type:

list[int]

property total_input_spaces: list[Hashable]

Names of factors in the total input space, [E_i, I_0, …].

Returns:

List of names.

Return type:

list[Hashable]

property total_output_spaces: list[Hashable]

Names of factors in the total output space, [E_o, O_0, …].

Returns:

List of names.

Return type:

list[Hashable]

property is_comb: bool

Whether the object represent a comb (True) or a single channel (False).

Returns:

True if the object is a comb.

Return type:

bool

tensor(input_spaces=None, output_spaces=None, env_inp=None, env_out=None, sdict=None, **kwargs)[source]

Returns parametrized tensor of self’s Choi matrix. Names of its inidices are in the attributes of self:

  • input_spaces, output_spaces,

  • env_inp_space, env_out_space,

  • total_input_spaces which is equal to [env_inp_space, *input_spaces],

  • total_output_spaces which is equal to [env_out_space, *output_spaces].

or can be provided as keyword arguments to this method.

Parameters:
  • input_spaces (list[Hashable] | None, optional) – Tensor’s input spaces names. They should be in the causal order (as in self.input_dims), by default None.

  • output_spaces (list[Hashable] | None, optional) – Tensor’s output spaces names. They should be in the causal order (as in self.output_dims), by default None.

  • env_inp (Hashable | None, optional) – Name of the environment input space. If the environment input is trivial this space will be omitted. By default None.

  • env_out (Hashable | None, optional) – Name of the environment output space. If the environment output is trivial this space will be omitted. By default None.

  • sdict (SpaceDict, optional) – Tensor’s space dictionary, by default self.sdict.

Returns:

Parametrized tensor of the Choi matrix.

Return type:

ParamTensor

krauses(force_computation=False)[source]

Computes Kraus operators of the channel.

If the object was defined using Kraus operators it will return the same Kraus operators it was defined with unless force_computation is true.

Parameters:

force_computation (bool, optional) – Whether to force computation of new Kraus operators.

Returns:

krauses – List of Kraus operators. Each acting from E_i (x) I to E_o (x) O.

Return type:

list[np.ndarray]

dkrauses(force_computation=False)[source]

Computes Kraus operatiors of the channel.

In case the object was defined using Kraus operators it will return the same Kraus operators it was defined with unless force_computation is true.

Parameters:

force_computation (bool, optional) – Whether to force computation of new Kraus operators.

Returns:

  • krauses (list[np.ndarray]) – List of Kraus operators.

  • dkrauses (list[np.ndarray]) – List of derivatives of Kraus operators.

Return type:

tuple[list[ndarray], list[ndarray]]

choi()[source]

Compute Choi matrix of the channel.

Returns:

matrix – Choi matrix.

Return type:

np.ndarray

dchoi()[source]

Compute derivative of the Choi matrix of the channel.

Returns:

matrix – Derivative of the Choi matrix.

Return type:

np.ndarray

duplicate()[source]

Create new ParamChannel object representing the same channel but with different names of spaces.

Returns:

New ParamChannel.

Return type:

ParamChannel

merge_spaces()[source]

Merges spaces of the channel to make it single-tooth.

When input channel is from E_i (x) I_1 (x) … (x) I_n to E_o (x) O_1 (x) … (x) O_n it will be transformed to a channel from E_i (x) I to E_o (x) O, where I = I_1 (x) … (x) I_n and O = O_1 (x) … (x) O_n are single, high-dimensional spaces.

Returns:

New single-tooth ParamChannel.

Return type:

ParamChannel

kron(*others)[source]

Computes Kronecker product of channels A (x) B (x) C (x) …

Each channel must be elementary i.e. they must have one input and one output space (single-tooth comb). The corresponding spaces of two channels are merged, so the resulting channel has a single input, single env_input, single output, single env_output.

Parameters:
Returns:

Kronecker product of channels (single-tooth channel).

Return type:

ParamChannel

Raises:

ValueError – When channels are not single-tooth.

kron_pow(n)[source]

Creates a n-th Kronecker power of channel with trivial environment space.

Parameters:

n (int) – Exponent.

Returns:

n-th Kronecker power

Return type:

ParamChannel

Raises:

ValueError – If channels are not single-tooth

Computes link product of channels A * B * C * … Connecting them by their environment.

For a product of channels A and B all spaces of A will be before spaces of B e.g. A._kron_one(B).input_spaces == A.input_spaces + B.input_spaces

Link produckt is possible only between channels A and B such that A.env_out_dim == B.env_inp_dim.

Parameters:
Returns:

Link product of channels.

Return type:

ParamChannel

Raises:

ValueError – When the appropriate environment spaces have different dimensions.

scalar_mul(factor)[source]

Multiplies the channel by scalar by multiplying its choi and dchoi.

Breaks trace preservation, useful to construct convex combinations of channels (together with add_channel).

Parameters:

factor (float) – The factor by which a channel is multiplied

Returns:

Input channel multiplied by a scalar.

Return type:

ParamChannel

add(other)[source]

Adds two ParamChannels by adding their chois and dchois.

Breaks trace preservation, useful to construct convex combinations of channels (together with scalar_mul)

Parameters:

other (ParamChannel) – channel to be added to self

Returns:

Sum of two ParamChannels.

Return type:

ParamChannel

Raises:

ValueError – When two channels do not act on spaces of the same dimensions.

compose(*others, simplify_krauses=True)[source]

Returns the sequential composition of self and others.

In the simplest case of two channels x.compose(y) will return a channel representing a map rho -> x(y(rho)).

For multiple channels i.e. x.compose(y0, y1, …, yn) it will return a channel representing a map rho -> x(y0(y1( … (yn(rho)) … ), which is a concatenation (pipeline) of channels x, y0, y1, …, yn.

Parameters:
  • others[0...*] (ParamChannel) – Channels to be composed with self.

  • simplify_krauses (bool, optional) – If True, then output is always computed based on chois to ensure the minimal possible Kraus represantation of output. By default True.

  • others (ParamChannel)

Returns:

Sequential composition of channels

Return type:

ParamChannel

Raises:

ValueError – When channels are not single-tooth or dimensions of connected inputs and outputs do not match.

act(state)[source]

Act on a state with the channel.

Parameters:

state (np.ndarray | tuple[np.ndarray, np.ndarray]) – Input state density matrix (when np.ndarray) Input state density matrix and its derivative (when tuple[np.ndarray, np.ndarray])

Returns:

Density matrix of the output state and its derivative after action of ParamChannel on input state.

Return type:

tuple[np.ndarray, np.ndarray]

Raises:

ValueError – When state is neither 2d np.ndarray nor tuple of 2 2d np.ndarrays

trace_env_inp(env_inp_state=None)[source]

Trace environment input space using provided input state.

Parameters:

env_inp_state (np.ndarray | None, optional) – Density matrix of the state. If None then maximally mixed state is used. By default None.

Returns:

New channel with traced out environment input space.

Return type:

ParamChannel

Raises:

ValueError – When input state dimension does not match environment input space dimension.

trace_env_out()[source]

Trace environment output space.

Returns:

New channel with traced out environment output space.

Return type:

ParamChannel

trace_env(env_inp_state=None)[source]

Trace environment input space using provided input state and then trace environment output space.

Parameters:

env_inp_state (np.ndarray | None, optional) – Density matrix of the state. If None then maximally mixed state is used. By default None.

Returns:

New channel with traced out environment spaces.

Return type:

ParamChannel

Raises:

ValueError – When input state dimension does not match environment input space dimension.

markov_series(n)[source]

Computes link product of n channel copies each connected by their environment space.

Roughly equivalent to self.link_env(*repeat(self, n - 1)).

Parameters:
Returns:

Channel representing correlated channels.

Return type:

ParamChannel