Skip to content

GridDevice should allow measuring any qubit #5652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
maffoo opened this issue Jun 29, 2022 · 1 comment · Fixed by #5654
Closed

GridDevice should allow measuring any qubit #5652

maffoo opened this issue Jun 29, 2022 · 1 comment · Fixed by #5654
Assignees
Labels
area/devices kind/bug-report Something doesn't seem to work. triage/discuss Needs decision / discussion, bring these up during Cirq Cynque

Comments

@maffoo
Copy link
Contributor

maffoo commented Jun 29, 2022

Description of the issue

Currently cirq_google.GridDevice requires that for any operation with exactly two qubits, the pair of qubits must be in qubit_pairs. However, not all 2-qubit operations require the qubits to be coupled. In particular, MeasurementGate should be allowed on any set of qubits, including pairs that are not coupled.

How to reproduce the issue

In [1]: import cirq; import cirq_google

In [2]: cirq_google.Sycamore.validate_operation(cirq.measure(cirq.q(0, 5), cirq.q(2, 5), cirq.q(4, 5)))

In [3]: cirq_google.Sycamore.validate_operation(cirq.measure(cirq.q(0, 5), cirq.q(2, 5)))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-a955df2ee85c> in <module>
----> 1 cirq_google.Sycamore.validate_operation(cirq.measure(cirq.q(0, 5), cirq.q(2, 5)))

~/src/quantumlib/cirq/cirq-google/cirq_google/devices/grid_device.py in validate_operation(self, operation)
    341             and frozenset(operation.qubits) not in self._metadata.qubit_pairs
    342         ):
--> 343             raise ValueError(f'Qubit pair is not valid on device: {operation.qubits!r}.')
    344 
    345     def __str__(self) -> str:

ValueError: Qubit pair is not valid on device: (cirq.GridQubit(0, 5), cirq.GridQubit(2, 5)).

Cirq version

0.15

@verult
Copy link
Collaborator

verult commented Jun 30, 2022

Thanks for the catch!

@viathor viathor added area/devices triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Jul 6, 2022
CirqBot pushed a commit that referenced this issue Jul 12, 2022
)

I'm comfortable with special-casing MeasurementGate because it's the only gate today with the property that it can be applied to any subset of qubits.

Fixes #5652

@maffoo
rht pushed a commit to rht/Cirq that referenced this issue May 1, 2023
…antumlib#5654)

I'm comfortable with special-casing MeasurementGate because it's the only gate today with the property that it can be applied to any subset of qubits.

Fixes quantumlib#5652

@maffoo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devices kind/bug-report Something doesn't seem to work. triage/discuss Needs decision / discussion, bring these up during Cirq Cynque
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants