Choosing a quantum data-encoding method is a resource decision, not simply a programming choice. This guide compares basis, angle, amplitude and feature-map encoding so you can estimate qubit requirements, circuit depth, normalisation work and data-loading overhead before building a quantum machine-learning experiment.
Overview
Classical data cannot be passed directly into a quantum circuit as an ordinary array. It must first be represented by qubit states, gate angles or the parameters of a feature map. The encoding method affects almost every later stage of an experiment: how many qubits are needed, how deep the circuit becomes, how much preprocessing is required and whether the resulting circuit is practical to simulate or run on hardware.
There is no universally best encoding. A small binary dataset may suit basis encoding, while continuous features are often more naturally represented with angle encoding. Amplitude encoding can represent many values with relatively few qubits, but preparing the required quantum state may be expensive. Feature maps extend basic encodings with structured layers of single- and multi-qubit gates, making them useful when the relationship between features is part of the experiment.
| Method | Typical qubit estimate | Main cost | Good starting use case |
|---|---|---|---|
| Basis encoding | Often one qubit per binary feature, or ceiling of log2 of the number of categories | Representing discrete states and preparing bit patterns | Binary, categorical or combinatorial data |
| Angle encoding | Often one qubit per feature per layer | Repeated rotations and feature scaling | Small to medium continuous feature vectors |
| Amplitude encoding | n qubits represent up to 2^n amplitudes | State preparation and normalisation | Experiments where qubit count is tightly constrained |
| Feature-map encoding | Usually tied to the number of input features and map design | Circuit depth, entangling gates and repeated layers | Quantum kernels and variational models |
These are planning estimates rather than performance guarantees. A compact representation may require more difficult state preparation, and a simple encoding may use more qubits but be easier to test and interpret.
How to estimate
1. Count the information you actually need
Start with the model input, not the raw database schema. Remove identifiers, duplicate columns, leakage variables and features that will not be used by the classical baseline. Record the final number of features, their types, value ranges, category counts and whether the model needs the full precision of each value.
2. Estimate the qubit requirement
For basis encoding, binary values can usually be mapped to computational-basis states such as 0 and 1. If there are m possible categories, an index representation needs at least the smallest integer n for which 2n is at least m. If invalid bit patterns are created by this rounding, the circuit or classical preprocessing must handle them.
For angle encoding, a simple estimate is one qubit per feature. A vector with six scaled features therefore needs six data qubits for one rotation layer. If the feature map repeats the data-dependent layer r times, the qubit count may remain six while the depth and gate count increase.
For amplitude encoding, n qubits can describe a state with up to 2n amplitudes. The minimum qubit estimate is therefore the smallest n for which 2n is at least the length of the padded input vector. This advantage is easy to overstate: the circuit still needs to prepare those amplitudes, and that preparation can dominate the experiment.
3. Estimate depth and data-loading work
Separate the encoding circuit from the algorithm that follows it. Write down the number of rotation gates, entangling gates, barriers, measurements and repeated encoding layers. For a feature map, note whether features appear once or in several layers and whether pairs of features are connected. A dense entangling pattern can increase depth quickly, particularly after hardware-aware transpilation.
Also distinguish one-time setup from per-sample cost. Normalising a dataset may be performed classically once, but preparing every row as a quantum state is normally a per-sample operation. For a dataset with N rows, an approximate workload is the cost of preparing one encoded row multiplied by N, plus the chosen number of measurement shots and model evaluations.
4. Check the representation against the objective
Encoding should preserve information that the algorithm can use. A categorical code such as 0, 1 and 2 does not automatically express a meaningful distance between categories. Likewise, clipping continuous values to fit a rotation range can remove distinctions that matter to the target. Compare the encoded representation with a classical baseline using the same train, validation and test split.
Inputs and assumptions
Before selecting an encoding, create a short resource sheet with these inputs:
- Feature count: the number of retained columns after classical preprocessing.
- Feature type: binary, categorical, ordinal, integer or continuous.
- Value range: minimum, maximum, outliers and missing-value treatment.
- Rows and batches: the number of examples that must be encoded and whether batching or sampling is planned.
- Qubit budget: the available logical or simulator qubits, including any ancillas required by the circuit.
- Depth budget: the circuit depth that can be simulated or tested reliably in the chosen environment.
- Precision requirement: whether approximate scaling, binning or dimensionality reduction is acceptable.
- Evaluation plan: shots per circuit, number of optimisation steps and number of model evaluations.
For angle encoding, choose a documented scaling rule. A common planning approach maps a bounded feature interval to a rotation interval, but the exact range depends on the gate convention and the framework. Fit scaling parameters on the training data only, then apply the same transformation to validation and test data.
For amplitude encoding, verify that every input vector has the same length, pad it consistently when necessary and compute its norm. A vector x must be converted to a normalised state, conceptually x divided by its Euclidean norm, unless the selected software handles the preparation differently. Track the padding because unused amplitudes can change the effective representation.
For feature maps, record the map definition rather than just its name. Two feature maps can use the same number of input features but differ substantially in entanglement pattern, repetitions and depth. Keep the feature map fixed while comparing models, or treat a change of map as a separate experiment.
Worked examples
Example 1: Six scaled sensor features
Suppose a dataset contains six continuous features and the first experiment has a modest qubit budget. A one-layer angle encoding is straightforward: six features require approximately six qubits, with one data-dependent rotation per qubit. A second layer could add trainable rotations and entangling gates, but depth must then be measured rather than inferred from the qubit count.
Amplitude encoding could use three qubits because 23 equals eight, enough slots for six values after consistent padding. However, the preparation circuit may be more involved than six individual rotations. The sensible comparison is therefore not six qubits versus three qubits alone. Record state-preparation depth, transpiled depth, entangling-gate count and validation performance for both versions.
Example 2: A four-category variable and three binary flags
Four categories can be represented by two basis qubits using four bit patterns. Three binary flags require three more qubits in a direct representation, giving an initial estimate of five qubits. If the categories have a genuine order, an angle or ordinal representation may be appropriate, but assigning binary codes to unordered categories should not imply that category 3 is mathematically closer to category 2 than category 0.
Example 3: Reducing a wide dataset before encoding
A dataset with 24 continuous features would need about 24 qubits for a simple one-feature-per-qubit angle layer. If that exceeds the available budget, first test classical feature selection or dimensionality reduction. Reducing to eight components makes an eight-qubit angle encoding possible, but the components must be fitted on training data and documented. Compare the reduced classical model with the quantum model so that any observed difference is not attributed incorrectly to the circuit.
In each example, use a simulator or small circuit test to confirm the estimate. The quantum circuit resource estimation guide can help organise qubit, gate, depth and shot assumptions, while the quantum machine-learning data preparation workflow provides a broader validation checklist.
When to recalculate
Revisit the estimate whenever the dataset, framework implementation or target execution environment changes. In particular, recalculate when you add or remove features, change category handling, alter the scaling range, increase feature-map repetitions, switch simulators, target a different hardware backend or introduce ancilla qubits.
Recalculate after transpilation as well as before it. The abstract circuit may look compact, while the hardware-compatible version uses additional gates or a different entanglement layout. Test representative rows rather than only an empty circuit, and use regression checks to confirm that preprocessing and circuit construction remain consistent. The quantum program testing guide and circuit optimisation guide are useful next steps.
As a practical workflow, begin with a classical baseline, prepare a resource sheet, choose the simplest encoding that preserves the required information, and run a small validation experiment. Keep a record of qubits, depth, gates, state-preparation cost, shots and model evaluations. When any of those inputs changes, update the estimate before drawing conclusions. This makes the choice between basis, angle, amplitude and feature-map encoding repeatable rather than a matter of intuition.