University of Wisconsin team releases open-source quantum encoding tool

Krishnan Suresh and Sanjay Suresh of University of Wisconsin-Madison have released PyEncode, a new open-source Python library designed to bypass limitations in quantum state preparation. General-purpose quantum encoding circuits require a number of gates proportional to 2 to the power of m for vectors of length N = 2^m, but PyEncode implements efficient circuits for vectors with inherent mathematical structure. The library unifies a decade of theoretical work establishing these methods, offering ten exact pattern families, including sparse, Walsh, and Fourier, with gate counts scaling from O(m) to O(m^2).

A function encode maps each pattern to a verified Qiskit circuit, with no vector materialization and no approximation; for example, encode(SPARSE([(19, 1.0)]), N = 64) encodes the vector e_(19) of length N = 64. A companion predict_gates function estimates transpiled gate counts without synthesis, and a reverse-lookup utility match_vector identifies which family best fits a given numerical vector. PyEncode also provides a matrix product state (MPS) loader, encode_mps for approximate vector encoding.

The library is designed to work with Qiskit 2.3.1. PyEncode is available at https://github.com/UW-ERSL/PyEncode.

PyEncode: Open-Source Library for Quantum State Preparation

A quantum circuit capable of encoding specific vector types with significantly fewer gates than general-purpose methods is now publicly available. Developed by Krishnan Suresh and Sanjay Suresh at University of Wisconsin-Madison, the PyEncode library addresses a critical bottleneck in quantum computation: the efficient loading of classical data into quantum registers.

For instance, encoding a vector with a single non-zero entry at index 19 within a 64-dimensional space, a task requiring 97 gates using Qiskit’s StatePreparation, becomes achievable with just three gates using PyEncode’s sparse pattern function. This reduction in gate count is not merely theoretical; the library delivers verified Qiskit circuits, ensuring accuracy without vector materialization or approximation.

The team reports gate counts after transpilation to Qiskit 2.3.1 at optimization_level = 3. PyEncode’s efficiency stems from recognizing that most vectors encountered in scientific and engineering applications are not random. In computational mechanics, force vectors often follow known mathematical forms, while lattice Hamiltonians in quantum chemistry exhibit translational invariance, reducing the complexity of the coefficient vector.

Three composition primitives, SUM for weighted superpositions, PARTITION for ancilla-free composition, and TENSOR for separable states, allow users to combine these patterns to construct more complex quantum states. The researchers detail that for sparse, step, Walsh, Hamming, and staircase patterns, the gate requirement is proportional to m, while square and Fourier patterns require a number of gates proportional to m squared.

Dicke states, representing uniform superpositions, demand a number of gates proportional to k multiplied by (m-k), where k is the Hamming weight. The library is freely available at https://github.com/UW-ERSL/PyEncode, providing a practical tool for researchers and developers seeking to optimize quantum state preparation for specific applications. The team emphasizes that throughout the work, N = 2^m denotes the vector length on a m-qubit register, with parameters like sparsity (s) and polynomial degree (d) influencing the efficiency of each pattern.

Amplitude Encoding Bottleneck and Vector Structure

The challenge of efficiently loading classical data into quantum systems has long been a central hurdle in realizing the potential of quantum algorithms. Researchers at University of Wisconsin-Madison have now addressed this limitation with PyEncode, an open-source library designed to exploit those patterns. This library doesn’t simply offer new theoretical circuits; it provides a practical, unified implementation of a decade’s worth of advancements in structured vector encoding.

PyEncode implements ten distinct pattern families, including sparse, step, Walsh, Fourier, and Dicke states, each with its own optimized encoding circuit. This level of optimization is crucial because, as the developers explain, amplitude encoding, also known as state preparation, is a well-known bottleneck; encoding a vector of length N = 2^m with general state preparation requires a number of gates proportional to 2 to the power of m, potentially negating algorithmic speedups. The availability of PyEncode, accessible at https://github.com/UW-ERSL/PyEncode, provides a valuable resource for researchers seeking to overcome this challenge and unlock the full potential of quantum computation.

Ten Exact Patterns Implemented in PyEncode

This approach, detailed in a paper published on September 1, 2026, delivers substantial performance gains for vectors commonly encountered in scientific and engineering disciplines. PyEncode isn’t simply a novel theoretical construction; it represents a practical unification of a decade’s worth of research into efficient circuits for specific vector classes. For instance, the function encode directly translates a sparse vector, one with predominantly zero values, into a quantum state using only a number of gates proportional to m, where ‘m’ represents the number of qubits.

The efficiency isn’t limited to sparse vectors; degree-d polynomials benefit from a gate complexity proportional to m to the power of (d+1). Beyond these ten exact patterns, PyEncode provides flexibility through three composition primitives. SUM enables weighted superpositions, PARTITION allows ancilla-free composition of disjoint-support patterns, and TENSOR facilitates the creation of separable states over disjoint subregisters.

Dicke State and Polynomial Encoding Efficiency

The University of Wisconsin-Madison has delivered a new Python library, PyEncode, designed to significantly reduce the computational demands of preparing quantum states for specific types of data. This addresses a critical bottleneck in quantum computing, where the process of loading classical information onto a quantum register often outweighs the benefits of the quantum algorithm.

PyEncode unifies a decade of theoretical advancements in efficient quantum circuit construction, providing implementations for ten distinct patterns including Dicke states and polynomial encoding. The library’s utility extends beyond simply offering these methods; it provides a practical, open-source tool for researchers and developers who previously lacked the means to implement these theoretically efficient approaches.

The efficiency gains are not merely theoretical; the library includes a predict_gates function to estimate transpiled gate counts before circuit synthesis, allowing users to assess performance without full compilation. The team demonstrated this efficiency with a sparse vector of length 64, achieving encoding with only 3 gates using encode(SPARSE([(19, 1. 0)]), N = 64), compared to the 97 gates required by Qiskit’s standard StatePreparation routine.

For amplitude vectors that do not conform to these established patterns, the library provides an approximate vector encoding method utilizing matrix product states (MPS), offering a balance between accuracy and computational cost. The library is designed to work with Qiskit 2.3.1 at optimization_level = 3.

PyEncode Composition Primitives: SUM, PARTITION, TENSOR

Beyond recognizing ten distinct patterns in amplitude vectors, sparse, step, square, Walsh, Fourier, geometric, Hamming, staircase, Dicke, and polynomial, the PyEncode library provides tools to construct more complex states from these fundamental building blocks. These composition primitives, SUM, PARTITION, and TENSOR, allow researchers to efficiently encode vectors that do not directly align with the established, optimized patterns. This is achieved without reverting to general-purpose encoding methods, preserving the potential for significant gate count reduction.

Similarly, the PARTITION primitive enables the composition of disjoint-support patterns, effectively merging states defined on separate subregisters without the need for ancillary qubits. This ancilla-free composition is a crucial optimization, as ancillary qubits introduce overhead in terms of gate count and qubit allocation. The utility of these primitives extends beyond simple combination; they allow for the construction of intricate states from a limited set of optimized components.

The TENSOR primitive addresses the encoding of separable states, where the overall state is a product of states defined on disjoint subregisters. This is particularly relevant in scenarios involving multi-dimensional data or systems with independent components. By encoding each subregister separately and then combining the results using the TENSOR primitive, PyEncode avoids the exponential scaling associated with encoding the entire state as a single, monolithic vector. The library also incorporates an MPS loader, encode_mps, for approximate vector encoding when exact patterns are unavailable.

The accompanying match_vector utility identifies which family best fits a given numerical vector. This automated pattern recognition, combined with the composition primitives, positions PyEncode as a versatile tool for a wide range of quantum applications.

MPS Loader for Approximate Vector Encoding

For these cases, the encode_mps function offers approximate vector encoding. The library’s design prioritizes minimizing the trade-off between accuracy and computational cost. This predictive power allows users to assess the feasibility of different encoding strategies and select the most efficient approach for their specific vector and target quantum hardware. As Shende et al established, preparing an arbitrary N = 2^m -dimensional quantum state requires a number of gates proportional to 2 to the power of m, potentially negating any algorithmic speedup. The library is available at https://github.com/UW-ERSL/PyEncode.

Benchmarking: PyEncode vs. Qiskit State Preparation

The efficiency of quantum state preparation hinges on minimizing the number of gates required to encode classical data, and a new Python library, PyEncode, directly addresses this challenge by leveraging inherent mathematical structure within input vectors. This isn’t simply a theoretical exercise; the library unifies a decade of previously disparate theoretical work into a readily accessible tool for quantum computation. PyEncode’s core strength lies in its implementation of ten distinct exact pattern families, including sparse, step, and Walsh functions, each mapped to a verified Qiskit circuit.

Beyond direct encoding of known patterns, PyEncode incorporates a predictive capability. Benchmarking against standard quantum libraries reveals substantial performance differences. For example, encode(SPARSE([(19, 1.0)]), N = 64) achieves the same result with just 3 gates.

These improvements aren’t limited to simple cases; even more complex patterns like degree-d polynomials benefit from PyEncode’s optimized circuits, requiring a number of gates proportional to m to the power of (d+1). This hybrid approach balances accuracy and computational cost, offering a practical solution for a wider range of input data. The library is designed to work with Qiskit 2.3.1 at optimization_level = 3.

Stay current

See today’s quantum computing news on Quantum Zeitgeist for the latest breakthroughs in qubits, hardware, algorithms, and industry deals.

Avatar of Ivy Delaney

Ivy Delaney

Ivy Delaney has been working with neural networks and machine learning since the mid-nineties, back when a couple of hidden layers and a long afternoon of training counted as ambitious. She has watched the field go from academic curiosity to the thing quietly running underneath everything, and she brings that long view to quantum computing. For Quantum Zeitgeist she covers the ground where the two fields meet. That means quantum machine learning and the variational algorithms it leans on, and it also means the less glamorous but more interesting story of classical machine learning already doing real work inside quantum machines, decoding error-correcting codes, calibrating noisy hardware and learning the error models that simulators depend on. She writes about the hardware those algorithms have to run on too, and about the post-quantum cryptography scramble that the same hardware has set off. Her stories typically start with the paper, whether that is peer-reviewed work, conference proceedings or an arXiv preprint, with the source linked so you can hold a claim up against the research it came from. She is unimpressed by benchmarks that will not say what they beat, and by demonstrations that only work in the press release.

Latest Posts by Ivy Delaney: