Skip to content
alexandremndPublic

About

A Python library for continuous-variable measurement-based quantum computing, implementing the graph, flow, pattern, and backend simulation layers.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

55 Commits

Folders and files

Repository files navigation

cvflow

Qlustrix

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.

What is CV-Flow?

In continuous variable MBQC, a quantum computation is described by an open graph $(G, I, O)$ where $G$ is a weighted graph, $I$ the input nodes, and $O$ the output nodes. A CV-flow is a function that assigns to each non-output node a correction vector, along with a layering of the graph, such that the measurement order is causally consistent.

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.

Features

  • 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

Installation

Requires Python 3.12. Install with uv:

uv sync

For development (includes Sphinx, pytest):

uv sync --group dev

Quick Start

Finding a CV-flow

import 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)

Generating a Pattern

from qlustrix.pattern import flow_to_pattern

# Convert flow to an executable pattern
pattern = flow_to_pattern(graph, g_map, layers)
print(pattern)

Project Structure

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

Testing

Run tests with pytest:

uv run pytest

Methods

The 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")

Author(s)

  • Alexandre Menard (LKB x Inria QAT internship collaboration)

License

GNU GPLv3

About

A Python library for continuous-variable measurement-based quantum computing, implementing the graph, flow, pattern, and backend simulation layers.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages