lambeq use cases
lambeq
covers a wide range of experiment use cases (Fig. 4) in three broad categories:
quantum simulations on classical hardware;
actual runs on quantum hardware;
evaluation of tensor networks on classical hardware.

Fig. 4 Hierarchy of experimental use cases in lambeq.
The above figure introduces a couple of concepts that might need further explanation for users new to quantum computing:
shot-based run/simulation: Unlike classical computers, quantum computers are inherently non-deterministic. This means that running a quantum circuit only once and using the output for some task would produce unreliable results. The solution is to run the same circuit many times (or shots), exploiting statistical aggregation. The inherent uncertainty of quantum computers is greatly increased by the limitations of current NISQ devices, which are prone to noise, errors, and environmental interference.
noisy simulation: A noisy simulation uses a noise model that tries to approximate the negative effect of noise, errors, and environmental interference that are inherent in current NISQ devices. It is the closest you can get to an actual quantum run from a simulation running on classical hardware.
Table 1 provides a concise reference for the most common scenarios, together with the recommended lambeq
models and trainers to use for each of them, while the following subsections present each case in more detail.
Use case |
Configurations |
|
---|---|---|
Exact non-shot based simulation of quantum circuits on classical hardware |
NumpyModel with QuantumTrainer |
|
Noiseless shot-based simulation of quantum circuits on classical hardware |
TketModel with QuantumTrainer |
|
Noisy shot-based simulation of quantum circuits on classical hardware |
TketModel with QuantumTrainer |
|
Evaluation of quantum circuits on a quantum computer |
TketModel with QuantumTrainer |
|
Evaluation of classical, tensor-based models |
Exact (non shot-based) simulation of quantum circuits on classical hardware
- Description
Perform a simple, noiseless, non-shot-based simulation of a quantum run on classical hardware.
- Configuration
NumpyModel
withQuantumTrainer
.
- When to use
As a first proof-of-concept for a quantum model configuration
As a simple baseline for comparing with quantum runs
When fast training speeds are required
Computation with NISQ devices is slow, noisy and limited, so it is still not practical to do extensive training and comparative analyses on them. For this reason, and especially at the early stages of modelling, proofs-of-concept are usually obtained by running simulations on classical hardware. The simplest possible way to simulate a quantum computation on a classical computer is by using linear algebra; since quantum gates correspond to complex-valued tensors, each circuit can be represented as a tensor network where computation takes the form of tensor contraction. The output of the tensor network gives the ideal probability distribution of the measurement outcomes on a noise-free quantum computer and is only a rough approximation of the sampled probability distribution obtained from a NISQ device. An “exact simulation” of this form usually serves as a simple baseline or the first proof of concept for testing a quantum configuration, and in lambeq
is implemented by the NumpyModel
class.
See also:
Shot-based simulation of quantum circuits on classical hardware
- Description
Noisy or noiseless shot-based simulations on classical hardware using tket backend.
- Configuration
TketModel
withQuantumTrainer
.
- When to use
As a faithful approximation of an actual quantum run
When the available actual quantum machines are still small for the kind of experiment you have in mind
When a faithful approximation of a quantum run is needed, one should use a proper shot-based simulation, optionally including a noise model that is appropriate for the specific kind of quantum hardware. In fact, a noisy shot-based simulation is as close as we could get to an actual quantum run. For example, in order to run an architecture-aware simulation on an IBM machine, we could use a TketModel
initialised with a Qiskit noise model:
from pytket.extensions.qiskit import IBMQEmulatorBackend
from lambeq import TketModel
all_circuits = train_circuits + dev_circuits + test_circuits
device_name = 'ibmq_washington' # need credentials to access this device
backend = IBMQEmulatorBackend(device_name)
backend_config = {
'backend': backend,
'compilation': backend.default_compilation_pass(2),
'shots': 8192
}
model = TketModel.from_diagrams(all_circuits, backend_config=backend_config)
See also:
Evaluation of quantum circuits on a quantum computer
- Description
Perform actual quantum runs using tket backend.
- Configuration
TketModel
withQuantumTrainer
.
- When to use
The real thing, use it whenever possible!
As soon as you are satisfied with the results of the simulations, it’s time for the ultimate test of your model on a real quantum machine. For this, you will need an account on a platform that provides quantum services, such as IBM Quantum.
Note
While providers usually offer free plans which allow some limited access to their resources, depending on your experimental needs a paid subscription might be required. Table 2 summarises some popular quantum platforms that are currently available to the public.
Platform |
Technology |
---|---|
Annealing, trapped ions, superconducting qubits, photonics |
|
Superconducting qubits |
|
Superconducting qubits |
|
Trapped ions |
|
Superconducting qubits |
|
Trapped ions, superconducting qubits, neutral atoms |
|
Trapped ions |
|
Superconducting qubits |
See also:
Evaluation of classical tensor-based models
- Description
Perform tensor-based experiments on classical hardware using PyTorch.
- Configuration
PytorchModel
withPytorchTrainer
.- When to use
As a proof-of-concept for validating sentence modelling at a high level
As a classical baseline to compare with similarly structured quantum models
For enhancing models with neural parts and other ML features
While lambeq
is primarily aimed at the design and execution of NLP models on quantum hardware, in practice it is more than a QNLP toolkit: it is a modelling tool capable of representing language at many different levels of abstraction, including syntax trees, string/monoidal diagrams, strict pregroup diagrams, and quantum circuits. For example, the abstract representation given by a string diagram can be directly translated into a tensor network and executed on classical hardware. This can be useful for providing comparison and benchmarking between quantum models and similar classical implementations.
Furthermore, using the PyTorch backend via PytorchModel
provides access to a wide range of robust deep learning features, allowing you to combine your tensor-based models with neural parts (e.g. embeddings or classifiers) in an effortless way.
See also: