Skip to content

Conversation

@S-Erik
Copy link

@S-Erik S-Erik commented Oct 26, 2025

Hey everyone,

I'd like to add the ExcitationSolve (code, preprint) optimizer to tequila. See a code example below using the implemented ExcitationSolve optimizer.

Open questions:

  • Should I add a test in the tests folder?
  • I am not sure if the return value of the ExciationSolve minimize function is acceptable (currently a SciPyResults object).
  • I am not sure if I used the history member variable correctly.

Code example

import tequila as tq

tq.show_available_optimizers() # Lists now: excitationsolve      | excitationsolve

# define a molecule within an active space
active_orbitals = [1, 2, 5]
geometry = """
Li  0.0 0.0 0.0
H   0.0 0.0 1.6
"""
molecule = tq.quantumchemistry.Molecule(
    geometry=geometry, basis_set="6-31g", active_orbitals=active_orbitals, transformation="bravyi-kitaev"
)

# get the qubit hamiltonian
H = molecule.make_hamiltonian()

# create an k-UpCCGSD circuit of order k
U = molecule.make_ansatz(name="UpCCGSD")

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

# compute reference energies
fci = molecule.compute_energy("fci")

# optimize
result = tq.minimize(objective=E, method="excitationsolve", initial_values=0.0)

print("VQE : {:+2.8}f".format(result.energy))
print("FCI : {:+2.8}f".format(fci))

@kottmanj
Copy link
Collaborator

errors in test seem to be unrelated to tq, but an internal issue in excitation_solve

@S-Erik
Copy link
Author

S-Erik commented Nov 10, 2025

A few errors are similar to this:

/opt/hostedtoolcache/Python/3.9.24/x64/lib/python3.9/site-packages/excitationsolve/excitation_solve.py:7: in <module>
    parameter_variations: list | np.ndarray,
E   TypeError: unsupported operand type(s) for |: 'type' and 'type'

excitationsolve uses the | operator for type annotations. This operator is unknown to python3.9. python3.9 supports the Union type annotations.

Is it possible to use python3.10 or newer in the git runner or should I make excitationsolve compatible with python3.9?

@kottmanj
Copy link
Collaborator

Ah, thanks for digging that up.
It was on my todo list to update the test runners to 3.11 anyway.
Thanks!

@kottmanj
Copy link
Collaborator

kottmanj commented Nov 14, 2025

Issue is on the openfermion end. Issues with numpy.int64 which is not recognized as int anymore. Will remove affected transformations for now.
(quantumlib/OpenFermion#1171)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants