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

[QIM-1] Create a qml.math.density_matrix for state vectors #2554

Merged
merged 49 commits into from
Jun 10, 2022

Conversation

rmoyard
Copy link
Contributor

@rmoyard rmoyard commented May 10, 2022

Quantum Information module PR # 1
Context:

Currently the way to get the (reduced) density matrix from a state vector is a function in the device default.qubit.

Description of the Change:

We add _density_matrix_from_state_vector internal function that takes 1-d tensors for all interfaces as input and returns the density matrix. It also creates state_to_density_matrix which will be the user facing function that accepts state vectors, density matrices and QNodes returning states.

We also move the density matrix capabilities for state vector to the math module.

Benefits:

The density matrix capabilities for state vectors are now in the math module and it becomes a function accessible across the whole code base.

@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@rmoyard rmoyard added the WIP 🚧 Work-in-progress label May 10, 2022
@rmoyard rmoyard changed the title Create a qml.math.density_matrix for state vectors [WIP] Create a qml.math.density_matrix for state vectors May 10, 2022
@codecov
Copy link

codecov bot commented May 10, 2022

Codecov Report

Merging #2554 (df6d61b) into master (954db44) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2554   +/-   ##
=======================================
  Coverage   99.60%   99.60%           
=======================================
  Files         249      249           
  Lines       20294    20307   +13     
=======================================
+ Hits        20213    20226   +13     
  Misses         81       81           
Impacted Files Coverage Δ
pennylane/devices/default_qubit.py 100.00% <100.00%> (ø)
pennylane/math/__init__.py 100.00% <100.00%> (ø)
pennylane/math/quantum.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 954db44...df6d61b. Read the comment docs.

@rmoyard rmoyard changed the title [WIP] Create a qml.math.density_matrix for state vectors Create a qml.math.density_matrix for state vectors May 19, 2022
@rmoyard rmoyard added review-ready 👌 PRs which are ready for review by someone from the core team. and removed WIP 🚧 Work-in-progress labels May 19, 2022
pennylane/math/quantum.py Outdated Show resolved Hide resolved
@rmoyard rmoyard changed the title Create a qml.math.density_matrix for state vectors [QIM 1] Create a qml.math.density_matrix for state vectors May 19, 2022
@rmoyard rmoyard changed the title [QIM 1] Create a qml.math.density_matrix for state vectors [QIM-1] Create a qml.math.density_matrix for state vectors May 19, 2022
Copy link
Contributor

@antalszava antalszava left a comment

Choose a reason for hiding this comment

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

Looking great, with some comments here and there. 🚀

pennylane/math/quantum.py Show resolved Hide resolved
pennylane/math/quantum.py Outdated Show resolved Hide resolved
pennylane/math/quantum.py Outdated Show resolved Hide resolved
pennylane/math/quantum.py Show resolved Hide resolved
pennylane/math/quantum.py Outdated Show resolved Hide resolved
tests/math/test_functions.py Outdated Show resolved Hide resolved
tests/devices/test_default_qubit_torch.py Show resolved Hide resolved
pennylane/math/quantum.py Show resolved Hide resolved
pennylane/math/quantum.py Outdated Show resolved Hide resolved
pennylane/math/quantum.py Outdated Show resolved Hide resolved
Copy link
Contributor

@eddddddy eddddddy left a comment

Choose a reason for hiding this comment

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

Looking good @rmoyard! Just have a couple of minor suggestions.

pennylane/math/quantum.py Outdated Show resolved Hide resolved
pennylane/math/quantum.py Outdated Show resolved Hide resolved
Copy link
Contributor

@antalszava antalszava left a comment

Choose a reason for hiding this comment

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

Looks good! 🎉 🚀 Worth starting an entry in the changelog.

@rmoyard rmoyard requested a review from albi3ro May 31, 2022 14:02
pennylane/math/quantum.py Outdated Show resolved Hide resolved
pennylane/math/quantum.py Outdated Show resolved Hide resolved
pennylane/math/quantum.py Outdated Show resolved Hide resolved
Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! Remember a changelog entry.

@rmoyard
Copy link
Contributor Author

rmoyard commented May 31, 2022

[sc-19608]

@rmoyard rmoyard merged commit 8332b0e into master Jun 10, 2022
@rmoyard rmoyard deleted the density_matrix_from_array branch June 10, 2022 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review-ready 👌 PRs which are ready for review by someone from the core team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants