Python library for quantum circuit rewriting and optimisation using the ZX-calculus
This release includes breaking changes!
Major new features are support for W-spiders and Z-boxes, which are generators used in certain extensions of the ZX-calculus, such as in this paper which served as the motivation.
It also adds more formal support for symbolic phases through the addition of a Poly
class that can represented polynomial expressions containing Boolean and continuous variables.
These features were implemented to support the development of ZXLive, a new graphical proof assistant for ZX-diagrams.
This release includes some changes that are not backwards compatible. The most important of which is changing how inputs and outputs are stored in the json format. This means that json files produced by Graph.to_json()
are not parsible by older versions, and older versions are no longer parsible by this newer version.
In addition, the gate CX
has been renamed to XCX
to make it more clear that it is in fact not an alternative name for the CNOT
gate. Finally, the FSim
gate now takes as first arguments the control and target, and only then the angles, in order to be consistent with the other gate definitions.
Poly
class (standing for Polynomial) (courtesy of @RazinShaikh).is_well_formed
to check that a graph is a well-formed ZX-diagram (courtesy of @RazinShaikh).is_pauli
to check whether a phase is Pauli (courtesy of @y-richie-y).GraphDiff
that calculates what actions are needed to bring one graph to another (used in ZXLive).simplify.to_clifford_normal_form_graph
and extract.extract_clifford_normal_form
.CX
, which refers to an X-controlled X gate, renamed to XCX
for clarity.FSim
changed to put control and target before angles, for consistency with other gates.tensorfy
function used the visual ordering of inputs and outputs, instead of the correct ordering (#168).full_reduce
, interior_clifford_simp
and pivot_gadget_simp
by @y-richie-y in https://github.com/Quantomatic/pyzx/pull/130
print_phase
class var in gates.py
. by @dlyongemallo in https://github.com/Quantomatic/pyzx/pull/136
quipper_name
a class var in Gate
with a default value of undefined
. by @dlyongemallo in https://github.com/Quantomatic/pyzx/pull/141
parse
. by @dlyongemallo in https://github.com/Quantomatic/pyzx/pull/150
FSim
by putting control
and target
parameters first. by @dlyongemallo in https://github.com/Quantomatic/pyzx/pull/154
ry
rotation and add y
gate. by @dlyongemallo in https://github.com/Quantomatic/pyzx/pull/157
VertexType
constants in tensor.py. by @dlyongemallo in https://github.com/Quantomatic/pyzx/pull/170
RZZ
a subclass of ParityPhase
. by @dlyongemallo in https://github.com/Quantomatic/pyzx/pull/173
graph_to_swaps
a bit clearer. by @dlyongemallo in https://github.com/Quantomatic/pyzx/pull/175
ry
by @dlyongemallo in https://github.com/Quantomatic/pyzx/pull/183
Measurement
gate qasm comment and link. by @dlyongemallo in https://github.com/Quantomatic/pyzx/pull/190
Full Changelog: https://github.com/Quantomatic/pyzx/compare/v0.7.3...v0.8.0
This release improves support and documentation for routing circuits (courtesy of @aborgna-q). In particular it implements the architecture-aware synthesis technique for phase polynomials of this paper.
The way that the D3 library is loaded is also changed, meaning that the D3 visualization should now work on more systems, in particular on Google Colab. This should also hopefully fix some errors with loading the diagram editor (although this still relies on Jupyter's widget library so that that will only work locally).
zx.routing.route_phase_poly
adapted from this paper (courtesy of @Aerylia and @aborgna-q).zx.generate.phase_poly
, zx.generate.phase_poly_approximate
and zx.generate.phase_poly_from_gadgets
cnots
and phasepoly
that generates random CNOT and phase polynomial circuits (@aborgna-q).sympy
when doing rewriting (courtesy of @y-richie-y).ry
gates in QASM files (courtesy of @mgrzesiuk).ipywidgets
has been updated from ipywidgets>= 7.5
to ipywidgets>=7.5,<8
as newer version broke the diagram editor.mapper
has been renamed to router
.Circuit.verify_equality
where it would sometimes say that circuits are equal while they are not (courtesy of Julian Verweij).This release adds several new features: support for evaluating ZX-diagrams as tensor networks using the hypergraph contraction methods of quimb, basic support for interacting with the Rust port of PyZX quizx, support for 'hybrid' ZX-diagrams that contain classical wires and measurements, as well as several heuristics for trying to optimise the CNOT count of a circuit that is to be extracted from a ZX-diagram.
There is one small breaking change, which is that Graph.inputs
and Graph.outputs
are now methods that return a list, instead of being lists themselves.
Graph
class.Graph
vertices can now carry a ground
generator. This makes it possible to represent measurements and classical control in the diagrams. See the accompanying paper (courtesy of ABorgna).extract.lookahead_extract
that uses heuristics to extract circuit with less CNOT gates (courtesy of VladMoldoveanu).local_search
submodule for doing simulated annealing on rewrites of a ZX-diagram to try to get it to be extracted with less CNOTS (courtesy of Ryan Krueger).hsimplify.par_hbox_intro_simp()
that can remove some H-boxes.basicrules
and mbqc
.Graph.set_inputs()
and Graph.set_outputs()
to set a list of vertices to be the inputs/outputs of a diagram.Graph.num_inputs()
and Graph.num_outputs()
to get the number of inputs and outputs of a diagram.Graph.inputs
is now a method that returns a list of inputs, instead of Graph.inputs
being a list itself. The same for Graph.outputs
.The main feature added is support for copying and pasting inside the editor. This release should also hopefully fix the issue where users of the PyPI version can't use zx.draw and the editor.
Fixed several bugs related to scalars not being remembered or updated correctly. Also added a number of convience functions.
This release has made many backwards incompatible changes to the API in order to remove some old functions and rename other functions to more logical or consistent names. In particular, all British spelling names have been renamed to American spelling names. After this release the API should be significantly more stable.
The license for this project has been changed from GPLv3 to Apache2, in order to streamline the process of using PyZX with other open-source quantum computing projects.
Fixed syntax error that prevented scripts from being called
PyZX is now available as a package on PyPI. To install it, run
pip install pyzx