Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.05k stars 2.33k forks source link

An error occurs due to insufficient memory when obtaining the QAOA optimization parameters #12831

Closed Hawwwkim closed 1 month ago

Hawwwkim commented 1 month ago
sampler = Sampler()
optimizer = COBYLA()
qaoa = QAOA(sampler, optimizer, reps=1)
result = qaoa.compute_minimum_eigenvalue(H)

I'm a beginner. I was originally going to optimize the β and γ parameters in the QAOA circuit. When I run this code with a constructed hamiltonian H, which required 24 qubits, it will then raise an error: MemoryError:Unable to allocate 256. MiB for an array with shape (16777216,) and data type complex128. Anyone can help me with working this out? Thank you.

t-imamichi commented 1 month ago

If you use qiskit.primitives.Sampler, you cannot run a large hamiltonian because the Sampler does the statevector simulation and requires a lot of memory. I suggest Aer Primitives for the use case. https://qiskit.github.io/qiskit-aer/apidocs/aer_primitives.html

1ucian0 commented 1 month ago

This question seems to be answered by @t-imamichi so closing it. @Hawwwkim feel free to reopen or comment if that's not the case.