Optimization passes¶
graphix.optimization module¶
This module defines some optimization passes for patterns.
- graphix.optimization.standardize(pattern: Pattern) Pattern[source]¶
Return a standardized form to the given pattern.
A standardized form is an equivalent pattern where the commands appear in the following order:
N,E,M,Z,X,C.Note that a standardized form does not always exist in presence of
Ccommands. For instance, there is no standardized form for the following pattern (written in the right-to-left convention):E(0, 1) C(0, H) N(1) N(0).The function raises
NotImplementedErrorif there is no standardized form. This behavior can change in the future.
- class graphix.optimization.StandardizedPattern(input_nodes: Iterable[Node], output_nodes: Iterable[Node], results: Mapping[Node, Outcome], n_list: Iterable[command.N], e_set: Iterable[Iterable[Node]], m_list: Iterable[command.M], c_dict: Mapping[Node, Clifford], z_dict: Mapping[Node, Iterable[Node]], x_dict: Mapping[Node, Iterable[Node]])[source]¶
Pattern in standardized form.
Use the method
to_pattern()to get the standardized pattern.This class uses immutable data structures for its fields (
tuple,frozensetandMapping).Instances can be generated with the constructor from any compatible data structures, and an instance can be generated directly from a pattern with the class method
from_pattern().The constructor instantiates the
Mappingfields asMappingProxyTypeobjects over fresh dictionaries, ensuring their immutability. We expose the typeMappinginstead ofMappingProxyTypefor the readability, as they provide the same interface.- input_nodes¶
Input nodes.
- Type:
tuple[Node, …]
- output_nodes¶
Output nodes.
- Type:
tuple[Node, …]
- results¶
Already measured nodes (by Pauli presimulation).
- Type:
Mapping[Node, Outcome]
- e_set¶
Set of edges. Each edge is a set with two elements.
- Type:
frozenset[frozenset[Node]]
- z_dict¶
Mapping associating Z-domains to some nodes.
- Type:
Mapping[Node, frozenset[Node]]
- x_dict¶
Mapping associating X-domains to some nodes.
- Type:
Mapping[Node, frozenset[Node]]
- graphix.optimization.incorporate_pauli_results(pattern: Pattern) Pattern[source]¶
Return an equivalent pattern where results from Pauli presimulation are integrated in corrections.