noisy_graph_states.tools module
Additional functions that makes working with the package more straightforward.
The patterns tool
A collection of useful functions to translate between measurement patterns and strategies.
Functions:
|
Find measurement pattern corresponding to graph measurements. |
|
Find a sequence of graph measurements corresponding to a measurement pattern. |
|
Find a sequence of graph measurements corresponding to a measurement pattern. |
- noisy_graph_states.tools.patterns.sequence_to_pattern(sequence: list, graph: Graph)
Find measurement pattern corresponding to graph measurements.
Every sequence of measurements in the graph state picture (i.e., with explicitly undoing the byproduct operators at every step) corresponds to a measurement pattern of Pauli measurements that postpones all corrections operations to the very end. There are multiple sequences that lead to the same pattern.
This is explained in the appendix ofMaria Flors Mor-Ruiz, Julius Wallnöfer, and Wolfgang Dür.“Imperfect quantum networks with tailored resource states.”arXiv preprint arXiv:2403.19778 (2024).- Parameters:
sequence (list[tuple]) – A series of graph measurements that are performed in order. Format: (“x” or “y” or “z”, qubit_index) for x measurements optionally one can specify the index of the special neighbour like so (“x”, qubit_index, b0).
graph (nx.Graph) – The start graph to which the sequence of measurements is applied.
- Returns:
list[str] – The measurement pattern for postponed correction operations from the lowest qubit index to the highest qubit index. “x”, “y” or “z” for a Pauli measurement. “.” for no measurement.
- noisy_graph_states.tools.patterns.pattern_to_sequence(pattern: list, graph: Graph, support_nodes: list | None = None)
Find a sequence of graph measurements corresponding to a measurement pattern.
Since multiple sequences can lead to the same pattern, this just returns one particular one (the one in which the graph transformations are from the lowest qubit index to the highest qubit index in order). Use pattern_to_all_sequences instead to get a list of all.
This is explained in the appendix ofMaria Flors Mor-Ruiz, Julius Wallnöfer, and Wolfgang Dür.“Imperfect quantum networks with tailored resource states.”arXiv preprint arXiv:2403.19778 (2024).- Parameters:
pattern (list[str]) – The measurement pattern from the lowest qubit index to the highest qubit index. “x”, “y” or “z” for a Pauli measurement. “.” for no measurement. length must match len(graph)
graph (nx.Graph) – The start graph to which the measurements are applied.
support_nodes (list[int] or None) – A list of indices of support nodes for x measurements. If None, the first neighbour of the qubit is used as support node.
- Returns:
list[tuple] – A sequence of graph measurements. Format: (“x” or “y” or “z”, qubit_index)
- noisy_graph_states.tools.patterns.pattern_to_all_sequences(pattern: list, graph: Graph)
Find a sequence of graph measurements corresponding to a measurement pattern.
Multiple sequences can lead to the same pattern, this function finds all of them, except those that would arise from specifying the special neighbour b0 for x measurements explicitly. Use pattern_to_sequence instead if you just need a single sequence as representation of the pattern.
This is explained in the appendix ofMaria Flors Mor-Ruiz, Julius Wallnöfer, and Wolfgang Dür.“Imperfect quantum networks with tailored resource states.”arXiv preprint arXiv:2403.19778 (2024).- Parameters:
pattern (list[str]) – The measurement pattern from the lowest qubit index to the highest qubit index. “x”, “y” or “z” for a Pauli measurement. “.” for no measurement. length must match len(graph)
graph (nx.Graph) – The start graph to which the measurements are applied.
- Returns:
list[tuple] – A sequence of graph measurements. Format: (“x” or “y” or “z”, qubit_index)
The density matrix tool
An equivalent implementation using density matrices
It is a collection of functions that work with density matrices instead but use the same syntax as in the main package. Mostly useful for verification.
Classes:
|
A noisy graph state. |
Functions:
|
Apply a Pauli-X channel on a single qubit. |
|
Apply a Pauli-Y channel on a single qubit. |
|
Apply a Pauli-Z channel on a single qubit. |
|
A Pauli-diagonal noise channel acts on a qubit. |
|
Performs a local complementation on a graph and its density matrix. |
|
This function deletes all the edges of qubit index. |
|
Performs a local Pauli Y measurement on a graph and its density matrix. |
|
Performs a local Pauli X measurement on a graph and its density matrix. |
|
Performs a CNOT gate between source and target on a graph and its density matrix. |
|
Performs a merging operation between source and target on a graph and its density matrix. |
|
Performs a full-merging operation between source and target on a graph and its density matrix. |
|
Compute the fidelity of a state in the density matrix formalism against the target state in ket formalism. |
- class noisy_graph_states.tools.density_matrix.State(graph: Graph, density_matrix: ndarray)
Bases:
objectA noisy graph state.
Represents a quantum state in the density matrix formalism, where the density_matrix encloses all noises acting on the state. The corresponding to graph is also given. This has the same syntax that the State in noisy_graph_states, but using the density matrix instead of the noise maps.
- Parameters:
graph (nx.Graph) – The graph of the underlying noiseless graph state.
density_matrix (np.ndarray) – Noisy density matrix.
- Variables:
graph (networkx.classes.graph.Graph)
density_matrix (numpy.ndarray)
Attributes:
- graph: Graph
- density_matrix: ndarray
- noisy_graph_states.tools.density_matrix.x_noise(state, indices, epsilon)
Apply a Pauli-X channel on a single qubit.
The effect on an input state rho is given by: (1 - epsilon) * rho + epsilon * X @ rho @ X
- Parameters:
state (density_matrix.State) – The state on which the noise acts.
indices (list) – List of the indices of the affected qubits, counting starts at 0.
epsilon (scalar) – The weight of the noise channel; should be in the interval [0, 1]
- Returns:
State (density_matrix.State) – The state after the noise channel has been applied.
- noisy_graph_states.tools.density_matrix.y_noise(state, indices, epsilon)
Apply a Pauli-Y channel on a single qubit.
The effect on an input state rho is given by: (1 - epsilon) * rho + epsilon * Y @ rho @ Y
- Parameters:
state (density_matrix.State) – The state on which the noise acts.
indices (list) – List of the indices of the affected qubits, counting starts at 0.
epsilon (scalar) – The weight of the noise channel; should be in the interval [0, 1]
- Returns:
State (density_matrix.State) – The state after the noise channel has been applied.
- noisy_graph_states.tools.density_matrix.z_noise(state, indices, epsilon)
Apply a Pauli-Z channel on a single qubit.
The effect on an input state rho is given by: (1 - epsilon) * rho + epsilon * Z @ rho @ Z
- Parameters:
state (density_matrix.State) – The state on which the noise acts.
indices (list) – List of the indices of the affected qubits, counting starts at 0.
epsilon (scalar) – The weight of the noise channel; should be in the interval [0, 1]
- Returns:
State (density_matrix.State) – The state after the noise channel has been applied.
- noisy_graph_states.tools.density_matrix.pauli_noise(state, indices, coefficients)
A Pauli-diagonal noise channel acts on a qubit.
The effect on an input state rho is given by: p_0 * rho + p_1 * X @ rho @ X + p_2 * Y @ rho @ Y + p_3 * Z @ rho @ Z where p_0, p_1, p_2, p_3 = coefficients
- Parameters:
state (density_matrix.State) – The state on which the noise acts.
indices (list) – List of the indices of the affected qubits, counting starts at 0.
coefficients (list[scalar]) – The four coefficients of the noise channel, corresponding to the application Identity, X, Y and Z, respectively. Should sum to 1.
- Returns:
State (density_matrix.State) – The state after the noise channel has been applied.
- noisy_graph_states.tools.density_matrix.local_complementation(state, index)
Performs a local complementation on a graph and its density matrix.
- Parameters:
state (density_matrix.State) – The state on which the manipulation is performed.
index (int) – The index-th vertex is where the local complementation is applied. Counting starts at 0.
- Returns:
State (density_matrix.State) – The state after the manipulation has been applied.
- noisy_graph_states.tools.density_matrix.z_measurement(state, index)
This function deletes all the edges of qubit index. It updates the state, which includes the graph and the density matrix.
- Parameters:
state (density_matrix.State) – The state on which the manipulation is performed.
index (int) – Label of the qubit to be measured.
- Returns:
State (density_matrix.State) – The state after the manipulation has been applied.
- noisy_graph_states.tools.density_matrix.y_measurement(state, index)
Performs a local Pauli Y measurement on a graph and its density matrix.
- Parameters:
state (density_matrix.State) – The state on which the manipulation is performed.
index (int) – The index-th vertex is where the local complementation is applied. Counting starts at 0.
- Returns:
state (density_matrix.State) – The state after the manipulation has been applied.
- noisy_graph_states.tools.density_matrix.x_measurement(state, index, b0=None)
Performs a local Pauli X measurement on a graph and its density matrix.
- Parameters:
state (density_matrix.State) – The state on which the manipulation is performed.
index (int) – The index-th vertex is where the local complementation is applied. Counting starts at 0.
b0 (int) – Index of the special neighbour of the X measurement. Counting starts at 0.
- Returns:
state (density_matrix.State) – The state after the manipulation has been applied.
- noisy_graph_states.tools.density_matrix.cnot(state, source, target)
Performs a CNOT gate between source and target on a graph and its density matrix.
- Parameters:
state (density_matrix.State) – The state on which the manipulation is performed.
source (int) – The source-th vertex is considered. Counting starts at 0.
target (int) – The target-th vertex is considered. Counting starts at 0.
- Returns:
State (density_matrix.State) – The state after the manipulation has been applied.
- noisy_graph_states.tools.density_matrix.merge(state, source, target)
Performs a merging operation between source and target on a graph and its density matrix.
- Parameters:
state (density_matrix.State) – The state on which the manipulation is performed.
source (int) – The source-th vertex is considered. Counting starts at 0.
target (int) – The target-th vertex is considered. Counting starts at 0.
- Returns:
state (density_matrix.State) – The state after the manipulation has been applied.
- noisy_graph_states.tools.density_matrix.full_merge(state, source, target)
Performs a full-merging operation between source and target on a graph and its density matrix.
- Parameters:
state (density_matrix.State) – The state on which the manipulation is performed.
source (int) – The source-th vertex is considered. Counting starts at 0.
target (int) – The target-th vertex is considered. Counting starts at 0.
- Returns:
state (density_matrix.State) – The state after the manipulation has been applied.
- noisy_graph_states.tools.density_matrix.fidelity(noiseless_ket, noisy_dm)
Compute the fidelity of a state in the density matrix formalism against the target state in ket formalism. :param noiseless_ket: The target state in the ket formalism :type noiseless_ket: vector matrix :param noisy_dm: The state in the density matrix formalism. :type noisy_dm: matrix
- Returns:
fidelity (int) – Fidelity, takes values [0, 1]
The strategies_1d collection
A collection of measurement strategies and patterns on 1D cluster states.
Functions:
|
This function creates a tuple of the Y measurements that need to be performed in an N-qubit 1D cluster to connect the two end of the cluster. |
This function creates a tuple of the Y measurements that need to be performed in an N-qubit 1D cluster to connect the two end of the cluster. |
|
|
This function creates a tuple of the Y measurements that need to be performed in an N-qubit 1D cluster to connect the two end of the cluster. |
|
This function creates a tuple of the Y measurements that need to be performed in an N-qubit 1D cluster to connect the two end of the cluster. |
This function creates a list of all the possible tuples of the Y measurements that need to be performed in an N-qubit 1D cluster to connect the two end of the cluster. |
|
|
This function takes a strategy defined as a sequence of local Pauli measurements of the inner qubits of a 1D cluster such that the end nodes are connected, and transforms it into a strategy that also performs local Pauli measurements in the Z basis of the outer neighbours. |
This function gives a list of all possible strategies of inner neighbours related to all the possible measurement patterns consisting of 'y' and 'x' measurements. |
- noisy_graph_states.tools.strategies_1d.side_to_side(N)
This function creates a tuple of the Y measurements that need to be performed in an N-qubit 1D cluster to connect the two end of the cluster. The order of these measurements is side to side meaning from one end of the cluster to the other (left-to-right).
- Parameters:
N (int) – Number of qubits in the 1D cluster.
- Returns:
side_to_side (Strategy) – Strategy corresponding to the strategy of measuring side to side.
- noisy_graph_states.tools.strategies_1d.reverse_side_to_side(N)
This function creates a tuple of the Y measurements that need to be performed in an N-qubit 1D cluster to connect the two end of the cluster. The order of these measurements is reverse side to side meaning from one end of the cluster to the other (right-to-left).
- Parameters:
N (int) – Number of qubits in the 1D cluster.
- Returns:
strategy (Strategy) – Strategy corresponding to the strategy of measuring reversed side to side.
- noisy_graph_states.tools.strategies_1d.every_second(N)
This function creates a tuple of the Y measurements that need to be performed in an N-qubit 1D cluster to connect the two end of the cluster. The order of these measurements is every second qubit. Such that, on the first loop one wants to measure every two qubits, thus 1, 3, 5, … Then for round 1, you start measuring at 1 until N-2 every 2 –> range(1, N-1, 2) Next, you measure every second qubit of the ones that are left, so, 2, 6, 10… So for round 2, you start measuring at 2 until N-2 every 4 –> range(2, N-1, 4) Next, you measure every second qubit of the ones that are left, so, 4, 12, 20.. So for round 3, you start measuring at 4 until N-2 every 8 –> range(2, N-1, 4) Thus, in general at each round you measure qubits in range(2**r, N-1, 2**(r+1)), where r starts at 0. After performing all the measurement r will reach the value such that range(2**r, N-1, 2**(r+1)) is empty.
- Parameters:
N (int) – Number of qubits in the 1D cluster.
- Returns:
strategy (Strategy) – Strategy corresponding to the strategy of measuring every second qubit.
- noisy_graph_states.tools.strategies_1d.pairs(N)
This function creates a tuple of the Y measurements that need to be performed in an N-qubit 1D cluster to connect the two end of the cluster. The order of these measurements is every in pairs, starting from the outside to the inside. Such that first qubits 1 and N-2 are measured, then 3 and N-3, and so on.
- Parameters:
N (int) – Number of qubits in the 1D cluster.
- Returns:
strategy (Strategy) – Strategy corresponding to the strategy of measuring in pairs.
- noisy_graph_states.tools.strategies_1d.all_y_strategies(N)
This function creates a list of all the possible tuples of the Y measurements that need to be performed in an N-qubit 1D cluster to connect the two end of the cluster.
- Parameters:
N (int) – Number of qubits in the 1D cluster.
- Returns:
all_strategies (list of Strategy) – List of all the possible Strategy objects given a certain N.
- noisy_graph_states.tools.strategies_1d.strategy_plus_z(strategy)
This function takes a strategy defined as a sequence of local Pauli measurements of the inner qubits of a 1D cluster such that the end nodes are connected, and transforms it into a strategy that also performs local Pauli measurements in the Z basis of the outer neighbours.
- Parameters:
strategy (Strategy) – Order and bases of the measurements of the inner neighbours.
- Returns:
new_strategy (Strategy) – Order and bases of the measurements of the inner neighbours plus the local Pauli Z measurement of the two outer neighbours.
- noisy_graph_states.tools.strategies_1d.all_strategies_1d_pair(N)
This function gives a list of all possible strategies of inner neighbours related to all the possible measurement patterns consisting of ‘y’ and ‘x’ measurements. It also includes the patterns of only ‘y’ and only ‘x’. These strategies manipulate a 1D cluster to a Bell pair between the end nodes. The function checks internally that the strategy leads to the desired target state.
- Parameters:
N (int) – Number of qubits in the 1D cluster.
- Returns:
good_strategies (list) – List of all possible strategies.