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

An MPS (approximate) simulator #3630

Merged
merged 27 commits into from
Jan 12, 2021
Merged

An MPS (approximate) simulator #3630

merged 27 commits into from
Jan 12, 2021

Conversation

tonybruguier
Copy link
Contributor

This is based on this algo:
https://arxiv.org/abs/2002.07730

@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Dec 28, 2020
@tonybruguier tonybruguier marked this pull request as ready for review December 31, 2020 05:43
@tonybruguier tonybruguier requested review from cduck, vtomole and a team as code owners December 31, 2020 05:43
@tonybruguier
Copy link
Contributor Author

Hello,

I read more of the paper, and I think I understand how to do the 2D version (famous last words).

In the meantime, is there any comment on this PR? It would be nice to have some feedback on 1D before I attempted 2D.

Copy link
Collaborator

@95-martin-orion 95-martin-orion left a comment

Choose a reason for hiding this comment

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

CC'ing @rmlarose for review / comparison with external simulator.

Thanks for this addition! A couple of changes and clarifications needed, but overall the test coverage looks promising.

cirq/sim/mps_simulator.py Outdated Show resolved Hide resolved
cirq/sim/mps_simulator_test.py Outdated Show resolved Hide resolved
cirq/sim/mps_simulator_test.py Outdated Show resolved Hide resolved
cirq/sim/mps_simulator.py Show resolved Hide resolved
cirq/sim/mps_simulator.py Outdated Show resolved Hide resolved
@tonybruguier
Copy link
Contributor Author

Thanks. PTAL.

CirqBot pushed a commit that referenced this pull request Jan 12, 2021
During the (ongoing) review of #3630 95-martin-orion@ found a bug in my draft code. He said that I should copy state like in #3109. I changed my code and added a test in that PR.

However, I had inspired myself from the Clifford code which could have the same issue (I think), and so I am fixing the code in the present PR.
@95-martin-orion
Copy link
Collaborator

@tonybruguier I'm ready to merge this PR if you're happy with it - let me know.

@tonybruguier
Copy link
Contributor Author

Yes, please merge if you think it's fine to do so. Thank you for your help!

@95-martin-orion 95-martin-orion added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jan 12, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jan 12, 2021
@CirqBot CirqBot merged commit 989abad into quantumlib:master Jan 12, 2021
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Jan 12, 2021
@tonybruguier tonybruguier deleted the mps branch January 13, 2021 00:22
@rmlarose
Copy link
Contributor

Thanks Orion for the ping! I still haven't had time to look closely but will offer a few cursory comments if they're useful.

I think the simulator threshold is set internally at 1e-3? If so, it could be good to let this value be a simulator option, e.g. MPSSimulator(threshold=...). This allows for exact simulation (threshold = 0 <==> keep all singular values) in addition to "noisy" simulation (threshold > 0 <==> small singular values are thrown away).

I'm not sure in which order gates are applied, but it could be good to sweep from left to right (or right to left) to keep some canonicalization. This may not be necessary at present but certain operations are faster with canonical MPS.

Also not relevant now but maybe to future proof: this should support the "SimulatesExpectationValues" protocol when that is finalized since MPS are great for computing expectation values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants