Skip to content

Make C++ to Python state vector copying cheaper #237

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

Closed
95-martin-orion opened this issue Nov 10, 2020 · 2 comments
Closed

Make C++ to Python state vector copying cheaper #237

95-martin-orion opened this issue Nov 10, 2020 · 2 comments
Assignees

Comments

@95-martin-orion
Copy link
Collaborator

Users have noted that calling qsim_simulator.simulate() from Cirq takes considerably longer than the qsim simulation itself. This is likely due to the added cost of copying results from C++ to Python, which in theory can be avoided.

To resolve this issue, the pybind layer should ensure that results from Python are captured in C++ objects without copying.

@sergeisakov
Copy link
Collaborator

Calling results = qsim_simulator.simulate() from Cirq takes about the same time as the qsim simulation itself. The results are not copied from C++ to Python. Calling results.state_vector() from Cirq may take considerable time for large circuits. The problem is in Cirq not in qsimcirq, see line 215 in https://github.com/quantumlib/Cirq/blob/master/cirq/sim/state_vector_simulator.py.

@95-martin-orion
Copy link
Collaborator Author

Aha! That means this is a victim of Cirq PR 3115, which is meant to prevent mutation of the state vector in other simulators. I'll redirect this issue to Cirq.

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

No branches or pull requests

2 participants