API-Reference

Functions for multiparite entanglement purification on graph states.

See README.md for an overview of the functionality.

Classes:

Graph(N, E[, sets])

A graph object consisting of vertices and edges.

Functions:

adj_matrix(N, E)

Calculates the adjacency matrix from vetices and edges.

complement_state(rho, n, graph)

Update graph state basis entries after local complementation.

fid_alternative(rho, mu)

Alternative fidelity function.

fidelity(rho, mu)

Calculate fidelity of two states given in the same graph state basis.

local_complementation(n, graph)

Return the new graph after local complementation.

noise_global(rho, p[, graph])

Apply a global white noise channel to the state.

noise_pattern(rho, qubit_index, ps, graph)

Applies a local pauli-diagonal noise channel on the specified qubit.

noisy(rho, subset[, graph])

Template to generate noise patterns.

normalize(rho)

Normalize the state to trace = 1.

p1(rho, graph)

Perform protocol P1 of the ADB protocol for two-colorable graph states.

p1_var(rho, sigma, graph)

P1 but with two different input states instead of two copies of the same.

p2(rho, graph)

Perform protocol P2 of the ADB protocol for two-colorable graph states.

p2_var(rho, sigma, graph)

P2 but with two different input states instead of two copies of the same.

pk(rho, sigma, graph1, graph2, subset)

Perform sub-protocol P_k.

trace_distance(rho, mu)

Calculate the trace distance between to states in the same graph state basis.

wnoise(rho, qubit_index, p, graph)

Apply local white noise channel with error parameter p on a qubit.

wnoise_all(rho, p, graph)

Apply local white noise with the same error parameter to all qubits.

xnoise(rho, qubit_index, p, graph)

Apply Pauli-X noise channel with error parameter p on a qubit.

xnoisy(rho, qubit_index, graph)

Applies sigma_x noise on the specified qubit.

ynoise(rho, qubit_index, p, graph)

Apply Pauli-Y noise channel with error parameter p on a qubit.

ynoisy(rho, qubit_index, graph)

Applies sigma_y noise on the specified qubit.

znoise(rho, qubit_index, p[, graph])

Apply Pauli-Z noise channel with error parameter p on a qubit.

znoisy(rho, qubit_index[, graph])

Applies sigma_z noise on the specified qubit.

class graphepp.graphepp.Graph(N, E, sets=[])

A graph object consisting of vertices and edges.

Other functions that need to know in which graph state basis a state is given expect a Graph object to specify the associated graph. The properties are read-only on purpose to make this hashable. This is desirable because some functions in this module profit heavily from caching.

Parameters:
  • N (int) – Number of vertices.

  • E (list of tuples of ints) – Should contain 2-tuples with the edges of the graph. Each pair (i,j) indicates a connection between vertices i and j. Only simple, unweighted, undirected graphs are supported. Note that the N vertices are labeled 0…N-1

  • sets (list of list of ints, optional) – Optionally define subsets of vertices, e.g. coloring of the graph as expected for the entanglement purification protocols. Default: []

Attributes:

E

Return the edges of the graph.

N

Return the number of vertices of the graph.

a

The first subset of vertices (first color).

adj

Return the adjacency matrix of the graph.

b

The second subset of vertices (second color).

sets

Return the subsets of vertices defined for the graph.

property E

Return the edges of the graph.

Returns:

tuple[tuple[int]] – A tuple containing the edges of the graph as ordered 2-tuples.

property N

Return the number of vertices of the graph.

Returns:

int – The number of vertices.

property a

The first subset of vertices (first color).

Returns:

tuple[int] or None – The first subset, or None if no subsets were defined.

property adj

Return the adjacency matrix of the graph.

Returns:

np.ndarray – The N`x`N adjacency matrix.

property b

The second subset of vertices (second color).

Returns:

tuple[int] or None – The second subset, or None if no second subset was defined.

property sets

Return the subsets of vertices defined for the graph.

Usually these are related to colorings of the graph.

Returns:

tuple[tuple[int]] – All subsets in the order they were specified.

graphepp.graphepp.adj_matrix(N, E)

Calculates the adjacency matrix from vetices and edges.

The graph has N vertices (labeled 0 to N-1) and edges E.

Parameters:
  • N (int) – Number of vertices.

  • E (list (or tuple) of tuples) – Should contain 2-tuples with the edges of the graph. Each pair (i,j) indicates a connection between vertices i and j. Only simple, unweighted, undirected graphs are supported. Note that the N vertices are labeled 0…N-1

Returns:

adj (np.ndarray) – Adjacency matrix of the graph specified. Is a symmetric N x N matrix with N_{ij}=1 if (i,j) is in E and 0 otherwise.

graphepp.graphepp.complement_state(rho, n, graph)

Update graph state basis entries after local complementation.

The entries in the new graph state basis are switched around a bit: | µ’>_G’ = U_n^τ(G) | µ>_G

with update rule µ’_i = µ_i XOR µ_n if i in the neighbourhood of n µ’_i = µ_i otherwise

This is shown in Appendix B of Phys. Rev. A 95, 012303 (2017) Preprint: https://doi.org/10.48550/arXiv.1609.05754

Parameters:
  • rho (np.ndarray) – The state given in the graph state basis corresponding to the original graph.

  • n (int) – Local complementation around the n-th vertex.

  • graph (Graph) – The original graph.

Returns:

np.ndarray – The state given in the graph state basis corresponding to the updated graph.

graphepp.graphepp.fid_alternative(rho, mu)

Alternative fidelity function.

Calculates sqrt(F) instead of F (as defined in the fidelity fucntion).

Parameters:
  • rho (np.ndarray) – Diagonal entries of quantum states given in the same graph state basis.

  • mu (np.ndarray) – Diagonal entries of quantum states given in the same graph state basis.

Returns:

scalar – sqrt(F)

graphepp.graphepp.fidelity(rho, mu)

Calculate fidelity of two states given in the same graph state basis.

This is a special case of the general definition of the fidelity: F(rho, mu) = (tr(sqrt(sqrt(rho), mu, sqrt(rho))))**2 Note that the term “fidelity” has been used ambiguously in quantum information theory, either referring to F or sqrt(F). F as defined here is the square of the fidelity as defined in Nielsen and Chuang.

sqrt(1 - F(rho, mu)) is a distance measure. (1 - sqrt(F(rho, mu))) is a distance measure.

Parameters:
  • rho (np.ndarray) – Diagonal entries of quantum states given in the same graph state basis.

  • mu (np.ndarray) – Diagonal entries of quantum states given in the same graph state basis.

Returns:

scalar – The fidelity F.

graphepp.graphepp.local_complementation(n, graph)

Return the new graph after local complementation.

Careful: Subsets are just copied so the coloring is not updated!

Parameters:
  • n (int) – Local complementation around the n-th vertex.

  • graph (Graph) – The original graph.

Returns:

Graph – The graph after local complementation.

graphepp.graphepp.noise_global(rho, p, graph=None)

Apply a global white noise channel to the state.

Parameters:
  • rho (np.ndarray) – Is the state acted on. Should be a 2**N-dimensional vector with the diagonal entries of the density matrix in the graph state basis.

  • p (scalar) – Error parameter of the channel should be in interval [0, 1].

  • graph (Graph, optional) – Specifies in which graph state basis rho is given. This function does not use it - only included for consistency. Default: None

Returns:

np.ndarray – The state after the action. Same shape as rho.

graphepp.graphepp.noise_pattern(rho, qubit_index, ps, graph)

Applies a local pauli-diagonal noise channel on the specified qubit.

Parameters:
  • rho (np.ndarray) – Is the state acted on. Should be a 2**N-dimensional vector with the diagonal entries of the density matrix in the graph state basis.

  • qubit_index (int) – The n-th qubit is affected, counting starts at 0. Indices are expected to be in order 012…(N-1) regardless of coloring of the vertices.

  • ps (list of scalars) – The coefficients of the noise channel. Should have 4 entries p_0 p_x p_y p_z that sum to 1.

  • graph (Graph) – Specifies in which graph state basis rho is given.

Returns:

np.ndarray – The state after the action. Same shape as rho.

graphepp.graphepp.noisy(rho, subset, graph=None)

Template to generate noise patterns.

In physical terms this is correlated sigma_z noise on all particles in subset.

Parameters:
  • rho (np.ndarray) – Is the state acted on. Should be a 2**N-dimensional vector with the diagonal entries of the density matrix in the graph state basis.

  • subset (list of int) – The list of which qubits are affected, counting starts at 0. Indices are expected to be in order 012…(N-1) regardless of coloring of the vertices.

  • graph (Graph, optional) – Specifies in which graph state basis rho is given. This function does not use it - only included for consistency. Default: None

Returns:

np.ndarray – The state after the action. Same shape as rho.

graphepp.graphepp.normalize(rho)

Normalize the state to trace = 1.

Also catches numerical phenomena with entries < 0.

Parameters:

rho (np.ndarray) – The state to be normalized.

Returns:

np.ndarray – The normalized state. Same shape as rho.

graphepp.graphepp.p1(rho, graph)

Perform protocol P1 of the ADB protocol for two-colorable graph states.

Implements equation (17) of Phys. Rev. A 71, 012319 (2005) Preprint: https://arxiv.org/abs/quant-ph/0405045

Comment on the implementation: The integers used here correspond to the bit strings in the publication as follows: i ~ γ_A,γ_B j ~ 0,γ_B k ~ ν_B m ~ 0,ν_B and therefore: i^j ~ γ_A,0 (i^j)^m ~ γ_A,ν_B i^m ~ γ_A,(γ_B ⊕ ν_B) So the loop over k iterates over all possible ν_B. While equation (17) suggests another loop over μ_B, there is only one μ_B = (γ_B ⊕ ν_B) that fulfils the specified condition ν_B ⊕ μ_B = γ_B so another nested loop is not necessary.

Parameters:
  • rho (np.ndarray) – Diagonal entries of a density matrix in the graph state basis. Two copies of this state will be used to perform the protocol.

  • graph (Graph) – Graph of the target graph state to be purified. rho is given in this graph state basis. Must contain coloring information of the two-colorable graph state.

Returns:

np.ndarray – The output state of the protocol, assuming the purification step was successful.

graphepp.graphepp.p1_var(rho, sigma, graph)

P1 but with two different input states instead of two copies of the same.

Parameters:
  • rho (np.ndarray) – Diagonal entries of a density matrix in the graph state basis. First input state.

  • sigma (np.ndarray) – Diagonal entries of a density matrix in the graph state basis. Second input state.

  • graph (Graph) – Graph of the target graph state to be purified. rho and mu are given in this graph state basis. Must contain coloring information of the two-colorable graph state.

Returns:

np.ndarray – The output state of the protocol, assuming the purification step was successful.

graphepp.graphepp.p2(rho, graph)

Perform protocol P2 of the ADB protocol for two-colorable graph states.

Implements equation (19) of Phys. Rev. A 71, 012319 (2005) Preprint: https://arxiv.org/abs/quant-ph/0405045

See docstring of p1 for comment on the iterations and bit strings.

Parameters:
  • rho (np.ndarray) – Diagonal entries of a density matrix in the graph state basis. Two copies of this state will be used to perform the protocol.

  • graph (Graph) – Graph of the target graph state to be purified. rho is given in this graph state basis. Must contain coloring information of the two-colorable graph state.

Returns:

np.ndarray – The output state of the protocol, assuming the purification step was successful.

graphepp.graphepp.p2_var(rho, sigma, graph)

P2 but with two different input states instead of two copies of the same.

Parameters:
  • rho (np.ndarray) – Diagonal entries of a density matrix in the graph state basis. First input state.

  • sigma (np.ndarray) – Diagonal entries of a density matrix in the graph state basis. Second input state.

  • graph (Graph) – Graph of the target graph state to be purified. rho and mu are given in this graph state basis. Must contain coloring information of the two-colorable graph state.

Returns:

np.ndarray – The output state of the protocol, assuming the purification step was successful.

graphepp.graphepp.pk(rho, sigma, graph1, graph2, subset)

Perform sub-protocol P_k.

A sub-protocol of the entanglement purification protocol for all graph states. Implements equation (8) of Phys. Rev. A 74, 052316 (2006) Preprint: https://arxiv.org/abs/quant-ph/0606090

See docstring of p1 for comment on the iterations and bit strings.

Parameters:
  • rho (np.ndarray) – Diagonal entries of a density matrix in the graph state basis corresponding to graph1. Main input state.

  • sigma (np.ndarray) – Diagonal entries of a density matrix in the graph state basis corresponding to graph2. Auxiliary input state. Make sure it has the same number of qubits as rho (expand with unconnected vertices if needed).

  • graph1 (Graph) – The main graph of the protocol.

  • graph2 (Graph) – The auxiliary graph for the k-th subset for the k-th sub-protocol P_k. Make sure it has the same number of vertices as graph1 (expand with unconnected vertices if needed).

  • subset (tuple of ints) – A subset of vertices, corresponding to the k-th subset.

Returns:

np.ndarray – The output state of the protocol, assuming the purification step was successful.

graphepp.graphepp.trace_distance(rho, mu)

Calculate the trace distance between to states in the same graph state basis.

Parameters:
  • rho (np.ndarray) – Diagonal entries of quantum states given in the same graph state basis.

  • mu (np.ndarray) – Diagonal entries of quantum states given in the same graph state basis.

Returns:

scalar – The trace distance.

graphepp.graphepp.wnoise(rho, qubit_index, p, graph)

Apply local white noise channel with error parameter p on a qubit.

Note: local white noise is often also called local depolarizing noise

Parameters:
  • rho (np.ndarray) – Is the state acted on. Should be a 2**N-dimensional vector with the diagonal entries of the density matrix in the graph state basis.

  • qubit_index (int) – The qubit_index-th qubit is affected, counting starts at 0. Indices are expected to be in order 012…(N-1) regardless of coloring of the vertices.

  • p (scalar) – Error parameter of the channel should be in interval [0, 1].

  • graph (Graph) – Specifies in which graph state basis rho is given.

Returns:

np.ndarray – The state after the action. Same shape as rho.

graphepp.graphepp.wnoise_all(rho, p, graph)

Apply local white noise with the same error parameter to all qubits.

Parameters:
  • rho (np.ndarray) – Is the state acted on. Should be a 2**N-dimensional vector with the diagonal entries of the density matrix in the graph state basis.

  • p (scalar) – Error parameter of the channel should be in interval [0, 1].

  • graph (Graph) – Specifies the graphstate considered.

Returns:

np.ndarray – The state after the action. Same shape as rho.

graphepp.graphepp.xnoise(rho, qubit_index, p, graph)

Apply Pauli-X noise channel with error parameter p on a qubit.

Parameters:
  • rho (np.ndarray) – Is the state acted on. Should be a 2**N-dimensional vector with the diagonal entries of the density matrix in the graph state basis.

  • qubit_index (int) – The qubit_index-th qubit is affected, counting starts at 0. Indices are expected to be in order 012…(N-1) regardless of coloring of the vertices.

  • p (scalar) – Error parameter of the channel should be in interval [0, 1].

  • graph (Graph) – Specifies in which graph state basis rho is given.

Returns:

np.ndarray – The state after the action. Same shape as rho.

graphepp.graphepp.xnoisy(rho, qubit_index, graph)

Applies sigma_x noise on the specified qubit.

Parameters:
  • rho (np.ndarray) – Is the state acted on. Should be a 2**N-dimensional vector with the diagonal entries of the density matrix in the graph state basis.

  • qubit_index (int) – The qubit_index-th qubit is affected, counting starts at 0. Indices are expected to be in order 012…(N-1) regardless of coloring of the vertices.

  • graph (Graph) – Specifies in which graph state basis rho is given.

Returns:

np.ndarray – The state after the action. Same shape as rho.

graphepp.graphepp.ynoise(rho, qubit_index, p, graph)

Apply Pauli-Y noise channel with error parameter p on a qubit.

Parameters:
  • rho (np.ndarray) – Is the state acted on. Should be a 2**N-dimensional vector with the diagonal entries of the density matrix in the graph state basis.

  • qubit_index (int) – The qubit_index-th qubit is affected, counting starts at 0. Indices are expected to be in order 012…(N-1) regardless of coloring of the vertices.

  • p (scalar) – Error parameter of the channel should be in interval [0, 1].

  • graph (Graph) – Specifies in which graph state basis rho is given.

Returns:

np.ndarray – The state after the action. Same shape as rho.

graphepp.graphepp.ynoisy(rho, qubit_index, graph)

Applies sigma_y noise on the specified qubit.

Parameters:
  • rho (np.ndarray) – Is the state acted on. Should be a 2**N-dimensional vector with the diagonal entries of the density matrix in the graph state basis.

  • qubit_index (int) – The qubit_index-th qubit is affected, counting starts at 0. Indices are expected to be in order 012…(N-1) regardless of coloring of the vertices.

  • graph (Graph) – Specifies in which graph state basis rho is given.

Returns:

np.ndarray – The state after the action. Same shape as rho.

graphepp.graphepp.znoise(rho, qubit_index, p, graph=None)

Apply Pauli-Z noise channel with error parameter p on a qubit.

Parameters:
  • rho (np.ndarray) – Is the state acted on. Should be a 2**N-dimensional vector with the diagonal entries of the density matrix in the graph state basis.

  • qubit_index (int) – The qubit_index-th qubit is affected, counting starts at 0. Indices are expected to be in order 012…(N-1) regardless of coloring of the vertices.

  • p (scalar) – Error parameter of the channel should be in interval [0, 1].

  • graph (Graph, optional) – Specifies in which graph state basis rho is given. Default: None

Returns:

np.ndarray – The state after the action. Same shape as rho.

graphepp.graphepp.znoisy(rho, qubit_index, graph=None)

Applies sigma_z noise on the specified qubit.

Parameters:
  • rho (np.ndarray) – Is the state acted on. Should be a 2**N-dimensional vector with the diagonal entries of the density matrix in the graph state basis.

  • qubit_index (int) – The qubit_index-th qubit is affected, counting starts at 0. Indices are expected to be in order 012…(N-1) regardless of coloring of the vertices.

  • graph (Graph, optional) – Specifies in which graph state basis rho is given. This function does not use it. Included only so znoisy can be called the same way as xnoisy and ynoisy. Default: None

Returns:

np.ndarray – The state after the action. Same shape as rho.