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

Fix ignore_measurement_results=True for subcircuits #4760

Merged
merged 3 commits into from
Dec 23, 2021

Conversation

daxfohl
Copy link
Contributor

@daxfohl daxfohl commented Dec 17, 2021

Density matrix simulator has a bug that if ignore_measurement_results is set, that setting is overlooked within subcircuits.

The reason is that this setting check is done in SimulatorBase.core_iterator, but that only iterates the outermost circuit.

The fix is to move the check into ActOnArgs.measure, to ensure that any measurement is replaced with a dephase operation.

Surprisingly we did not even have a test for the non-subcircuit case. This PR adds a test for that and the subcircuit case.

@daxfohl daxfohl requested review from cduck, vtomole and a team as code owners December 17, 2021 17:48
@daxfohl daxfohl requested a review from dabacon December 17, 2021 17:48
@CirqBot CirqBot added the size: M 50< lines changed <250 label Dec 17, 2021
@daxfohl
Copy link
Contributor Author

daxfohl commented Dec 23, 2021

cc @95-martin-orion

@95-martin-orion 95-martin-orion self-assigned this Dec 23, 2021
Copy link
Collaborator

@95-martin-orion 95-martin-orion left a comment

Choose a reason for hiding this comment

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

Seeing as the state vector simulator is unaffected by this, there should be no backwards-compatibility issues if users happen to define their own ActOnArgs outside Cirq.

Some docs comments, then this can merge.

cirq-core/cirq/sim/act_on_args.py Outdated Show resolved Hide resolved
@95-martin-orion 95-martin-orion added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Dec 23, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Dec 23, 2021
@CirqBot
Copy link
Collaborator

CirqBot commented Dec 23, 2021

Automerge cancelled: A required status check is not present.

Missing statuses: ['Pytest Windows (3.7)', 'Pytest Windows (3.8)', 'Pytest Windows (3.9)', 'Typescript lint check', 'Typescript tests', 'Typescript tests coverage']

@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Dec 23, 2021
@95-martin-orion
Copy link
Collaborator

Automerge cancelled: A required status check is not present.

Dear, sweet @CirqBot. Your ruthless vigilance towards "incomplete" tests inspires us all 😛

@MichaelBroughton MichaelBroughton added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Dec 23, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Dec 23, 2021
@CirqBot CirqBot merged commit 9581e65 into quantumlib:master Dec 23, 2021
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Dec 23, 2021
@daxfohl daxfohl deleted the fix_nomeasure branch December 24, 2021 02:12
MichaelBroughton pushed a commit to MichaelBroughton/Cirq that referenced this pull request Jan 22, 2022
Density matrix simulator has a bug that if `ignore_measurement_results` is set, that setting is overlooked within subcircuits.

The reason is that this setting check is done in `SimulatorBase.core_iterator`, but that only iterates the outermost circuit.

The fix is to move the check into `ActOnArgs.measure`, to ensure that any measurement is replaced with a dephase operation.

Surprisingly we did not even have a test for the non-subcircuit case. This PR adds a test for that and the subcircuit case.
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Density matrix simulator has a bug that if `ignore_measurement_results` is set, that setting is overlooked within subcircuits.

The reason is that this setting check is done in `SimulatorBase.core_iterator`, but that only iterates the outermost circuit.

The fix is to move the check into `ActOnArgs.measure`, to ensure that any measurement is replaced with a dephase operation.

Surprisingly we did not even have a test for the non-subcircuit case. This PR adds a test for that and the subcircuit case.
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
Density matrix simulator has a bug that if `ignore_measurement_results` is set, that setting is overlooked within subcircuits.

The reason is that this setting check is done in `SimulatorBase.core_iterator`, but that only iterates the outermost circuit.

The fix is to move the check into `ActOnArgs.measure`, to ensure that any measurement is replaced with a dephase operation.

Surprisingly we did not even have a test for the non-subcircuit case. This PR adds a test for that and the subcircuit case.
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.

4 participants