Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
4ca34ae
initial commit of qompiler
masa10-f Jun 6, 2025
c1d8d85
implement PauliFrame for MBQC computation
masa10-f Jun 24, 2025
e1a98d3
add PauliFrame attribute to Pattern
masa10-f Jun 24, 2025
2140284
fix ruff error
masa10-f Jun 24, 2025
07c3b49
update command interface
masa10-f Jun 24, 2025
a11048b
remove CBitType attribute from M command since this information is de…
masa10-f Jun 24, 2025
b97e534
remove CBitType enum
masa10-f Jun 24, 2025
efb1970
update qompiler with PauliFrame and updated commands
masa10-f Jun 24, 2025
a5d2d95
fix docstring
masa10-f Jun 24, 2025
7377795
fix lint error
masa10-f Jun 24, 2025
692fd36
update command __str__
masa10-f Jun 24, 2025
c7c1046
temporaly remove pattern test
masa10-f Jun 24, 2025
0b8ebc7
add pattern generation example
masa10-f Jun 24, 2025
62a7e16
fix dag calculation
masa10-f Jun 24, 2025
15acc59
reverse the topological order
masa10-f Jun 24, 2025
d1a7cef
add docs of pauli frame and qompiler
masa10-f Jun 24, 2025
f3c803c
ignore docstring linter in examples
masa10-f Jun 24, 2025
1ebd63e
add title in pattern generation demo
masa10-f Jun 24, 2025
e0432a1
update gitignore
masa10-f Jun 24, 2025
d123256
fix docstring typo
masa10-f Jun 24, 2025
6ee4860
modify doc
masa10-f Jun 24, 2025
e5d7e7d
fix mypy error
masa10-f Jun 24, 2025
fd073fc
add matplotlib in requirements-doc
masa10-f Jun 24, 2025
3c074cc
loosen required versions
masa10-f Jun 25, 2025
f786dbc
move initialize_pauli_frame into staticmethod of PauliFrame
masa10-f Jun 25, 2025
a6b56e9
type annotation
masa10-f Jun 25, 2025
4eb75c1
simplify qompile methods
masa10-f Jun 25, 2025
8abd353
fix topological sort
masa10-f Jun 25, 2025
2cb0002
fix ruff errors
masa10-f Jun 25, 2025
d666a59
update qompiler doc
masa10-f Jun 25, 2025
b2d819f
update example
masa10-f Jun 25, 2025
81c0433
modify feedforward utils
masa10-f Jun 25, 2025
7bb788c
improve stability of qompile function
masa10-f Jun 25, 2025
3b71b5f
remove Clifford and Decoder commands since they are not necessary now
masa10-f Jun 25, 2025
f89d38b
modify utils
masa10-f Jun 25, 2025
8d5d78c
update doc
masa10-f Jun 25, 2025
4249525
update func
masa10-f Jun 25, 2025
e4aed7a
fix tests
masa10-f Jun 25, 2025
eeb147d
fix interface
masa10-f Jun 25, 2025
acbdd0f
fix test_feedforward
masa10-f Jun 25, 2025
0057bfb
implement PauliFrame.children
masa10-f Jun 25, 2025
9d76e0d
update checker
masa10-f Jun 25, 2025
671dfbd
fix docstring
masa10-f Jun 25, 2025
2e47100
resolve type error
masa10-f Jun 25, 2025
9cb03a7
fix type error in focus_flow
masa10-f Jun 25, 2025
6bdf8fd
fix ruff errors
masa10-f Jun 25, 2025
e6b91ec
fix name
masa10-f Jun 25, 2025
c3d5924
fix docstring
masa10-f Jun 25, 2025
488716b
fix PauliFrame update func
masa10-f Jun 25, 2025
41f4f83
implement x/z flip method
masa10-f Jun 25, 2025
18c98ae
allow self-loop in x/zflow
masa10-f Jun 25, 2025
6ae921f
fix ruff errors
masa10-f Jun 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,4 @@ cython_debug/

# Custom stuff
docs/source/gallery
docs/source/sg_execution_times.rst
8 changes: 5 additions & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
sphinx==8.2.3
sphinx_gallery==0.19.0
furo==2024.8.6
sphinx>=7.4.0
sphinx_gallery>=0.17.0
furo>=2024.01.29

matplotlib>=3.7.0
6 changes: 0 additions & 6 deletions docs/source/command.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ Command Classes
.. autoclass:: graphix_zx.command.Z
:members:

.. autoclass:: graphix_zx.command.Clifford
:members:

.. autoclass:: graphix_zx.command.D
:members:

Type Alias
----------

Expand Down
18 changes: 0 additions & 18 deletions docs/source/decoder_backend.rst

This file was deleted.

4 changes: 3 additions & 1 deletion docs/source/feedforward.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ Functions

.. autofunction:: graphix_zx.feedforward.dag_from_flow

.. autofunction:: graphix_zx.feedforward.check_causality
.. autofunction:: graphix_zx.feedforward.check_dag

.. autofunction:: graphix_zx.feedforward.check_flow
14 changes: 14 additions & 0 deletions docs/source/pauli_frame.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Pauli Frame
===========

:mod:`graphix_zx.pauli_frame` module
++++++++++++++++++++++++++++++++++++

.. automodule:: graphix_zx.pauli_frame

Pauli Frame Class
-----------------

.. autoclass:: graphix_zx.pauli_frame.PauliFrame
:members:
:member-order: bysource
12 changes: 12 additions & 0 deletions docs/source/qompiler.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Qompiler
========

:mod:`graphix_zx.qompiler` module
+++++++++++++++++++++++++++++++++

.. automodule:: graphix_zx.qompiler

Qompile Functions
-----------------

.. autofunction:: graphix_zx.qompiler.qompile
3 changes: 2 additions & 1 deletion docs/source/references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ Module reference
feedforward
focus_flow
command
decoder_backend
pattern
pauli_frame
qompiler
37 changes: 0 additions & 37 deletions docs/source/sg_execution_times.rst

This file was deleted.

20 changes: 20 additions & 0 deletions examples/pattern_generation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
Basic Pattern Generation Example
================================

This example demonstrates how to generate a pattern from a graph state
using the graphix-zx library.
"""

# %%
from graphix_zx.pattern import print_pattern
from graphix_zx.qompiler import qompile
from graphix_zx.random_objects import generate_random_flow_graph

# %%
# convert circuit to graph and flow
graphstate, gflow = generate_random_flow_graph(width=3, depth=5)
# first, qompile it to standardized pattern
pattern = qompile(graphstate, gflow)
print("get max space of pattern:", pattern.max_space)
print_pattern(pattern)
76 changes: 5 additions & 71 deletions graphix_zx/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
- `M`: Measurement command.
- `X`: X correction command.
- `Z`: Z correction command.
- `Clifford`: Clifford command.
- `D`: Decode command.
- `Command`: Type alias of all commands.
"""

Expand All @@ -20,8 +18,6 @@

if TYPE_CHECKING:
from graphix_zx.common import MeasBasis
from graphix_zx.decoder_backend import BaseDecoder
from graphix_zx.euler import LocalClifford


@dataclasses.dataclass
Expand Down Expand Up @@ -66,30 +62,18 @@ class M:
The node index to be measured.
meas_basis : MeasBasis
The measurement basis.
s_cbit : `int` | `None`
The index of s_domain control classical bit.
Default is None, meaning the flag is always False.
t_cbit : `int` | `None`
The index of t_domain control classical bit.
Default is None, meaning the flag is always False.
"""

node: int
meas_basis: MeasBasis
s_cbit: int | None = None
t_cbit: int | None = None

def __str__(self) -> str:
return (
f"M: node={self.node}, plane={self.meas_basis.plane}, "
f"angle={self.meas_basis.angle}, s_cbit={self.s_cbit}, t_cbit={self.t_cbit}"
)
return f"M: node={self.node}, plane={self.meas_basis.plane}, angle={self.meas_basis.angle}"


@dataclasses.dataclass
class _Correction:
node: int
cbit: int | None = None


@dataclasses.dataclass
Expand All @@ -100,13 +84,10 @@ class X(_Correction):
----------
node : `int`
The node index to apply the correction.
cbit : `int` | `None`
The index of the classical bit to control the correction.
If cbit is None, the flag is always False, meaning the correction will not be applied.
"""

def __str__(self) -> str:
return f"X: node={self.node}, cbit={self.cbit}"
return f"X: node={self.node}"


@dataclasses.dataclass
Expand All @@ -117,60 +98,13 @@ class Z(_Correction):
----------
node : `int`
The node index to apply the correction.
cbit : `int` | `None`
The index of the classical bit to control the correction.
If cbit is None, the flag is always False, meaning the correction will not be applied.
"""

def __str__(self) -> str:
return f"Z: node={self.node}, cbit={self.cbit}"


@dataclasses.dataclass
class Clifford:
"""Clifford command.

Attributes
----------
node : `int`
The node index to apply the local Clifford.
local_clifford : `LocalClifford`
The local Clifford to apply
"""

node: int
local_clifford: LocalClifford

def __str__(self) -> str:
return (
f"Clifford: node={self.node}, alpha={self.local_clifford.alpha}, "
f"beta={self.local_clifford.beta}, gamma={self.local_clifford.gamma}"
)


@dataclasses.dataclass
class D:
r"""Decode command.

Attributes
----------
input_cbits : `list`\[`int`\]
A list of classical bit indices that will serve as input to the decoder.
output_cbits : `list`\[`int`\]
A list of classical bit indices that will store the decoding results.
decoder : `BaseDecoder`
The decoder instance used to process the input classical bits and produce the output.
"""

input_cbits: list[int]
output_cbits: list[int]
decoder: BaseDecoder

def __str__(self) -> str:
return f"D: input_cbits={self.input_cbits}, output_cbits={self.output_cbits}, decoder={self.decoder}"
return f"Z: node={self.node}"


if sys.version_info >= (3, 10):
Command = N | E | M | X | Z | Clifford | D
Command = N | E | M | X | Z
else:
Command = Union[N, E, M, X, Z, Clifford, D]
Command = Union[N, E, M, X, Z]
61 changes: 0 additions & 61 deletions graphix_zx/decoder_backend.py

This file was deleted.

Loading