Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 65 additions & 19 deletions algorithms/README.md
Original file line number Diff line number Diff line change
@@ -1,114 +1,160 @@
# Quantum Algorithms Implementations

This page gathers implementations for both canonical and recent works, that
This directory gathers implementations for both canonical and recent works, that
include concrete quantum algorithms. Researchers are invited to add their work
to the table. We also encourage the community to add implementations to papers listed
in the table or to add new ones.

The directory is organized into multiple subject areas:

**Amplitude Amplification and Estimation** - Includes variants of amplitude amplification and
estimation algorithms, which generalize Grover’s search to boost the probability of measuring
marked states and achieve a quadratic speedup—finding a state of initial probability
$𝑝$
p with near certainty using $O(1/
\sqrt{p})$ iterations.

**Foundational** - Fundamental quantum algorithms, providing the foundations for future advancements
and demonstrating query complexity advantages.

**Hamiltonian Simulation** - Advanced methods to simulate physical systems,
including product-formula decompositions and block-encoding–based techniques such as QSP,
qubitization, and QSVT.

**Number Theory and Cryptography** - Contains quantum algorithms for number-theoretic
problems that achieve dramatic speedups over classical methods and underpin cryptographic
attacks on widely used schemes such as RSA, elliptic-curve cryptography, and Diffie–Hellman.

**Quantum Machine Learning** - Hybrid quantum–classical machine learning algorithms that
integrate parameterized quantum circuits with classical optimization frameworks to perform
tasks such as classification, generative modeling, and data compression,

**Quantum Differential Equation Solvers** - Shows how partial differential equations and dynamical evolution
problems can be mapped to linear systems or block-encoded operators and solved with quantum hardware,
to enable efficient scientific and engineering simulations.

**Quantum Linear Solvers** - Brings together principal quantum algorithms for solving linear systems—including
adiabatic approaches, HHL, QSVT-based matrix inversion, and variational methods.

**Quantum Phase Estimation** - Demonstrates how eigenvalues of Hermitian operators can be extracted via controlled
unitary evolution using techniques such as Trotterized simulation and qubitization-based block-encoding,
with applications to quantum chemistry and advanced linear algebra algorithms.

**Quantum Primitives** - Provides core quantum algorithmic primitives—such as the Hadamard test, Swap test, and
Generalized Quantum Signal Processing (GQSP)—that act as modular building blocks for higher-level algorithms

**Quantum State Preparation** - Presents advanced quantum state preparation techniques—including adaptive variational
methods such as ADAPT-VQE and block-encoding–based Gibbs state generation.

**Quantum Walks** - Demonstrates discrete quantum walk implementations, including explicit comparisons with classical
random walks and specialized constructions for structured graphs.

**Search and Optimization** - Showcases quantum algorithms for unstructured search and combinatorial
optimization—including Grover’s amplitude amplification,
Decoded Quantum Interferometry, and variational frameworks such as QAOA and Grover-based mixers.

A representative selection of algorithms is presented below:

<table>
<tr>
<th>Algorithm</th>
<th>Paper Name</th>
<th>Implementations</th>
<th>Short Description</th>
<th>Tags</th>
</tr>
<tr>
<td>Shor</td>
<td><a href="https://arxiv.org/abs/quant-ph/9508027" target="_blank">Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer</a></td>
<td>
<a href="number_theory_and_cryptography/shor/shor.ipynb">Prime Factorization</a><br>
<a href="number_theory_and_cryptography/discrete_log/discrete_log.ipynb">Discrete Logarithm</a><br>
</td>
<td>Shor's algorithm for prime factorization and discrete logarithms</td>
<td>#algebraic #prime_factorization #discrete_logarithms</td>
</tr>
<tr>
<td>Grover</td>
<td><a href="https://arxiv.org/abs/quant-ph/9605043" target="_blank">A fast quantum mechanical algorithm for database search</a></td>
<td>
<a href="search_and_optimization/grover/grover.ipynb">Grover search for a 3-SAT problem</a>
</td>
<td>Grover's algorithm for fast database search</td>
<td>#grover #database_search</td>
</tr>
<tr>
<td>HHL</td>
<td><a href="https://arxiv.org/abs/0811.3171" target="_blank">Quantum algorithm for solving linear systems of equations</a></td>
<td>
<a href="quantum_linear_solvers/hhl/hhl.ipynb">HHL Implementation</a>
</td>
<td>HHL algorithm for solving linear systems</td>
<td>#hhl #linear_systems</td>
</tr>
<tr>
<td>QAOA</td>
<td><a href="https://arxiv.org/abs/1411.4028" target="_blank">A Quantum Approximate Optimization Algorithm</a></td>
<td>
<a href="search_and_optimization/qaoa/qaoa.ipynb">Max Cut Problem</a>
</td>
<td>QAOA for combinatorial optimization problems</td>
<td>#qaoa #optimization</td>
</tr>
<tr>
<td>VQE</td>
<td><a href="https://arxiv.org/abs/1304.3061" target="_blank">A variational eigenvalue solver on a quantum processor</a></td>
<td>
<a href="../applications/chemistry/molecular_energy_curve/molecular_energy_curve.ipynb">VQE Implementation for molecule ground state solving</a>
</td>
<td>Variational Quantum Eigensolver (VQE) for finding eigenvalues</td>
<td>#vqe</td>
</tr>
<tr>
<td>Quantum Walk (Glued Trees)</td>
<td><a href="https://arxiv.org/abs/2303.13012" target="_blank">Exponential quantum speedup in simulating coupled classical oscillators</a></td>
<td>
<a href="quantum_walks/glued_trees/glued_trees.ipynb">Glued Trees Implementation</a>
</td>
<td>Exponential speedup in solving system of coupled harmonic oscillators</td>
<td>#quantum_speedup</td>
</tr>
<tr>
<td>Deutsch–Jozsa</td>
<td><a href="https://royalsocietypublishing.org/doi/epdf/10.1098/rspa.1992.0167" target="_blank">Rapid solution of problems by quantum computation</a></td>
<td>
<a href="foundational/deutsch_jozsa/deutsch_jozsa.ipynb">Deutsch-Jozsa Implementation</a>
</td>
<td>Deutsch-Jozsa algorithm for rapid problem solving</td>
<td>#deutsch_jozsa #problem_solving</td>
</tr>
<tr>
<td>QSVT</td>
<td><a href="https://arxiv.org/abs/1806.01838" target="_blank">Quantum singular value transformation and beyond: exponential improvements for quantum matrix arithmetics</a></td>
<td>
<a href="quantum_linear_solvers/qsvt_matrix_inversion/qsvt_matrix_inversion.ipynb">QSVT matrix inversion</a><br>
<a href="amplitude_amplification_and_estimation/qsvt_fixed_point_amplitude_amplification/qsvt_fixed_point_amplitude_amplification.ipynb">QSVT fixed point amplitude amplification</a><br>
</td>
<td>Introduction of the QSVT Algorithmic framework and its applications</td>
<td>#qsvt #quantum_algorithms</td>
</tr>
<tr>
<td>Simon</td>
<td><a href="https://epubs.siam.org/doi/10.1137/S0097539796298637" target="_blank">On the Power of Quantum Computation</a></td>
<td>
<a href="foundational/simon/simon.ipynb">Simon's Algorithm Implementation</a>
</td>
<td>Simon's algorithm demonstrating quantum computational power</td>
<td>#simon #quantum_computation</td>
</tr>
<tr>
<td><a href="https://arxiv.org/abs/2408.08292" target="_blank">Optimization by Decoded Quantum Interferometry
</a></td>
<td>DQI</td>
<td><a href="https://arxiv.org/abs/2408.08292" target="_blank">Optimization by Decoded Quantum Interferometry</a></td>
<td>
<a href="search_and_optimization/dqi/dqi_max_xorsat.ipynb">DQI Algorithm Implementation</a>
</td>
<td>Decoded Quantum Interferometry Algorithm for discrete optimization problems</td>
<td>#dqi #quantum_algorithms</td>
</tr>
<tr>
<td>Quantum Amplitude Loading</td>
<td>
<a href="https://arxiv.org/abs/2402.05574" target="_blank">Quantum Amplitude Loading for Rainbow Options Pricing</a>
</td>
<td style="min-width: 200px;">
<td>
<a href="../applications/finance/rainbow_options/rainbow_options_direct_method.ipynb">Direct Method</a><br>
<a href="../applications/finance/rainbow_options/rainbow_options_integration_method.ipynb">Integration Method</a>
</td>
<td>
Implementation of the quantum monte-carlo integration method for the use case of rainbow option pricing
</td>
<td>
#option_pricing<br>
#amplitude_estimation
</td>
</tr>
</table>
25 changes: 25 additions & 0 deletions algorithms/amplitude_amplification_and_estimation/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Amplitude Amplification and Estimation

Algorithmic variations of the amplitude amplification and estimation algorithm.
Amplitude amplification is a technique to increase the probability of measuring marked ("good") states. The scaling is typically achieved employing the Grover operator as a canonical building block.
Generally, the methods produce a quadratic speedup, relative to classical repetition, so a marked state which
has probability $p$ to be measured, can be found with a probability close to unity by employing $O(1/\sqrt{p})$
measurements. In contrast, the goal of amplitude estimation is to estimate the probability value, $p$. It achieves an additive error $\epsilon$ in $O(1/\epsilon)$ iterations, obtaining a quadratic speed up relative to the classical Monte Carlo.

The directory contains the following methods:

- **Oblivious Amplitude Amplification** - Amplifies a coherent transformation by increasing the probability that a desired
operation is successfully applied, where success is indicated by the state of an auxiliary qubit. The algorithm is
oblivious to the input state, meaning it works uniformly for any input, does not rely on efficient state preparation,
and avoids measurements. As a result, it can be implemented as part of a larger unitary quantum circuit without
interrupting coherence.
- **Quantum Monte Carlo Integration** - Employs Quantum Amplitude Estimation (QAE) to evaluate a definite integral. Obtains a
quadratic improvement of the analogous classical method, exhibiting an error which scales as $O(1/M)$, where $M$ is the
number of controlled applications of the Grover operator within the QAE.
- **Quantum Singular Value Transformation (QSVT) fixed point amplitude amplification** - Solves unstructured
search problems without requiring prior knowledge of the fraction of marked solutions.
By leveraging QSVT together with an efficiently block-encoded operator, it implements amplitude amplification
in a fixed-point manner, guaranteeing monotonic convergence toward the marked subspace and eliminating
the risk of overshooting the target state.
- **Quantum Counting** - Efficiently estimates the number of valid solutions to a search problem. The algorithm
employs QAE to obtain a quadratic query complexity speed up relative to classical algorithms.
20 changes: 20 additions & 0 deletions algorithms/foundational/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Foundational

Fundamental quantum algorithms, providing the foundations for future advancements
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the amplitude estimation and amplification you started with: "This directory contains..."
I would be consistent with the style.
I prefer this one (in Foundational), but feel free to choose whatever you like.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

and demonstrating query complexity advantages.

- **Bernstein Vazirani**-
Demonstrating a linear query complexity advantage over deterministic and
probabilistic classical method.
The algorithm finds the hidden-bit string $a$ by a single query call to an oracle function
$f(x) = (a\cdot x) \mod 2$, where $x$ is also a bit string and $\cdot$ denotes the bitwise multiplication.
This problem constitutes a specific case of the general hidden-shift problem.
- **Deutsch Jozsa** - Widely regarded as the first quantum algorithm, it demonstrates an exponential advantage in query
complexity over classical deterministic approaches. Given oracle access to a Boolean function promised to be either
constant or balanced, the algorithm deterministically identifies which case holds using a single query to
the function.
- **Quantum Teleportation** - A foundational quantum communication protocol, employing quantum entanglement and
classical communication to transfer ("teleport") an arbitrary qubit state from one place to another.
- **Simon** - Given an oracle binary function, satisfying $f(x)=f(y)$ if and only if $y=x\oplus s$ for some secret key $s$, the
algorithm recovers $s$. It does so using a number of oracle queries linear in the input size, yielding an exponential
improvement in query complexity compared to the best classical approaches.
13 changes: 13 additions & 0 deletions algorithms/hamiltonian_simulation/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Hamiltonian Simulation

Hamiltonian simulation methods are used to model and analyze physical systems in a controlled way. The present folder showcases a range of advanced Hamiltonian simulation methods,
including product-formula decompositions and block-encoding–based techniques such as QSP,
qubitization, and QSVT. The examples illustrate how quantum time evolution can be implemented
efficiently within modern algorithmic frameworks.

- **Hamiltonian simulation guide** - Provides an introduction and overview to standard Hamiltonian simulation methods.
The methods are described and implemented utilizing Classiq's built-in functions. First, the product formula
based methods, Suzuki-Trotter decomposition and qDrift are introduced and implemented.
- **Hamiltonian simulation with block encoding** - The notebook demonstrates how to implement Hamiltonian simulation with
three block-encoding methods: Generalized Quantum Signal Processing (QSP), Qubitization, and Quantum Singular Value Transformation (QSVT).
Each method is explained and defined independently and finally compared.
25 changes: 25 additions & 0 deletions algorithms/number_theory_and_cryptography/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Number Theory and Cryptography

Quantum algorithms for number-theoretic problems offer the most striking
speedups over their best known classical counterparts. Because many widely deployed
cryptographic schemes rely on one-way functions whose security is grounded in the computational
hardness of number-theoretic tasks, these polynomial-time quantum algorithms pose a
well-established threat to modern secure communication and key exchange protocols,
including RSA, elliptic-curve cryptography, and the Diffie–Hellman key exchange.

- **Discrete log** - Solves the Discrete logarithm problem, i.e., given an element, $x$, of a cyclic group
with generator $g$, finds the least positive integer $s$, such that $g^s = x$. The algorithm provides an exponential
speedup relative to the best known classical algorithm. The hardness of the problem, provides the basis for the
Diffie-Hellman key exchange protocol. Similarly to order-finding and elliptic curve, the problem
constitutes an instance of the Abelian Hidden Subgroup Problem (HSP).
- **Elliptic curves** - A quantum algorithm solving the elliptic curve discrete logarithm problem in polynomial running time. The
hardness of the problem constitutes the basis of elliptic curve cryptography, which is widely used for key-exchange, cryptocurrency
and high-security communications.
- **Hidden shift problem** - Implementation of an algorithm to find the hidden-shift for the family of Boolean bent functions, which
are characterized by high non-linearity and a perfectly flat Fourier transform. Given access to queries of a functions $f$,
the algorithm finds the shift, a boolean string, which satisfies $f(x) = f(x \oplus s)$. The quantum algorithm provides
an exponential separation in query complexity relative to any (including the optimal) classical algorithm.
- **Shor's algorithm** - Evaluates the prime factors of a large integer. The algorithm played a foundational role in
the development of the field, providing an exponential speedup over currently known classical algorithms. The quantum component
is naturally structured as a Quantum Phase Estimation (QPE) routine, utilizing
Classiq’s built-in `flexible_qpe` and modular arithmetic.
26 changes: 26 additions & 0 deletions algorithms/qml/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# QML
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.


Quantum Machine Learning (QML) algorithms are a family of hybrid quantum–classical frameworks. A number of key QML algorithms are implemented, demonstrating how
parameterized quantum circuits can be integrated with classical optimization and
deep-learning tools to perform classification, generative modeling, and data compression tasks.
Each implementation highlights both the algorithmic principles and the practical workflow,
including state preparation, circuit design, training procedures, and performance evaluation.

- **Hybrid Quantum Neural Networks (QNN)** A hybrid quantum-classical algorithm, incorporating quantum layers into the structure of
a classical neural network. A state preparation maps classical states in the quantum Hilbert state, following quantum layers are
implemented by parameterized quantum circuits, providing different expressibility relative to the classical networks.
Considering a specific example function we construct, train, and verify the hybrid classical-quantum neural network, building
upon the deep-learning PyTorch module.
- **Quantum Generative Adversarial Networks (GANs)** - A quantum analogue of a classical learning algorithm that generates new
data which mimics the training set data. The original model is trained by an adversarial optimization in a two-player minmax game,
utilizing a gradient-based learning. In the quantum algorithm, the classical neural networks are replaced by quantum neural networks,
which are parameterized quantum circuits.
- **Quantum Support Vector Machine (QSVM)** - Quantum version of the classical machine learning algorithm, classifying
data points between into two distinct categories. Employing the dual problem formulation, the classification is dictated by a
defined feature map and the
kernel matrix. In the quantum algorithm, the feature map is implemented by a quantum circuit and the elements of the
kernel matrix are evaluated by quantum measurements. The performance of various quantum feature maps are analyzed,
for both a simplex and complex data sets.
- **Quantum autoencoder** - A quantum program is trained to reduce the memory required to encode data
with a given structure. The example demonstrates how to use the encoder for anomaly detection.
Two training approaches for the quantum autoencoder are presented, leveraging Classiq’s integration with PyTorch.
Loading