Skip to content

Running :func: Pattern.perform_pauli_measurements twice returns non-runnable patterns. #397

@matulni

Description

@matulni

The transformation $T$ implemented in :func: Pattern.perform_pauli_measurements should fulfill

$$ T^n[P] = T[P], \quad n > 0$$

The example below shows that apply :func: Pattern.perform_pauli_measurements twice returns a non-runnable pattern.

import numpy as np
from graphix.random_objects import rand_circuit
import pytest

rng = np.random.default_rng(42)
nqubits = 2
depth = 2
circuit = rand_circuit(nqubits, depth, rng, use_ccx=False)
p = circuit.transpile().pattern

p.perform_pauli_measurements()
print(p.results)  # {0: 0, 2: 0, 3: 0, 4: 0, 5: 0, 7: 0, 8: 0, 1: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 9: 0, 16: 0, 15: 0, 18: 0}
p.perform_pauli_measurements()
print(p.results)  # {}
p.check_runnability() # Raises error

I believe this occurs because :func: Pattern.perform_pauli_measurements does not handle Pattern.results adequately. If so, it should be an easy fix that could be incorporated to #392.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions