Skip to content

Qubits are not remapped in the default measurement key #4124

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
smitsanghavi opened this issue May 21, 2021 · 3 comments · Fixed by #4123
Closed

Qubits are not remapped in the default measurement key #4124

smitsanghavi opened this issue May 21, 2021 · 3 comments · Fixed by #4123
Assignees
Labels
area/measurements kind/bug-report Something doesn't seem to work. status/stale This has been closed due to inactivity for an extended period of time.

Comments

@smitsanghavi
Copy link
Collaborator

smitsanghavi commented May 21, 2021

Description of the issue
When a measurement operation created from cirq.measure without an explicit key is remapped to some other qubit, the measurement key does not update.

How to reproduce the issue

qubit = cirq.LineQubit(0)
op = cirq.measure(qubit)
assert cirq.measurement_key(op) == str(qubit)

qubit2 = cirq.LineQubit(1)
op2 = op.with_qubits(qubit2)
assert cirq.measurement_key(op2) == str(qubit2)

The last assertion will fail because the operation does not really process the key as made of the qubit. This might not strictly be a bug, but it would be much nicer to allow users to assume that when no explicit key is specified, Cirq will be smart enough to key the result by the actual qubit(s) that were operated on.

This issue is mainly for bookkeeping, I already have a fix planned and ready to go. Part of #4040

@smitsanghavi smitsanghavi added the kind/bug-report Something doesn't seem to work. label May 21, 2021
@smitsanghavi smitsanghavi self-assigned this May 21, 2021
@viathor viathor added area/measurements triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Jun 14, 2021
@smitsanghavi
Copy link
Collaborator Author

Reopening for discussion on what is the desired behavior here.

If there was no explicitly specified name for the measurement, should the final Results object be keyed by the qubits that were measured or the qubits that were originally used to create the operation?

@smitsanghavi smitsanghavi reopened this Jul 20, 2021
@95-martin-orion
Copy link
Collaborator

If there was no explicitly specified name for the measurement, should the final Results object be keyed by the qubits that were measured or the qubits that were originally used to create the operation?

From the discussion on this topic, my takeaway was that measurement keys should be defined at construction time so that it's easy to reference them later on (i.e. without having to manually parse through the circuit). Key-renaming in CircuitOperations runs somewhat contrary to this, but depending on the outcome of #4274 that contradiction may also be removed.

@tanujkhattar tanujkhattar added triage/stale and removed triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Aug 18, 2021
@github-actions
Copy link

Issue closed due to inactivity.

@mhucka mhucka added T status/stale This has been closed due to inactivity for an extended period of time. and removed triage/stale labels Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/measurements kind/bug-report Something doesn't seem to work. status/stale This has been closed due to inactivity for an extended period of time.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants