Skip to main content
The algorithm zoo gives you production-ready implementations of well-known quantum algorithms as first-class b01t modules. Every zoo module follows the same ancilla discipline as hand-written @coherent code, so you get structural safety certificates without having to implement the details yourself. You can use zoo components as drop-in building blocks inside your own @coherent, @parametric, or @adaptive programs, composing them the same way you would any other b01t function.

Available modules

grover

Phase oracle and diffusion operator for Grover’s search algorithm. Use make_phase_oracle to target any basis state, or compose the pre-built phase_oracle and diffusion_operator directly.

qft

Quantum Fourier Transform and its inverse. Used as a subroutine in QPE, Shor’s algorithm, and any algorithm that needs to read out a frequency from a quantum register.

qpe

Quantum Phase Estimation. Takes a controlled-unitary oracle and estimates its eigenvalue to t bits of precision using the inverse QFT on a counting register.

amplitude_amplification

Generalized Grover search. Accepts any @coherent state-preparation function A and predicate oracle O_chi, and amplifies the amplitude of “good” states over repeated iterations.

modular

Modular arithmetic primitives for Shor-class algorithms: controlled modular addition, inplace modular multiplication, and controlled modular exponentiation. All gates are permutation gates (@coherent/@primitive).

rank_select

Coherent legal-action indexing. Maps a superposition of selector indices to the corresponding empty cell in an occupancy register. Used in rollout oracles for sequential decision problems.

qae

Quantum Amplitude Estimation. Provides both iterative (measurement-based) and coherent (QPE-based) amplitude estimation, plus classical MLE post-processing utilities.

max_finding

Quantum maximum finding via the Dürr–Høyer algorithm. Composes coherent amplitude estimation with Grover search to identify the highest-payoff arm in O(√k/ε) oracle calls.

Importing from the zoo

Each module lives under b01t.zoo and exports its public API directly from its package:
from b01t.zoo.grover import make_phase_oracle, phase_oracle, diffusion_operator
from b01t.zoo.qft import qft, inverse_qft
from b01t.zoo.qpe import make_qpe
from b01t.zoo.amplitude_amplification import (
    zero_state_reflection,
    make_amplification_step,
    make_amplitude_amplifier,
)
from b01t.zoo.modular import (
    ctrl_modular_add_wires,
    make_inplace_modular_mul,
    make_controlled_modular_exp,
)
from b01t.zoo.rank_select import rank_select, rank_select_binary
from b01t.zoo.qae import make_qae_round, make_qae_schedule, make_coherent_ae
from b01t.zoo.max_finding import make_comparison_oracle, DurrHoyerRunner

Composing zoo modules

Zoo functions are ordinary b01t DSL functions — you call them inside @coherent, @parametric, or @adaptive bodies the same way you call any gate or kit utility. The following example builds a QPE circuit by combining the QFT module with a custom unitary oracle:
from b01t import QReg, parametric, h
from b01t.zoo.qft import inverse_qft

def my_controlled_unitary(counting: QReg, work: QReg):
    # your controlled-U^(2^k) implementation here
    ...

@parametric
def my_qpe(counting: QReg, work: QReg):
    for i in range(len(counting)):
        h(counting[i])
    my_controlled_unitary(counting, work)
    inverse_qft(counting)
Zoo modules that use continuous rotation gates (QFT, QPE, QAE) are decorated @parametric. Modules that use only permutation and diagonal gates (Grover oracle, diffusion, modular arithmetic) are @coherent. Check each module’s documentation for its decorator so you know which host context it can run in.
You can inspect any zoo function’s IR with from b01t import dump_ir and dump_ir(fn.build(...)) to understand the gate-level structure before compiling to Qiskit.