quil-lang / qvm

The high-performance and featureful Quil simulator.
Other
413 stars 57 forks source link

QVM does not release memory after large qubit simulations #198

Closed jmackeyrigetti closed 4 years ago

jmackeyrigetti commented 4 years ago

After running a 32 qubit simulation, the full 64G of RAM was used but upon completion, not released:

free -h total used free shared buff/cache available Mem: 124G 64G 55G 932K 4.5G 58G Swap: 0B 0B 0B

Subsequent simulations to the QVM fail to release the RAM and cannot allocate enough for the next simulation: `<135>1 2019-10-24T18:06:31Z a3ae8eac44b3 qvm 1 - - [172.17.0.1 Session:2] Got "multishot" request from API key/User ID: NIL / NIL

<135>1 2019-10-24T18:06:31Z a3ae8eac44b3 qvm 1 - - [172.17.0.1 Session:2] Making qvm of 32 qubits <131>1 2019-10-24T18:06:31Z a3ae8eac44b3 qvm 1 - - [2019-10-24 18:06:31 [ERROR]] Error while processing connection: The condition The condition Cannot allocate memory: malloc() of 68719476752 bytes failed. occurred with errno: 0. occurred with errno: 0. `
jmbr commented 4 years ago

The Lisp image has no idea how taxing the foreign memory allocation is and, consequently, it does not collect garbage often enough. The patch #199 "fixes" the issue by triggering a full garbage collection after each request.