tequilahub / tequila

A High-Level Abstraction Framework for Quantum Algorithms
MIT License
369 stars 103 forks source link

`SPSA` optimizer throws error in minimization of circuit #315

Closed dariavh closed 1 year ago

dariavh commented 1 year ago

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:

kottmanj commented 1 year ago

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

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
dariavh commented 1 year ago

Thank you!