noisy_graph_states module
Classes:
|
A noise map using the NSF convention. |
|
A noisy graph state. |
|
A representation of a measurement strategy on a noisy graph state. |
Functions:
|
Add noise operators if they are not there. |
|
Apply Pauli-X noise channel with error probability epsilon on a qubit. |
|
Apply Pauli-Y noise channel with error probability epsilon on a qubit. |
|
Apply Pauli-Z noise channel with error probability epsilon on a qubit. |
|
A Pauli-diagonal noise channel acts on a qubit. |
|
Performs a local complementation on a graph and its noise. |
|
Performs a local Pauli Z measurement on a graph and its noise. |
|
Performs a local Pauli Y measurement on a graph and its noise. |
|
Performs a local Pauli X measurement on a graph and its noise. |
|
Performs a CNOT gate between source and target on a graph and its noise. |
|
Performs a merging operation between source and target on a graph and its noise. |
|
Performs a full-merging operation between source and target on a graph and its noise. |
|
Combine multiple Maps into a single equivalent Map. |
|
Compute the reduced noise maps of all the state on a subset of qubits. |
|
Apply maps to a density matrix representing a subset of qubits. |
|
Compute the noisy density matrix of a targeted Bell pair. |
|
Compute the noisy density matrix of a targeted 3-qubit GHZ state. |
- class noisy_graph_states.noisy_graph_states.Map(weights: list, noises: list)
Bases:
objectA noise map using the NSF convention.
Can be used to represent Pauli-diagonal noise. Y and X noise are represented as correlated Z noises, which only makes sense in the context of graph states.
- Parameters:
weights (list) – weights associated with this noise pattern. (1 - sum(weights)) is the weight of the identity.
noises (list[tuple[int]]) – noises are represented by tuples of indices, indicating correlated Z-operators being applied to those qubits.
- Variables:
weights (list)
noises (list)
Methods:
__call__(other)Apply the Map to a State object.
Return an equivalent map that is in standard form.
Transform the map to standard form in place.
- __call__(other)
Apply the Map to a State object.
Effectively, this just adds the Map to the list of maps.
- Parameters:
other (State)
- Returns:
State – The State after the application of the map.
- as_standard_form()
Return an equivalent map that is in standard form.
See the to_standard_form method for an explanation of the standard form.
- Returns:
Map – an equivalent map that is in standard form
- to_standard_form()
Transform the map to standard form in place.
The standard form is useful because it makes the format more predictable for other functions. The standard form does this: * each individual noise is sorted * noises are sorted * duplicate noises are combined (their weights are added) * empty noises (corresponding to identity operator) are dropped * noises with weight 0 are dropped
- Returns:
None
- class noisy_graph_states.noisy_graph_states.State(graph: Graph, maps: list)
Bases:
objectA noisy graph state.
Represents a quantum state that is the perfect graph state corresponding to graph with the noise maps applied to it.
- Parameters:
graph (nx.Graph) – The graph of the underlying graph state.
maps (list[Map]) – Noise maps that are acting on the noiseless graph state.
- Variables:
graph (networkx.classes.graph.Graph)
maps (list)
- class noisy_graph_states.noisy_graph_states.Strategy(graph: Graph, sequence: tuple, autoload: bool = True)
Bases:
objectA representation of a measurement strategy on a noisy graph state.
This supports transformations that consist of local complementations and measurements. (no merging/connecting operations) One can use this class instead of individual functions to make use of the built-in caching mechanisms - i.e. repeated applications of the same strategy on different input states will be much faster - as well as the save and load features to retain this cache between runs.
- Parameters:
graph (Graph) – The graph state at the beginning of the strategy.
sequence (tuple[tuple[str, int]]) – Local complementations or measurements corresponding to combined operators, which both project on an eigenstate and perform the local Cliffords that return the state to a graph state. Individual instructions must be of form (“x” or “y” or “z” or “lc”, qubit_index). Optionally, x-measurements may specify the index of the special neighbour b0 as a third entry in the tuple (“x”, qubit_index, b0).
autoload (bool) – If True, tries to load the strategy from the .pickle file in DEFAULT_CACHE_DIR matching the Strategy’s _hash_str. Default: True.
- Variables:
graph (networkx.classes.graph.Graph)
sequence (tuple)
Methods:
__call__(other)Apply the strategy to an initial state.
Calculate all noise patterns for local initial noise.
Get an expression describing how initial local Pauli noise transforms under the strategy.
save([path])Save the calculated caches to a file.
load([path])Load a saved cache from a file.
- __call__(other)
Apply the strategy to an initial state.
- Parameters:
other (State)
- Returns:
State – The state after all measurements defined by the strategy were performed.
- populate_cache()
Calculate all noise patterns for local initial noise.
This is a helper method that populates the cache of the _transform_noise method with patterns corresponding to local Pauli-diagonal initial noise. Generally, this will not be necessary, as the needed entries will be created anyway as needed, but this allows optionally to pre-calculate some of this before the first application.
- Returns:
None
- get_weight_vector_expression()
Get an expression describing how initial local Pauli noise transforms under the strategy.
This can be used to build an analytic expression that is equivalent to the strategy, but is more easily optimized.
- Returns:
dict –
- keystuple[int]
final noise patterns
- values: list[str]
which initial noises contribute to the noise pattern, in the format [xyz]_[0-9]+ example: [“x_0”, “y_3”, “y_13”, “z_8”]
- save(path: [<class 'str'>, None] = None)
Save the calculated caches to a file.
A new strategy can then simply load the precalculated results in the future so future runs of the Strategy can save time.
When picking custom file names it is the user’s responsibility to only load compatible strategies.
- Parameters:
path (path-like or None) – The file name in which to save the results. If None, saves in a .pickle file in DEFAULT_CACHE_DIR with the strategy’s hash as the name. Default: None
- Returns:
None
- load(path: [<class 'str'>, None] = None)
Load a saved cache from a file.
This loads the pre-calculated results that have been saved with the save method from a previous When picking custom file names it is the user’s responsibility to only load compatible strategies.
- Parameters:
path (path-like or None) – The file name from which to load the results. If None, tries to load a .pickle file in DEFAULT_CACHE_DIR with the strategy’s hash as the name. Default: None
- Returns:
None
- noisy_graph_states.noisy_graph_states.add_or_remove(index_list, noise)
Add noise operators if they are not there. Remove the noise operators if they are there.
- Parameters:
index_list (Iterable) – List of the indices of the affected qubits, counting starts at 0.
noise (tuple[int]) – Initial noise operators
- Returns:
tuple – Final noise operators
- noisy_graph_states.noisy_graph_states.x_noise(state, indices, epsilon)
Apply Pauli-X noise channel with error probability epsilon on a qubit.
The equivalent effect (in density matrix notation) on an input state rho is: (1 - epsilon) * rho + epsilon * X @ rho @ X
- Parameters:
state (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 – The state after the noise channel has been applied.
- noisy_graph_states.noisy_graph_states.y_noise(state, indices, epsilon)
Apply Pauli-Y noise channel with error probability epsilon on a qubit.
The equivalent effect (in density matrix notation) on an input state rho is: (1 - epsilon) * rho + epsilon * Y @ rho @ Y
- Parameters:
state (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 – The state after the noise channel has been applied.
- noisy_graph_states.noisy_graph_states.z_noise(state, indices, epsilon)
Apply Pauli-Z noise channel with error probability epsilon on a qubit.
The equivalent effect (in density matrix notation) on an input state rho is: (1 - epsilon) * rho + epsilon * Z @ rho @ Z
- Parameters:
state (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 – The state after the noise channel has been applied.
- noisy_graph_states.noisy_graph_states.pauli_noise(state, indices, coefficients)
A Pauli-diagonal noise channel acts on a qubit.
The equivalent effect (in density matrix notation) 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 (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 – The state after the noise channel has been applied.
- noisy_graph_states.noisy_graph_states.local_complementation(state, index)
Performs a local complementation on a graph and its noise.
- Parameters:
state (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 – The state after the manipulation has been applied.
- noisy_graph_states.noisy_graph_states.z_measurement(state, index)
Performs a local Pauli Z measurement on a graph and its noise.
- Parameters:
state (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 – The state after the manipulation has been applied.
- noisy_graph_states.noisy_graph_states.y_measurement(state, index)
Performs a local Pauli Y measurement on a graph and its noise.
- Parameters:
state (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 – The state after the manipulation has been applied.
- noisy_graph_states.noisy_graph_states.x_measurement(state, index, b0=None)
Performs a local Pauli X measurement on a graph and its noise.
- Parameters:
state (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 – The state after the manipulation has been applied.
- noisy_graph_states.noisy_graph_states.cnot(state, source, target)
Performs a CNOT gate between source and target on a graph and its noise.
- Parameters:
state (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 – The state after the manipulation has been applied.
- noisy_graph_states.noisy_graph_states.merge(state, source, target)
Performs a merging operation between source and target on a graph and its noise.
- Parameters:
state (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 – The state after the manipulation has been applied.
- noisy_graph_states.noisy_graph_states.full_merge(state, source, target)
Performs a full-merging operation between source and target on a graph and its noise.
- Parameters:
state (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 – The state after the manipulation has been applied.
- noisy_graph_states.noisy_graph_states.compile_maps(*args)
Combine multiple Maps into a single equivalent Map.
Use with care, because this can impact efficiency. If arbitrary maps are combined, exponentially many entries may be needed to describe the final map.
- Parameters:
args (Map) – Any number of Map objects that will be combined.
- Returns:
Map – A single Map object that is equivalent to the application of all the Map objects provided in args.
- noisy_graph_states.noisy_graph_states.reduce_maps(state, target_indices)
Compute the reduced noise maps of all the state on a subset of qubits.
- Parameters:
state (State) – The state on whose maps will be reduced.
target_indices (list[int]) – Indices of the target qubits. Counting starts at 0.
- Returns:
list[Map] – Reduced maps
- noisy_graph_states.noisy_graph_states.apply_nsf_maps_to_dm(maps, density_matrix, target_indices)
Apply maps to a density matrix representing a subset of qubits.
- Parameters:
maps (list[Map]) – All noise maps that should be applied.
density_matrix (np.ndarray) – Input state to which the noise maps will be applied. Must have shape (2**N, 2**N) with N=len(target_indices) and the qubits are assumed to be in the same order as specified in target_indices.
target_indices (list) – Indices of subset of qubits that is considered. Counting starts at 0.
- Returns:
np.ndarray – Density matrix after the application of the maps.
- noisy_graph_states.noisy_graph_states.noisy_bp_dm(state, target_indices)
Compute the noisy density matrix of a targeted Bell pair.
- Parameters:
state (State) – The state in the NSF of the noisy graph state containing a Bell pair.
target_indices (list[int]) – Indices of the target qubits of the Bell pair. Counting starts at 0.
- Returns:
np.ndarray – Noisy density matrix of the target Bell pair.
- Raises:
ValueError – If the state of the target_indices cannot be reduced to a Bell pair. This is the case if either there is no edge between the target_indices, or there are other vertices connected to them.
- noisy_graph_states.noisy_graph_states.noisy_3_ghz_dm(state, target_root, target_leafs)
Compute the noisy density matrix of a targeted 3-qubit GHZ state.
This assumes the root-and-leafs representation of the graph state variant of the GHZ state. (which is LC-equivalent to the fully connected graph)
- Parameters:
state (State) – The state in the NSF of the noisy graph state containing a 3-qubit GHZ state.
target_root (int) – Index of the root qubit of the targeted 3-qubit GHZ state. Counting starts at 0.
target_leafs (list[int]) – Indices of the target leaf qubits of the 3-qubit GHZ state. Counting starts at 0.
- Returns:
np.ndarray – Noisy density matrix of the target 3-qubit GHZ state.
- Raises:
ValueError – If the state of the target_root and target_leafs cannot represent a GHZ state. This is the case if there are edges missing in the graph or there are other extra connections to vertices outside the subset.