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.
To install the latest stable release of qlass
from PyPI:
pip install qlass
To install the development version, set the working directory to the top level of the repository and run:
pip install -e .
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.
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.
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)
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
# 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
)
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)
The qlass
package is organized into several modules:
qlass.compiler
: Functions for compiling quantum circuits to photonic processorsqlass.quantum_chemistry
: Tools for generating and manipulating Hamiltoniansqlass.vqe
: VQE ansatz implementations for photonic quantum computingqlass.utils
: Utility functions for executing algorithms and processing results
The main functions of the package are commented using the Google style format and can be found here.
qlass
is developed by the Unitary Foundation, in collaboration with QLASS performers.
You can join the UF Discord server for community support.
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.