tequilahub / tequila

A High-Level Abstraction Framework for Quantum Algorithms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`SPSA` optimizer throws error in minimization of circuit

dariavh opened this issue · comments

Describe the bug
SPSA optimizer throws algorithm when silent keyword in tequila.optimize() is set to False.

To Reproduce
Steps to reproduce the behavior:

import tequila as tq

molecule = tq.chemistry.Molecule(geometry = "H 0.0 0.0 0.0\nH 0.0 0.0 1.0", basis_set="sto-3g")

H = molecule.make_hamiltonian()
U = molecule.make_uccsd_ansatz(threshold=1e-06, trotter_steps=1)

# define the expectationvalue
E = tq.ExpectationValue(H=H, U=U)

# optimize
result = tq.minimize(objective=E, method="SPSA", samples=10000, initial_values={k:0.0 for k in E.extract_variables()}, silent=False)

Computer:

  • OS: Linux Darwin Kernel Version 22.3.0
  • Version: Python 3.7.12, tequila 1.8.9

Thanks for noticing. It should be fixed in version 1.9.1.
Until then:

```bash pip install --upgrade git+https://github.com/tequilahub/tequila.git@pr-spsa-print-fix ```
pip install --upgrade git+https://github.com/tequilahub/tequila.git@devel

Thank you!