-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make state vector copying explicit #3494
Comments
For the final simulator state it's not clear why it needs to copy at all (Think @95-martin-orion commented on this in original PR not sure why I ignored it). |
ref #3115 |
Discussed at Cirq Cynque: 1. let's go without copy. 2. make a note in the release notes about potential breakage here. |
From cirq sync: Let's do it!! |
@95-martin-orion I just remembered to mention: I noticed an unnecessary sv copy introduced in https://github.com/quantumlib/Cirq/pull/4533/files. While that PR made sweeps more efficient, it inordinately makes an unnecessary copy of the state when running One solution is to have the base implementation skip copying the state for the last paramresolver, and just use the provided state directly. Officially this would be breaking since simulate_sweep_iter is public. |
Kind of tangential to this issue, but I support the solution you've described. What happened to |
Removes the copy when simulating params. #3494 (comment) for discussion. @95-martin-orion
Part of #3494 (requires deprecation cycle to resolve). This adds the `copy` parameter to all `state_vector` methods affected by #3494, and sets up deprecation messages to change the default copy behavior to "don't copy" in the next Cirq release. The only substantive changes are in `sparse_simulator.py`, `state_vector.py`, and `state_vector_simulator.py`; all other changes simply inject `copy` to prevent deprecation warnings from `state_vector` calls (True for step results, False for final results).
With #5324 merged, all that's left for this is to complete the deprecation and switch the default to |
Fixes #3494. This PR bundles together a bunch of cleanup around `[final_]state_vector` deprecations.
Removes the copy when simulating params. quantumlib#3494 (comment) for discussion. @95-martin-orion
Part of quantumlib#3494 (requires deprecation cycle to resolve). This adds the `copy` parameter to all `state_vector` methods affected by quantumlib#3494, and sets up deprecation messages to change the default copy behavior to "don't copy" in the next Cirq release. The only substantive changes are in `sparse_simulator.py`, `state_vector.py`, and `state_vector_simulator.py`; all other changes simply inject `copy` to prevent deprecation warnings from `state_vector` calls (True for step results, False for final results).
Fixes quantumlib#3494. This PR bundles together a bunch of cleanup around `[final_]state_vector` deprecations.
Removes the copy when simulating params. quantumlib#3494 (comment) for discussion. @95-martin-orion
Part of quantumlib#3494 (requires deprecation cycle to resolve). This adds the `copy` parameter to all `state_vector` methods affected by quantumlib#3494, and sets up deprecation messages to change the default copy behavior to "don't copy" in the next Cirq release. The only substantive changes are in `sparse_simulator.py`, `state_vector.py`, and `state_vector_simulator.py`; all other changes simply inject `copy` to prevent deprecation warnings from `state_vector` calls (True for step results, False for final results).
Fixes quantumlib#3494. This PR bundles together a bunch of cleanup around `[final_]state_vector` deprecations.
The
state_vector
method inStateVectorTrialResult
includes a copying of the state vector to resolve issue #3101:Cirq/cirq/sim/state_vector_simulator.py
Line 215 in 8bf262e
This eliminates the issue of mutating the state vector, but can significantly increase runtime for large circuits without a clear indication of the root cause. We should force users to explicitly make a copy of the state if they need it, either by renaming the method to
state_vector_copy
or by removing it altogether and requiring users to copy thefinal_state_vector
field.Related: qsim issue 237
The text was updated successfully, but these errors were encountered: