Skip to content

single_qubit_state_tomography issues with multiple key measurements #7417

Open
@kygnz

Description

@kygnz

Issue:

When trying to run single_qubit_state_tomography on a CircuitOperation object that contains measurements, my group and I run into the error "cannot extract 2D measurements for repeated keys". Upon observing the file qubit_characterizations.py, we found the issue lies in the function definition of single_qubit_state_tomography, with rho_11, rho_01_im, and rho_01_re initialized using results.measurements. Changing the lines to results.records eliminates the error. Is this an unintended bug in the tomography function?

How to recreate the issue:


import cirq
import cirq.experiments
import sympy

qubits = cirq.LineQubit.range(3)
circuit = cirq.Circuit()

circuit.append(
    [
        cirq.X(qubits[0]),
        cirq.X(qubits[1]),
        cirq.X(qubits[2]),
    ]
)


circuit.append(
    [
        cirq.measure(qubits[0], key="a"),
        cirq.measure(qubits[1], key="b"),
        cirq.measure(qubits[2], key="c"),
    ]
)

a, b, c = sympy.symbols("a,b,c")
sympy_cond = cirq.SympyCondition(sympy.Eq(a + b + c, 0))


print(circuit)
sim = cirq.Simulator()

circuitBuilt = cirq.Circuit(
    cirq.CircuitOperation(
        circuit=circuit.freeze(),
        repeat_until=sympy_cond,
        use_repetition_ids=False,
    )
)

print("\n------------------- single qubit state tomography -------------------")
# Without updating qubit_characterizations.py, tomography_result produces an error
tomography_result = cirq.experiments.single_qubit_state_tomography(
    sim, qubits[0], circuitBuilt, 1000
)

print(tomography_result.data)


Cirq Version:

1.5.0

Metadata

Metadata

Assignees

Labels

area/tomographygood first issueThis issue can be resolved by someone who is not familiar with the codebase. A good starting issue.good part-time projectA meaty non-urgent issue with a substantial amount of work to be done.kind/feature-requestDescribes new functionalitytriage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions