Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
oracq documentation
oracq documentation

Manuals

  • Complete documentation
    • Installation and environment
    • Operations, registers, and the generation process
    • Source code structure
    • Oracles and operator representations
    • QRAM data structures: pointers, offsets, and random writes
    • Quantum data structures and the KP recommendation system
    • Conventions owned by algorithms: starting from one gate
    • Implementing QPDE/QODE: multiple input paradigms, replaceable oracles, and protocols
    • Automatically generating reversible quantum modules from ordinary math functions
    • QFVM input models and solver replacement
    • General QHAM automatic generation: PDE → HAM → QCL → QODE
    • QCNN line-by-line implementation walkthrough
    • Export and execution backends
    • Resource estimation (Toffoli+Clifford+T+QRAM)
    • Command line
    • Import path migration
    • Applicability boundaries and validation status
  • Algorithm catalog
    • Data Loading and Input Models
      • State Preparation
      • Alias Sampling Preparation
      • XOR Database
      • Adjacency Oracle
      • Select-Swap QROM
      • QROM Lookup
      • Block Encoding Algebra
      • Sparse Access
      • Sparse Matrix Block Encoding
      • PREPARE–SELECT Decomposition
      • Purification Access
      • Gibbs State Preparation
      • Double Factorization
      • Tensor Hypercontraction
    • Basic Query Algorithms
      • Deutsch–Jozsa
      • Bernstein–Vazirani
      • Simon Sampling
    • Query and Search
      • Grover Search
      • Amplitude Amplification
      • Oblivious Amplitude Amplification
      • Fixed-Point Search
      • Amplitude Estimation
      • Quantum Counting
    • Fourier and Arithmetic
      • Quantum Fourier Transform
      • Fourier Addition
      • Order Finding
      • Modular Multiplication
      • Fixed-Point Arithmetic
      • Boolean Networks
    • Estimation and Testing
      • Quantum Phase Estimation
      • Hadamard Test
      • Swap Test
      • Heinrich Quantum Summation
      • Heinrich Quantum Integration
    • Hamiltonian Evolution and QSVT
      • Trotter Product-Formula Simulation
      • Hamiltonian Simulation Protocol
      • QSP Phase Synthesis
      • QSVT Phase Sequence
      • QSVT Matrix Inversion
      • QSVT Hamiltonian Simulation
      • Qubitization Walk
      • Truncated Taylor Block Encoding
      • Eigenstate Filtering
    • Quantum Linear Systems
      • Costa Walk QLSS
      • CKS Chebyshev QLSS
      • VTAA-CKS QLSS
    • Differential Equations
      • QODE Problem and Protocol
      • Linear Combination of Hamiltonian Simulations
      • Schrödingerization
      • CBMD
      • Fokker–Planck Input Model
      • Carleman Linearization
    • Variational and Optimization
      • Hardware-Efficient Ansatz
      • VQE Pauli Measurements
      • QAOA for MaxCut
      • Decoded Quantum Interferometry
      • Jordan Quantum Gradient Estimation
    • Quantum Walks
      • Coined Cycle Walk
      • Szegedy Walk
      • MNRS Quantum Walk Search
    • Quantum Machine Learning
      • Quantum Principal Component Analysis
      • QCNN
      • Density Matrix Exponentiation
    • Quantum Error Correction
      • Repetition Codes
    • Applications and Infrastructure
      • Quantum Finite Volume Method, QFVM
      • General QHAM
      • Math Function Compilation
  • Specification reference
    • Language and algorithm library conventions
    • RIR: the modular register-level intermediate representation
    • QRAM memory definition (qram YAML)
    • Open declarations, capabilities, and binding
    • MIR 0.1: the pure mathematical function graph
    • General QHAM: derivation from PDEs to quantum-adapted linear systems
    • Replacing the QLSS inside QFVM: a review of input models, QRAM data structures, and output contracts
    • OriginIR-ext and PySparQ review
  • API Reference
    • oracq package overview
    • Infrastructure API
      • Toffoli / U3 / CZ lowering
      • OriginIR-ext backend
      • PySparQ backend
      • Quantikz circuit export
      • Strict netlist export
      • Module builder
      • Resource estimation
      • Register reference executor
      • RIR objects
      • Register layout
      • Binding and capability analysis
      • Math-function compilation entry
      • Python math-function frontend
      • MIR objects
      • Math-function lowering
      • Math kernel generation
      • Native implementation registry
      • QRAM pointer-style read/write
      • QRAM YAML memory format
      • Host readout
      • RIR serialization
      • Structural validation
    • Algorithms API
      • Modular multiplication and order finding
      • Oracle query algorithms
      • Reversible arithmetic
      • Phase, amplitude, and overlap estimation
      • Fourier transforms and arithmetic
      • Hamiltonian evolution
      • Quantum summation and integration
      • PREPARE-SELECT decomposition
      • qsp_pyqsp
      • QSVT standard transforms
      • Search and amplitude amplification
      • solve
      • Operator-level synthesis optimization of spectral circuits
      • State-preparation composition
      • Matrix transform sequences
      • Quantum walks
      • Block-encoding composition
      • Algorithm contracts and reports
      • Select-Swap QROM data loading
      • Density-matrix input models and Gibbs states
      • Graph-walk search
      • initial
      • Algorithm structure protocols
      • Chemistry low-rank decomposition block encodings
      • QODE assembly interface
      • Operator wrappers and basic composition
      • Oracle declarations and implementations
      • PDE models and adapters
      • Quantum data structures (qsample and sample-and-query)
      • QHAM
      • Sparse-access adapters
      • Spectral input/output primitives and operator-level optimization
      • DQI decoding quantum interference optimization
      • Quantum gradient estimation
      • Variational algorithm circuits
      • Repetition codes and error recovery
      • Quantum linear systems
      • VTAA-CKS variable-time linear-system solver
      • Quantum convolutional neural networks
      • Quantum building blocks of QCNNs
      • QPCA quantum principal component analysis
      • Quantum semidefinite programming framework
      • KP quantum recommendation system
      • Carleman linearization
      • Quantum Newton method
      • CBMD
      • LCHS
      • Legacy compatibility entry points
      • QODE assembly interface
      • Linear ODE input models
      • Schrödingerization
      • SDE/Fokker–Planck input models
      • solver
      • PDE models and adapters
      • solver
    • Domain Applications API
      • Reference workload catalog
      • Flow fields and QRAM data
      • Algorithm gallery
      • Legacy compatibility entry points
      • oracle_study
      • QFVM application
      • QFVM direct QMem data path
      • QHAM PDE examples
      • QHAM finite closure
      • PDE models and adapters
      • Spatial discretization and classical reference
      • QHAM derivation report
      • Structured finite-difference ports
      • Roe matrix-element generation
      • Roe classical math formulas

Tutorials

  • Tutorials
    • Your first register program
    • Replacing an algorithm’s oracle
    • From a paper’s access model to implementation comparison
    • Search for an element and estimate the success probability
    • Supplying your own Hamiltonian decomposition
    • Swapping QODE methods for the same linear problem
    • Generating QHAM input from a PDE expression
    • Composing PDE inputs and solve instances
    • Composing linear ODE inputs and solve instances
    • Scientific computing workflows: input models, solvers, and reproduction
    • Running and modifying the algorithm gallery

Development

  • Development
    • Development and acceptance
    • Architecture paradigm and interface conventions
    • Framework survey notes (stage 1)
    • Writing documentation
    • Translation Glossary (Chinese → English)
    • Repository reorganization and the algorithm expansion panel
    • Algorithm research workflow improvements
    • Acceptance record for this version
    • Quantum algorithm implementation validation plan (review draft)
    • Validation coverage matrix
    • Quantum algorithm coverage workboard
Back to top
View this page

Graph-walk search¶

oracq.algorithms.input_model.graph_walks

Graph oracle input model and the Szegedy/MNRS quantum walk search framework.

The graph is supplied as a neighbor-table oracle: |v>|j>|c> -> |v>|j>|c XOR N(v,j)>, with the out-edge table uniformly padded to D=2**degree_bits columns (usually padded with self-loops). The Szegedy walk step is defined on the (current, peer, index) bipartite walk space and consists of two reflections built from neighbor superposition preparations, W = R_B R_A; the MNRS search skeleton is setup initial state preparation followed by Repeat{ walk; marked phase flip }.

References: Szegedy 2004 (the spectrum of the walk operator); Magniez–Nayak–Roland–Santha 2011 (Search via quantum walk, hitting time and step scaling).

class oracq.algorithms.input_model.graph_walks.AdjacencyOracle(operation)[source]¶

Bases: OracleView

Neighbor-table query: |v>|j>|c> -> |v>|j>|c XOR N(v,j)>.

The out-edge table is arranged by vertex number, with exactly D=2**degree_bits entries per row; the caller pads the shortfall with self-loops or the like, to keep the neighbor superposition normalized as 1/sqrt(D). The paradigm reuses database_xor, with address interpreted as the low-bit concatenation of vertex and index.

oracle_kind = 'database_xor'¶
operation¶
adjacency_oracle()[source]¶

Return the AdjacencyOracle view of itself, as the adapter entry point of the adjacency oracle protocol.

Returns:

This view itself.

Return type:

AdjacencyOracle

property vertex_bits¶

Bit width of the vertex register vertex.

property degree_bits¶

Bit width of the out-edge index register index.

property vertices¶

Total number of addressable vertices, i.e. 2**vertex_bits.

property degree¶

Number D of out-edge table columns per vertex after padding, i.e. 2**degree_bits.

xor_database()[source]¶

Treat the neighbor table as an XOR database with address=``vertex||index`` and data=neighbor.

Returns:

XOR database view wrapping the same neighbor-table operation.

Return type:

XorDatabase

oracq.algorithms.input_model.graph_walks.as_adjacency(value)[source]¶

Adapt a graph adjacency input into an AdjacencyOracle view.

Parameters:
  • value – Returned as-is when already an AdjacencyOracle; otherwise it

  • `` (must be a complete Operation with the)

  • signature.

Returns:

Adjacency oracle view wrapping the given operation.

Return type:

AdjacencyOracle

Raises:

ValidationError – value is neither an AdjacencyOracle nor an Operation.

oracq.algorithms.input_model.graph_walks.abstract_adjacency(vertex_bits, degree_bits, *, name=None)[source]¶

Open declaration of graph adjacency; the body is empty and can be bound to a gate/QRAM implementation via bind.

Parameters:
  • vertex_bits – Bit width of the vertex register, range 1..32.

  • degree_bits – Bit width of the out-edge index register, range 0..32.

  • name – Name of the declaration slot; GraphAdjacency_{vertex_bits}_{degree_bits} by default.

Returns:

Adjacency declaration with an empty body awaiting a bound implementation.

Return type:

AdjacencyOracle

oracq.algorithms.input_model.graph_walks.gate_adjacency(neighbors, *, name=None)[source]¶

Gate-level implementation for a small neighbor table: a controlled X network per (v, j) branch.

Parameters:
  • neighbors – Nonempty rectangular neighbor table with rows for vertices

  • numbers. (0..V-1 and D entries per row; entries are legal vertex)

  • name – Name of the generated operation; derived from the table content by default.

Returns:

Adjacency oracle implemented as a controlled X network.

Return type:

AdjacencyOracle

oracq.algorithms.input_model.graph_walks.qram_adjacency(vertex_bits, degree_bits, *, name=None)[source]¶

QRAM implementation of the neighbor table; the address is vertex | (index << vertex_bits) and the word is the neighbor number.

Parameters:
  • vertex_bits – Bit width of the vertex register, range 1..32.

  • degree_bits – Bit width of the out-edge index register, range 0..32.

  • name – Name of the generated operation; qram_adjacency_{vertex_bits}_{degree_bits} by default.

Returns:

Adjacency oracle backed by the table bank.

Return type:

AdjacencyOracle

oracq.algorithms.input_model.graph_walks.szegedy_walk(adjacency, *, name=None)[source]¶

Szegedy walk step W = R_B R_A, acting on the (current, peer, index) walk space.

R_A is the reflection about the subspace of neighbor superpositions on the current end, and R_B swaps the roles of the two ends (equivalent to SWAP conjugation). The graph need not be regular; when irregular, the padding scheme determines the effective transition.

Parameters:
  • adjacency – Adjacency oracle, or an operation with the (vertex, index, neighbor) signature.

  • name – Name of the generated operation; derived from the adjacency operation by default.

Returns:

The unitary operation of one walk step.

Return type:

Operation

oracq.algorithms.input_model.graph_walks.szegedy_setup(adjacency, *, name=None)[source]¶

Prepare the MNRS initial state 1/sqrt(N) sum_v A|v>: a uniform superposition on current followed by neighbor state preparation.

The target layout matches the register declaration order of szegedy_walk: the low vertex_bits bits are current, the next vertex_bits bits are peer, and the high degree_bits bits are index.

Parameters:
  • adjacency – Adjacency oracle, or an operation with the (vertex, index, neighbor) signature.

  • name – Name of the generated operation; derived from the adjacency operation by default.

Returns:

Preparation view preparing the MNRS initial state.

Return type:

StatePreparation

oracq.algorithms.input_model.graph_walks.quantum_walk_search(setup, walk, marked, steps, *, name=None)[source]¶

MNRS marked-vertex search skeleton: setup followed by Repeat{ walk; marked phase flip }.

Parameters:
  • setup – Initial state preparation (StatePreparation protocol), with target being the whole walk space.

  • walk – Walk step handle; its registers map in declaration order to consecutive slices of setup.target.

  • marked – Phase oracle (target with optional work) acting on the first target.width bits of the walk space, which is the current register for szegedy_walk.

  • steps – Nonnegative iteration count; choose with reference to suggest_steps.

All three handles may be open declarations; the generated program becomes executable after bind closes the implementations in batches.

Returns:

The search program of repeated walking and phase flipping.

Return type:

Operation

oracq.algorithms.input_model.graph_walks.transition_matrix(neighbors)[source]¶

Build the classical random-walk transition matrix from the neighbor table, P[v][u] = |{j: N(v,j)=u}| / D.

Parameters:

neighbors – Nonempty rectangular neighbor table whose entries are legal vertex numbers.

Returns:

Row-major transition probability matrix, with each row summing to 1.

Return type:

tuple[tuple[float, …], …]

oracq.algorithms.input_model.graph_walks.hitting_times(transition, marked)[source]¶

Expected number of steps for each vertex to first reach the marked set (zero for marked vertices).

Solves the linear system (I - P_free) h = 1, where P_free is the sub-transition matrix with the marked rows and columns removed.

Parameters:
  • transition – Nonnegative square transition matrix with each row summing to 1.

  • marked – Set of marked vertex numbers, which must be nonempty and in range.

Returns:

Expected hitting times ordered by vertex number.

Return type:

tuple[float, …]

oracq.algorithms.input_model.graph_walks.suggest_steps(transition, marked)[source]¶

MNRS suggested walk step count: ceil(pi/4 * sqrt(H_avg)), where H_avg is the average hitting time.

Matches the Grover limit: on the complete graph H_avg = N/|M| and the step count recovers pi/4 * sqrt(N/|M|).

Parameters:
  • transition – Nonnegative square transition matrix with each row summing to 1.

  • marked – Set of marked vertex numbers, which must be nonempty and in range.

Returns:

Suggested iteration count, at least 1; zero when there are no free vertices.

Return type:

int

Next
initial
Previous
Density-matrix input models and Gibbs states
Copyright © 2026, oracq developers
Made with Sphinx and @pradyunsg's Furo
On this page
  • Graph-walk search
    • AdjacencyOracle
      • AdjacencyOracle.oracle_kind
      • AdjacencyOracle.operation
      • AdjacencyOracle.adjacency_oracle()
      • AdjacencyOracle.vertex_bits
      • AdjacencyOracle.degree_bits
      • AdjacencyOracle.vertices
      • AdjacencyOracle.degree
      • AdjacencyOracle.xor_database()
    • as_adjacency()
    • abstract_adjacency()
    • gate_adjacency()
    • qram_adjacency()
    • szegedy_walk()
    • szegedy_setup()
    • quantum_walk_search()
    • transition_matrix()
    • hitting_times()
    • suggest_steps()