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

Add partial_transpose to quantum_info.linalg_operations #1462

Merged
merged 18 commits into from
Oct 7, 2024

Conversation

renatomello
Copy link
Contributor

@renatomello renatomello commented Sep 23, 2024

Needs to be merged before #1456

Checklist:

  • Reviewers confirm new code works as expected.
  • Tests are passing.
  • Coverage does not decrease.
  • Documentation is updated.

@renatomello renatomello added documentation Improvements or additions to documentation enhancement New feature or request quantum_info module PRs and issues related to the quantum information module labels Sep 23, 2024
@renatomello renatomello added this to the Qibo 0.2.13 milestone Sep 23, 2024
@renatomello renatomello self-assigned this Sep 23, 2024
Copy link

codecov bot commented Sep 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.93%. Comparing base (9fb5161) to head (7f33911).
Report is 19 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1462   +/-   ##
=======================================
  Coverage   99.93%   99.93%           
=======================================
  Files          81       81           
  Lines       11750    11777   +27     
=======================================
+ Hits        11742    11769   +27     
  Misses          8        8           
Flag Coverage Δ
unittests 99.93% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@BrunoLiegiBastonLiegi BrunoLiegiBastonLiegi left a comment

Choose a reason for hiding this comment

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

I think it might be useful to allow the inputs to both partial_transpose and partial_trace (this one in a separate PR though) to be batches of states, similarly to what it is done for vectorization in #1459. This would make more efficient, for instance, the calculation of the meyer_wallach_entanglement

def meyer_wallach_entanglement(state, backend=None):

and similar methods that need to perform these operations on several different states.

@renatomello
Copy link
Contributor Author

I think it might be useful to allow the inputs to both partial_transpose and partial_trace (this one in a separate PR though) to be batches of states, similarly to what it is done for vectorization in #1459. This would make more efficient, for instance, the calculation of the meyer_wallach_entanglement

def meyer_wallach_entanglement(state, backend=None):

and similar methods that need to perform these operations on several different states.

Done.

@renatomello
Copy link
Contributor Author

renatomello commented Oct 4, 2024

@AlejandroSopena @stavros11 this is ready. Could you review it soon since it is blocking #1456 ? Thanks

Copy link
Member

@stavros11 stavros11 left a comment

Choose a reason for hiding this comment

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

Thanks @renatomello. Generally fine with me, but I have not checked validity so I just trust the test.

It took me some time to understand the supported input shapes and I think we are kind of overcomplicating it by supporting 1-dimensional arrays. To me, since this is a partial trace, it would even be sufficient to stick to 2-dimensional. If someone wants to process a 1-dimensional one, they can still do the outer product before calling this (this way it is also a bit more modular). However, I am not the best candidate user of this, so it's not a strong opinion.

Other than that, I understand you are also supporting a "batch" dimension (N). There may be a way to generalize this to arbitrary number of batch dimensions ((..., k, k)), so that you don't even have to distinguish between batch/no batch, but I haven't thought much about whether this can be easily done and maybe it's not very useful in the end.

src/qibo/quantum_info/linalg_operations.py Outdated Show resolved Hide resolved
@renatomello
Copy link
Contributor Author

renatomello commented Oct 7, 2024

Thanks @renatomello. Generally fine with me, but I have not checked validity so I just trust the test.

It took me some time to understand the supported input shapes and I think we are kind of overcomplicating it by supporting 1-dimensional arrays. To me, since this is a partial trace, it would even be sufficient to stick to 2-dimensional. If someone wants to process a 1-dimensional one, they can still do the outer product before calling this (this way it is also a bit more modular). However, I am not the best candidate user of this, so it's not a strong opinion.

I think it's fine supporting statevectors because it takes an extra step from the users' hands at the price of a handful of lines of code on our side. So the trade-off is worth IMO.

Other than that, I understand you are also supporting a "batch" dimension (N). There may be a way to generalize this to arbitrary number of batch dimensions ((..., k, k)), so that you don't even have to distinguish between batch/no batch, but I haven't thought much about whether this can be easily done and maybe it's not very useful in the end.

I like the idea, but for the interest of time I prefer to move forward as is because we have some priorities that are more urgent.

@renatomello renatomello added this pull request to the merge queue Oct 7, 2024
Merged via the queue into master with commit a59e5d7 Oct 7, 2024
27 checks passed
@renatomello renatomello deleted the partial_transpose branch October 7, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request quantum_info module PRs and issues related to the quantum information module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants