Skip to content

add back add/remove_qubit to density matrix sim state#6259

Merged
tanujkhattar merged 2 commits intoquantumlib:masterfrom
sanuj:master
Aug 28, 2023
Merged

add back add/remove_qubit to density matrix sim state#6259
tanujkhattar merged 2 commits intoquantumlib:masterfrom
sanuj:master

Conversation

@sanuj
Copy link
Copy Markdown
Contributor

@sanuj sanuj commented Aug 25, 2023

For #6081.

add/remove_qubit() was added in #6108 and removed in #6127. I've added back the functions and updated remove_qubit() to self.factor() inplace to make the test (simulation_state_test.test_delegating_gate_channel()) pass.

The test was failing because the final density matrices were different for the control and test circuit. The simulate(test_circuit).final_density_matrix.shape was (2, 2, 2, 2) while simulate(control_circuit).final_density_matrix.shape was (2, 2). My guess was that the adding qubit was working fine but remove_qubit() was not able to remove the qubit. After debugging, I found that remove qubit was also working fine but self.factor() was not being done inplace and the density matrix was not getting updated during the removal of the qubit.

@sanuj sanuj requested review from a team, cduck and vtomole as code owners August 25, 2023 19:06
@sanuj sanuj requested a review from NoureldinYosri August 25, 2023 19:06
@google-cla
Copy link
Copy Markdown

google-cla bot commented Aug 25, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@CirqBot CirqBot added the size: S 10< lines changed <50 label Aug 25, 2023
@sanuj sanuj marked this pull request as draft August 25, 2023 19:08
@sanuj sanuj marked this pull request as ready for review August 28, 2023 00:03
@sanuj sanuj changed the title wip: add back add/remove_qubit to density matrix sim state add back add/remove_qubit to density matrix sim state Aug 28, 2023
Copy link
Copy Markdown
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.

This is great, thanks Sanuj for debugging the issue and sending the fix! Good to know that it was a minor fix and not a bigger issue with rest of the infrastructure.

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 28, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01% ⚠️

Comparison is base (ed26d2f) 97.60% compared to head (0764095) 97.60%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6259      +/-   ##
==========================================
- Coverage   97.60%   97.60%   -0.01%     
==========================================
  Files        1116     1116              
  Lines       95848    95858      +10     
==========================================
+ Hits        93556    93564       +8     
- Misses       2292     2294       +2     
Files Changed Coverage Δ
...q-core/cirq/sim/density_matrix_simulation_state.py 99.02% <100.00%> (+0.10%) ⬆️
cirq-core/cirq/sim/simulation_state_test.py 98.51% <100.00%> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tanujkhattar tanujkhattar merged commit 56b5db2 into quantumlib:master Aug 28, 2023
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
* wip: add back add/remove_qubit to density matrix sim state

* factorize inplace while removing qubit in density matrix simulation state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S 10< lines changed <50

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants