A Python library for working with CV-flow (continuous variable flow) in measurement-based quantum computing (MBQC). It provides tools to define open graphs, check and find CV-flows, generate measurement patterns, and execute quantum computations.
In continuous variable MBQC, a quantum computation is described by an open graph
qlustrix implements algorithms to:
- Determine whether a CV-flow exists for a given open graph
- Compute the flow and measurement layers when it exists
- Generate executable measurement patterns from flows
- Execute patterns using different quantum backends
For more details on CV-Flow, refer to the "Concepts" section in the documentation.
- Graph Analysis: Define and manipulate open graphs with input/output nodes
- Flow Finding: Automatic CV-flow detection with L1/L2 optimization methods
- Pattern Generation: Convert flows to executable measurement sequences
- Multiple Backends: Abstract backend interface with a provided MrMustard implementation
- Visualization: Graph layout and visualization utilities
Requires Python 3.12. Install with uv:
uv syncFor development (includes Sphinx, pytest):
uv sync --group devimport networkx as nx
from qlustrix.graph import OpenGraph
from qlustrix.flow import find_cvflow
# Create a graph
g = nx.Graph()
g.add_nodes_from([0, 1, 2, 3])
g.add_edge(0, 2, weight=1.0)
g.add_edge(1, 3, weight=1.0)
g.add_edge(2, 3, weight=1.0)
# Define the open graph
graph = OpenGraph(g, input_nodes=[0, 1], output_nodes=[2, 3])
# Find the CV-flow
exists, g_map, layers = find_cvflow(graph, method="l2")
if exists:
print("CV-flow found!")
print("Corrections:", g_map)
print("Layers:", layers)from qlustrix.pattern import flow_to_pattern
# Convert flow to an executable pattern
pattern = flow_to_pattern(graph, g_map, layers)
print(pattern)src/qlustrix/
├── graph.py # OpenGraph class and graph utilities
├── flow.py # CV-flow finding and checking algorithms
├── pattern.py # Pattern class and flow-to-pattern conversion
├── command.py # Command types: N, M, E, X, Z
├── factories.py # Pattern factories (squeezing, random measurements)
├── backend/
│ ├── abstract_backend.py # AbstractBackend interface
│ └── mrmustard_backend.py # MrMustard implementation
└── utils/
├── run.py # Experiment run layer
├── sweep.py # Parameter sweep utilities
└── serialization.py # Result serialization
tests/ # Test suite
Run tests with pytest:
uv run pytestThe flow-finding algorithms support two optimization methods:
- L2 (default): Least squares minimization, spreads corrections across nodes
- L1: Linear programming for sparse corrections
# Use L1 for sparser corrections
exists, g_map, layers = find_cvflow(graph, method="l1")- Alexandre Menard (LKB x Inria QAT internship collaboration)