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

Make cirq.final_density_matrix work on classical controls #5915

Open
daxfohl opened this issue Oct 11, 2022 · 1 comment
Open

Make cirq.final_density_matrix work on classical controls #5915

daxfohl opened this issue Oct 11, 2022 · 1 comment
Assignees
Labels
area/density-matrix-simulator area/simulation good for learning For beginners in QC, this will help picking up some knowledge. Bit harder than "good first issues" kind/feature-request Describes new functionality triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on

Comments

@daxfohl
Copy link
Collaborator

daxfohl commented Oct 11, 2022

Is your feature request related to a use case or problem? Please describe.

The ignore_measurement_results argument of final_density_matrix is used for calculating the final density matrix without ever collapsing the DM due to a measurement. However this causes the function to fail when presented with a classically controlled operation.

Describe the solution you'd like

This can be fixed by first passing the circuit through the defer_measurements transformer, before passing through the dephase_measurements transformer. The simulator can then run on this circuit. The produced DM will include axes for the ancilla qubits that were added in the deferral transform. These can be removed by doing a partial_trace and only retaining the axes corresponding to the original circuit's qubits.

Note that within final_density_matrix we'd also have to apply the noise model explicitly, prior to calling defer_measurements, instead of just passing it into the simulator. Otherwise any noise would be applied to the ancilla "measurement qubits" as well, which is not desired.

(good for learning, good first issue with some guidance) I'll leave this open for a while if someone wants to contribute.

[optional] Describe alternatives/workarounds you've considered

We could build this functionality into the simulators themselves. This would be a lot longer project and I imagine could get quite gnarly. Though a possible approach for that was prototyped and discussed here #6040 (comment)

[optional] Additional context (e.g. screenshots)

What is the urgency from your perspective for this issue? Is it blocking important work?

P3 - I'm not really blocked by it, it is an idea I'd like to discuss / suggestion based on principle

@daxfohl daxfohl added the kind/feature-request Describes new functionality label Oct 11, 2022
@viathor viathor added triage/discuss Needs decision / discussion, bring these up during Cirq Cynque area/simulation area/density-matrix-simulator labels Nov 8, 2022
@tanujkhattar tanujkhattar added the good for learning For beginners in QC, this will help picking up some knowledge. Bit harder than "good first issues" label Mar 30, 2023
@TarunSinghaniaGoogle
Copy link

TarunSinghaniaGoogle commented Apr 4, 2023

Hi all,

I can take this up. Will reach out in case I have any questions.
Upd: Looks like I used the google github account to comment here.
Can you please reassign it to @TarunSinghania.

@verult verult added triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on and removed triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/density-matrix-simulator area/simulation good for learning For beginners in QC, this will help picking up some knowledge. Bit harder than "good first issues" kind/feature-request Describes new functionality triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on
Projects
None yet
Development

No branches or pull requests

5 participants