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

Enable efficient contraction order simulation #166

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open

Conversation

nabe98
Copy link
Contributor

@nabe98 nabe98 commented Jun 17, 2024

Before submitting, please check the following:

  • Make sure you have tests for the new code and that test passes (run tox)
  • If applicable, add a line to the [unreleased] part of CHANGELOG.md, following keep-a-changelog.
  • Format added code by black and isort
    • See pyproject.toml for configurations

Then, please fill in below:

Context (if applicable):

Description of the change:
Enabled TN contraction based state vector simulator, which is more efficient compared with pure state-vector simulation.

Related issue:
#92

also see that checks (github actions) pass.
If lint check keeps failing, try installing black==22.8.0 as behavior seems to vary across versions.

Copy link

codecov bot commented Jun 17, 2024

Codecov Report

Attention: Patch coverage is 97.59036% with 2 lines in your changes missing coverage. Please review.

Project coverage is 75.89%. Comparing base (364be19) to head (d124700).

Files Patch % Lines
graphix/random_objects.py 96.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #166      +/-   ##
==========================================
+ Coverage   75.52%   75.89%   +0.37%     
==========================================
  Files          34       34              
  Lines        5569     5638      +69     
==========================================
+ Hits         4206     4279      +73     
+ Misses       1363     1359       -4     

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

graphix/random_circuit.py Outdated Show resolved Hide resolved
@nabe98 nabe98 requested a review from shinich1 July 14, 2024 11:21
Comment on lines +575 to +580
op = op.reshape(
[
2,
]
* (2 * op_dim)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

use black -l 120?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. If I left this like op = op.reshape([2,] * (2 * op_dim), cannot pass the check for black.


Parameters
----------
indices (optional): list of int
target qubit indices. Default is the MBQC output nodes (self.default_output_nodes).
skip : bool
Copy link
Contributor

Choose a reason for hiding this comment

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

argument name skip is way too generic and very difficult to understand. Consider making it skip_tn_simp or restructure. Also, why/who/when do we want to skip the simplification?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This option is not that essential, so I removed skip.

def to_statevector(self, indices=None, **kwagrs):
"""Retrieve the statevector from the tensornetwork.
This method tends to be slow however we plan to parallelize this.
def to_statevector(self, skip=False, **kwagrs) -> NDArray:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add very detailed description (100+ words, with equations and diagrams) to this method as this is rather uncommon way to use TN (for most people, at least afaik).
Is this proven to work for any case or are there limitations? worth pointing out we're NOT performing the intermediate measurements according to probability distribution? what is the expected space/time cost compared to statevector sim?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added that based on notes and discussion in #92 .

@nabe98 nabe98 requested a review from shinich1 July 25, 2024 08:58
@shinich1
Copy link
Contributor

shinich1 commented Aug 3, 2024

@nabe98 can you paste benchmarking result (plot) on this page?

@nabe98
Copy link
Contributor Author

nabe98 commented Aug 4, 2024

OK.
I'll share that as soon as I return to my home (around 8/7).

@nabe98
Copy link
Contributor Author

nabe98 commented Aug 9, 2024

@shinich1
Here is the benchmarking result plot.
simulation_time

@nabe98
Copy link
Contributor Author

nabe98 commented Aug 19, 2024

simulation_time
The latest benchmarking plot with error bars (for 5 iterations).

@nabe98 nabe98 self-assigned this Aug 19, 2024
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.

3 participants