Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix: 🐛 Fix the Substate Vector Problem#16

Merged
DRovara merged 4 commits into
mainfrom
bugix/substate-vectors
Aug 29, 2024
Merged

fix: 🐛 Fix the Substate Vector Problem#16
DRovara merged 4 commits into
mainfrom
bugix/substate-vectors

Conversation

@DRovara

@DRovara DRovara commented Aug 28, 2024

Copy link
Copy Markdown
Collaborator

Description

This pull request resolves the currently biggest underlying issue: The generation of substate vectors. At the moment, substate vectors are computed by projecting the full state vector onto a subset of its qubits. While this is a valid approach in general, the resulting vector is not guaranteed to be a valid state vector. Due to destructive interference, it may not be normalised or a 0-vector, which is not compatible with many use cases.

Furthermore, all assertion types are currently implemented using substate vectors. For instance, for the superposition assertion, we first compute a substate vector containing only the target qubits and then we perform our calculation. Because of that, this bug spreads over a large part of the code base.

To resolve this, this pull request brings the following changes:

  • Substate vectors are revised: Now, instead, we compute the density matrix, trace out unwanted qubits, and then transform back into a state vector. This only works, if the qubits to trace out were not entangled with the other qubits. In other cases, this will throw an exception (and return ERROR)
  • Superposition assertion checks are updated: Now, instead of first computing the substate vector, we just take all amplitudes into account. Computationally, this is not more complex than the previous approach, as before, the substate vector computation also checked all amplitudes. By no longer using substate vectors, we can still use this assertion, even if one of the target qubits is entangled with a non-target qubit.
  • Entanglement checks are updated: The concept of "is qubit X entangled with qubit Y" is more involved than the previous implementation. Previously, we computed the substate vector of only target qubits and then checked all individual pairs of qubits for entanglement. But now, this would no longer work if a target qubit is entangled with a non-target qubit. Furthermore, the entire previous approach does not work in the presence of entanglement. Therefore, we now use the metric of "mutual information" to check for entanglement. For each pair of target qubits, we first compute our density matrix and trace out all other qubits. This new density matrix is not necessarily pure. We then generate two more density matrices by tracing out each of the remaining qubits, respectively. Using the entropy of these three density matrices, we can then compute the mutual information, which is 0 if and only if the qubits were not entangled. Tests so far seem to suggest that this metric is valid.

Fixes # (issue)

Checklist:

  • The pull request only contains commits that are related to it.
  • I have added appropriate tests and documentation.
  • I have made sure that all CI jobs on GitHub pass.
  • The pull request introduces no new warnings and follows the project's style guidelines.

Now, we check if a given substate is separable, and if it is, we trace out unwanted qubits instead of performing a projection
@DRovara DRovara changed the title Fix the Substate Vector Problem fix: 🐛 Fix the Substate Vector Problem Aug 28, 2024
@codecov-commenter

codecov-commenter commented Aug 28, 2024

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 97.52475% with 5 lines in your changes missing coverage. Please review.

Project coverage is 93.6%. Comparing base (6f227dc) to head (d3c7c64).

Files Patch % Lines
src/backend/dd/DDSimDebug.cpp 97.2% 5 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main     #16     +/-   ##
=======================================
+ Coverage   93.2%   93.6%   +0.3%     
=======================================
  Files          9       9             
  Lines       1247    1363    +116     
  Branches     194     226     +32     
=======================================
+ Hits        1163    1276    +113     
- Misses        84      87      +3     
Flag Coverage Δ
cpp 93.5% <97.5%> (+0.3%) ⬆️
python 100.0% <ø> (ø)
Files Coverage Δ
src/backend/dd/DDSimDiagnostics.cpp 98.0% <100.0%> (+0.1%) ⬆️
src/backend/dd/DDSimDebug.cpp 91.6% <97.2%> (+0.8%) ⬆️

... and 1 file with indirect coverage changes

@DRovara DRovara merged commit 819bf08 into main Aug 29, 2024
@DRovara DRovara deleted the bugix/substate-vectors branch August 29, 2024 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants