-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Description of the issue
First reported in quantumlib/qsim#612. Cirq ~=1.0
requires qsimcirq to return its simulation output as a cirq.StateVectorTrialResult
. In the current implementation, it causes an OOM when running a 32-qubit circuit on an a2-highgpu-1g, with a RAM of 85 GB. But it used to be not the case in qsimcirq 0.13.
In the specific case when the statevector is final (no further operations on the statevector are needed after the simulation), this construction is expensive as it requires, at one point, 3x-4x more RAM than is necessary. The allocations are:
- The C++ buffer of the statevector in the qsim layer. Is it
scratch
? - The Python buffer of the statevector in the Cirq layer
The simulation output viewed as an array ofnp.complex64
this view has been removed by @NoureldinYosri (https://github.com/quantumlib/qsim/blob/7b921299e53073e1f4e35c9b349dcf9655d76b63/qsimcirq/qsim_simulator.py#L561 in quantumlib/qsim@0009bc4)this shouldn't cause any extra RAM because it's just a view- The copy of the simulation output
A quick modification on a live Cirq 1.1.0 install, where I removed the state_vector = state_vector.copy()
, resulted in the OOM error gone. But it seems that the extra RAM consumption could be further reduced.
How to reproduce the issue
Steps to reproduce and the output can be found in quantumlib/qsim#612 (comment).
Cirq version
~= 1.0
Metadata
Metadata
Assignees
Labels
Type
Projects
Status