Skip to content
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

Support multi-qubit measurements in deferred measurement transformer #5787

Merged
merged 8 commits into from
Jul 18, 2022

Conversation

daxfohl
Copy link
Contributor

@daxfohl daxfohl commented Jul 16, 2022

Use SumOfProducts to enable controls from multi-qubit measurements in deferred measurement transformer.

Fixes #5694

@daxfohl daxfohl requested review from a team, vtomole and cduck as code owners July 16, 2022 02:41
@daxfohl daxfohl requested a review from maffoo July 16, 2022 02:41
@CirqBot CirqBot added the size: M 50< lines changed <250 label Jul 16, 2022
@daxfohl daxfohl marked this pull request as draft July 16, 2022 04:24
@daxfohl daxfohl marked this pull request as ready for review July 16, 2022 14:10
@tanujkhattar tanujkhattar self-assigned this Jul 17, 2022
Copy link
Collaborator

@tanujkhattar tanujkhattar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any plans to provide a more explicit control on key conditions for a classically controlled operation? For example, can we say "Execute X(q0) only if measurement result of q1 and q0 is either both 0 or both 1" ? I guess this would require extending classically controlled operations to also accept control values?

It was a bit weird to see that the default strategy we are following for multi qubit classical controls is to activate the classical control on "anything but zeros". This can probably be a good first start, but I'm curious to hear if you've already thought on this.

@daxfohl
Copy link
Contributor Author

daxfohl commented Jul 18, 2022

A KeyCondition is triggered if it is non zero, which means at least one of the qubits it measured was non zero, which is equivalent to "anything but all zeros". To do more complex logic, you can use a SympyCondition

cirq.X(q_result).with_classical_controls(sympy_parser.parse_expr('m_j > m_i')),
.

@tanujkhattar tanujkhattar merged commit 5a8b496 into quantumlib:master Jul 18, 2022
@daxfohl daxfohl deleted the deferred-multi branch October 12, 2022 00:48
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
…uantumlib#5787)

* Support multi-qubit measurements in deferred measurement transformer

* mypy

* invert if branch

* docstring
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
…uantumlib#5787)

* Support multi-qubit measurements in deferred measurement transformer

* mypy

* invert if branch

* docstring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi-qubit conditions in DeferredMeasurementsTransformer
3 participants