tequilahub/tequila

A High-Level Abstraction Framework for Quantum Algorithms

Tequila – a Python framework for variational quantum algorithms

What it is – Tequila is a Python library that lets you write, combine, differentiate and optimise quantum‑computing circuits in a hardware‑agnostic way. It focuses on variational algorithms (VQE, QAOA, etc.) and provides a high‑level abstraction over quantum back‑ends (simulators and real devices) and quantum‑chemistry packages.

Key ideas

  • Abstract data structures – circuits, Hamiltonians, expectation values and optimisation objectives are represented as objects (tq.gates, tq.ExpectationValue, tq.Variable). This lets you build complex workflows without hard‑coding a specific simulator.
  • Automatic differentiation – the library can compute gradients of expectation values automatically, enabling gradient‑based optimisers such as BFGS.
  • Backend‑agnostic execution – if you have any of the supported back‑ends installed (Qulacs, Qibo, Qiskit, Cirq, PyQuil, QLM) Tequila will detect and use them automatically. You can also plug in quantum‑chemistry engines (Psi4, PySCF, Madness) to generate qubit Hamiltonians from molecular structures.
  • Chemistry‑focused utilities – helpers for building molecular Hamiltonians, generating common ansätze (UCC, UpCCGSD, SPA, etc.), and comparing against classical reference methods (CISD, FCI).

Typical workflow (Hello‑World)

import tequila as tq
from math import pi

# 1️⃣ Define a variational parameter
θ = tq.Variable('θ')

# 2️⃣ Build a simple circuit (Ry rotation on qubit 0)
U = tq.gates.Ry(angle=θ*pi, target=0)

# 3️⃣ Choose an observable (Pauli‑X on qubit 0)
H = tq.paulis.X(0)

# 4️⃣ Form the expectation value ⟨ψ(θ)|H|ψ(θ)⟩
E = tq.ExpectationValue(H=H, U=U)

# 5️⃣ Optimise – minimise the squared expectation value
result = tq.minimize(method='bfgs', objective=E**2)

# 6️⃣ Inspect the result
print('optimal wavefunction:', tq.simulate(U, variables=result.angles))
result.history.plot('energies')

The same pattern extends to chemistry: define a Molecule, generate a qubit Hamiltonian, pick an ansatz, and call tq.minimize.

Installation

  • The core package is distributed as tequila-basic on PyPI. Install it with pip install tequila-basic.
  • For best performance on simulators, add a fast backend such as Qulacs (pip install qulacs).
  • Optional chemistry back‑ends (Psi4, PySCF, Madness) are installed separately (conda or pip) and automatically detected.
  • Development versions can be pulled directly from GitHub (pip install git+https://github.com/tequilahub/tequila.git).

Ecosystem & community

  • Tutorials & docs – a dedicated site (tequilahub.github.io/tequila-tutorials) with notebooks covering basic usage, chemistry modules, and advanced topics.
  • Research impact – the README lists dozens of peer‑reviewed papers that use Tequila for VQE, basis‑set‑free methods, quantum‑optics hardware design, robustness analysis, etc. Many of these provide example notebooks in the tequila‑tutorials repo.
  • Extensibility – you can contribute new back‑ends, ansätze, or optimisation strategies via pull‑requests. The project follows standard Python tooling (Ruff for formatting, CI via GitHub Actions).

Who might use it

  • Quantum‑chemistry researchers wanting a Pythonic interface to run VQE on different simulators or real quantum hardware.
  • Algorithm developers prototyping new variational ansätze or gradient‑based optimisation schemes.
  • Educators looking for a teaching‑friendly library that abstracts away low‑level backend details while still exposing the underlying circuit model.

All information above is taken directly from the repository’s README; no additional features have been inferred.

Related

  • Project
  • Project
  • Project
  • Project
  • Project