Skip to main content

VQE on linear optical circuits

Project description

Repository build European Union Unitary Foundation Documentation Status codecov PyPI version Downloads License Discord Chat Zenodo DOI DOI

qlass

qlass is a package to compile quantum algorithms on photonic devices. Part of the Quantum Glass-based Photonic Integrated Circuits (QLASS) project funded by the European Union.

Installing qlass

Stable release (PyPI)

To install the latest stable release of qlass from PyPI:

pip install qlass

Development install

To install the development version, set the working directory to the top level of the repository and run:

uv sync --all-groups

If you don't have uv installed, you can checkout the installation instructions here. Or, you can install it via pip:

pip install uv

qlass builds upon open-source scientific software packages in Python: scipy for numerical optimization, pyscf and openfermion for quantum chemistry, qiskit for quantum computing, and perceval for quantum photonics compilation. Optionally, one can also use the piquasso package for quantum optics simulations, which can offer improved performance compared to perceval in certain regimes.

Getting started

You can use this demo notebook on the variational quantum eigensolver (VQE) to get started with the qlass package, or check out the example script.

Features

Circuit Compilation

qlass provides a convenient function to compile Qiskit quantum circuits to Perceval processors:

from qiskit import QuantumCircuit
from qlass import compile

# Create a Qiskit circuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)

# Compile to Perceval processor
processor = compile(qc)

Variational Quantum Eigensolver (VQE)

qlass includes tools for implementing the Variational Quantum Eigensolver on photonic quantum computers:

from qlass.vqe import VQE, le_ansatz
from qlass.utils import loss_function
from qlass.quantum_chemistry import LiH_hamiltonian

from perceval.algorithm import Sampler

# Generate a Hamiltonian for the LiH molecule
hamiltonian = LiH_hamiltonian(num_electrons=2, num_orbitals=1)

# Define an executor function that uses the linear entangled ansatz
def executor(params, pauli_string):
    processor = le_ansatz(params, pauli_string)
    sampler = Sampler(processor)
    samples = sampler.samples(10_000)
    return samples

# Initialize the VQE solver
vqe = VQE(
    hamiltonian=hamiltonian,
    executor=executor,
    num_params=4, # Number of parameters in the linear entangled ansatz
)

# Run the VQE optimization
vqe_energy = vqe.run(
    max_iterations=10,
    verbose=True
)

Quantum Chemistry

The package provides tools for working with quantum chemistry Hamiltonians:

from qlass.quantum_chemistry import LiH_hamiltonian, brute_force_minimize

# Generate a Hamiltonian for the LiH molecule
hamiltonian = LiH_hamiltonian(num_electrons=2, num_orbitals=1)

# Calculate the exact ground state energy for comparison
exact_energy = brute_force_minimize(hamiltonian)

Module Structure

The qlass package is organized into several modules:

  • qlass.compiler: Functions for compiling quantum circuits to photonic processors
  • qlass.quantum_chemistry: Tools for generating and manipulating Hamiltonians
  • qlass.vqe: VQE ansatz implementations for photonic quantum computing
  • qlass.utils: Utility functions for executing algorithms and processing results

Documentation

The main functions of the package are commented using the Google style format and can be found here.

Contributing

qlass is developed by the Unitary Foundation, in collaboration with QLASS performers.

You can join the UF Discord server for community support.

For a guide to opening a PR, checkout the contributing guide.

Funding

Funded by the European Union. Views and opinions expressed are however those of the authors only and do not necessarily reflect those of the European Union. Neither the European Union nor the granting authority can be held responsible for them.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qlass-0.2.4.tar.gz (43.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qlass-0.2.4-py3-none-any.whl (50.3 kB view details)

Uploaded Python 3

File details

Details for the file qlass-0.2.4.tar.gz.

File metadata

  • Download URL: qlass-0.2.4.tar.gz
  • Upload date:
  • Size: 43.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qlass-0.2.4.tar.gz
Algorithm Hash digest
SHA256 596c3188a125add67f11bfdc4bb5201a1bb49d23fb78a07b85a104dc26fe2ead
MD5 761e052356d9a4770d6d7ce8c6baab88
BLAKE2b-256 79bcd4b610f8d07ba4c2dc0a877d6cf61e601fb14e7c793175265b21b4fc2242

See more details on using hashes here.

Provenance

The following attestation bundles were made for qlass-0.2.4.tar.gz:

Publisher: cd.yml on unitaryfoundation/qlass

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qlass-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: qlass-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 50.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qlass-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e61c83335f43cb859487d9d92a9fd77a53e0d4fc447f4b2af08a3919e5b47923
MD5 1e0d147e1de4cb7a72e364be503fb0d0
BLAKE2b-256 2f9e05111ceaeed0a4469a099c7549f380ba8c244960fd595fd48c78ad7d09d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for qlass-0.2.4-py3-none-any.whl:

Publisher: cd.yml on unitaryfoundation/qlass

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page