Skip to content

Fix density matrix simulator when subcircuits exist #3745

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

Merged
merged 4 commits into from
Feb 8, 2021

Conversation

daxfohl
Copy link
Collaborator

@daxfohl daxfohl commented Feb 3, 2021

Fixes #3723 by forcing run_sweep_repeat in density matrix simulator if subcircuits are detected in the circuit. run_sweep_sample does not work in this case because there's no way to sample a subcircuit.

@daxfohl daxfohl requested review from cduck, vtomole and a team as code owners February 3, 2021 17:53
@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Feb 3, 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.

This is reasonable as a workaround for #3723, but run_sweep_repeat takes O(repetitions) times longer to complete than run_sweep_sample. In the long term, we'll want to switch back to "sample" where possible. The same applies to sparse_simulator, which will mark an entire subcircuit as non-unitary even if it only has terminal measurements.

One cheap-ish way to do this would be to split the subcircuit and its measurements:

# pseudocode
Circuit(CircuitOp(op1, op2, op3, measure))
--> Circuit(CircuitOp(op1, op2, op3), measure)

That step needs to be recursive, but it would be much cheaper to implement "subcircuit splitting" than full subcircuit sampling.

@95-martin-orion 95-martin-orion merged commit f08b344 into quantumlib:master Feb 8, 2021
@daxfohl daxfohl deleted the dms branch February 18, 2021 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DensityMatrixSimulator not working with subcircuits
2 participants