Choosing a quantum data encoding method is a modelling decision, not just a circuit-construction detail. This guide compares basis, angle, amplitude and feature-map encoding, then shows how to estimate qubit requirements, circuit overhead, data-loading effort and hardware practicality before committing to a quantum machine-learning or optimisation workflow.
Overview
Quantum data encoding converts classical values into a quantum state that a circuit can process. The method you choose affects nearly every later stage: the number of qubits, the number and type of gates, the depth of the circuit, the amount of preprocessing, and how difficult it is to obtain a useful result from hardware.
There is no universally best encoding. A small binary dataset may suit basis encoding, while a compact continuous feature vector may be easier to start with using angle encoding. Amplitude encoding can represent many values with relatively few qubits in theory, but preparing the required state may introduce substantial circuit cost. Feature-map encoding is a broader modelling pattern that combines data re-uploading, rotations and entangling operations to create a kernel or variational model.
For an initial quantum machine-learning experiment, the most useful question is usually not “Which method stores the most data?” It is “Which method gives me a fair, reproducible experiment within the available circuit and measurement budget?” Keep a classical baseline alongside the quantum model, and record the encoding assumptions so that results remain comparable when the dataset or SDK changes.
| Method | Typical qubit estimate | Data requirements | Practical profile | Suitable starting points |
|---|---|---|---|---|
| Basis encoding | Usually one qubit per binary feature, or approximately log2(N) qubits for N basis states | Binary, categorical or discretised data | Simple conceptually; continuous values need preprocessing | Binary classification, combinatorial and constraint representations |
| Angle encoding | Often one qubit per feature, unless features are reused | Scaled real-valued features | Accessible and hardware-friendly; qubit count can grow with feature count | Small variational models and early hardware experiments |
| Amplitude encoding | At least ceil(log2(N)) qubits for N values | A normalised vector, usually padded to a power-of-two length | Compact qubit count; state preparation can be expensive | Experiments where state preparation is controlled and justified |
| Feature-map encoding | Depends on feature grouping and map design | Usually scaled numerical features | Flexible, but depth and entanglement can increase quickly | Quantum kernels, QAOA-style analyses and variational classifiers |
How to estimate
Use a short estimation workflow before writing the full circuit.
- Define the information to encode. Count raw features, binary variables, categories and target outputs separately. Do not assume that every column must become a separate qubit.
- Choose the representation. Decide whether the circuit needs exact binary states, continuous rotations, vector amplitudes or interactions between features. The problem representation should lead the choice.
- Estimate qubits. For angle encoding, begin with the number of features assigned to simultaneous rotations. For amplitude encoding, use q = ceil(log2(N)) and pad the vector when N is not a power of two. For basis encoding, count the bits needed to represent the states or variables.
- Estimate circuit depth. Count encoding layers, entangling layers, repetitions and any state-preparation routine. A lower qubit count does not automatically mean a lower total cost.
- Estimate measurement work. Decide how many observables, outputs and repetitions are needed. In a hybrid quantum-classical model, include the number of circuit evaluations required during training.
- Compare against a baseline. Run the same train-test split, preprocessing rules and evaluation metric with a classical model. A quantum circuit is not a useful improvement if the comparison is not controlled.
A practical planning formula is:
Total experiment effort ≈ circuit evaluations × shots per evaluation × execution overhead.
This is not a cloud-price formula. It is a repeatable way to compare designs before provider-specific pricing, queueing and hardware details are added. For a broader planning view, see the guide to planning quantum cloud workloads.
Inputs and assumptions
Feature scale and normalisation
Angle encoding maps feature values to rotation angles. Establish a documented range, such as a linear mapping to a selected interval, and apply the same transformation to training, validation and test data. Poorly scaled inputs can make rotations difficult to compare and can obscure whether a model is learning from the data or from preprocessing artefacts.
Amplitude encoding requires a vector whose squared entries sum to one. If the original vector is x, the encoded vector is typically based on x divided by its Euclidean norm, provided the norm is non-zero. A length that is not a power of two requires padding. Record the padding rule and confirm that it does not introduce a misleading feature or alter the label distribution.
Feature count and qubit budget
With d numerical features, a basic angle-encoding design often starts at d qubits. You can reduce this number by selecting features, using classical dimensionality reduction, encoding features in successive layers, or reusing qubits. Each choice changes the model and should be reported rather than hidden.
For amplitude encoding, d values require at least ceil(log2(d)) qubits, after padding where necessary. That compact register is only part of the estimate: preparing an arbitrary amplitude state can require a non-trivial sequence of gates. When testing on noisy devices, evaluate the complete preparation circuit rather than comparing qubit counts alone.
Entanglement and feature maps
A feature map may apply one or more rotations per feature, followed by entangling gates in a chosen connectivity pattern. More layers can express richer interactions, but they also increase depth and the number of opportunities for noise. Start with the smallest map that tests the hypothesis, then add layers only when validation results justify them.
SDK implementations change over time, so treat circuit diagrams, parameter conventions and transpilation output as part of the experiment record. The same conceptual map can produce different hardware circuits after compilation in Qiskit, PennyLane, Cirq or a cloud platform.
Worked examples
Example 1: Eight binary variables
Suppose an optimisation problem has eight yes-or-no decisions. A direct basis representation can use eight qubits, with each qubit representing one decision. If the model instead needs to label one of eight mutually exclusive states, three qubits are sufficient because 23 = 8, although unused or invalid states may need constraints. The first design is easier to interpret for independent decisions; the second is more compact for a single state index.
For a constrained scheduling or assignment problem, validate that every measured bitstring represents a legal solution. Encoding alone does not enforce the business constraint. The quantum optimisation formulation checklist provides a useful companion workflow.
Example 2: Four continuous features
For four scaled numerical features, a first angle-encoding circuit can use four qubits and one rotation per feature. Add a single entangling layer, measure the selected observable, and compare the result with a classical baseline. This design is easy to inspect: the qubit count, feature-to-rotation mapping and added interaction layer are explicit.
An alternative is amplitude encoding. Four values fit into two qubits because 22 = 4, but the vector must be normalised and the state-preparation routine must be included in the depth and noise assessment. The two-qubit design is therefore not automatically the cheaper or more reliable experiment.
Example 3: Sixteen features reduced to four
Assume a dataset has sixteen measured features but the available circuit budget supports only a small model. A classical preprocessing step can reduce the input to four components. You can then compare four-qubit angle encoding with two-qubit amplitude encoding. Keep the reduction method fixed, document information loss, and test both against the same classical baseline. If a feature map adds two entangling layers, count those layers in both the simulator and hardware versions rather than comparing only the initial encoding.
When to recalculate
Revisit the encoding estimate whenever the dataset, model or execution environment changes. Recalculate when feature count changes, a new normalisation rule is introduced, dimensionality reduction is added, the number of feature-map layers changes, or a different hardware backend and compiler target is selected.
Recheck the estimate after a major SDK release changes feature-map APIs, transpilation behaviour, supported primitives or state-preparation routines. Also revisit it when measurement results become unstable, circuit depth grows during compilation, or training requires more circuit evaluations than expected. Noise and measurement effects can make a theoretically compact encoding impractical, so use the debugging and measurement workflows in this noisy-circuit checklist and the measurement shot-allocation guide.
Before each new experiment, record five numbers: encoded features or variables, qubits, circuit depth after compilation, circuit evaluations, and shots per evaluation. Then repeat the same test with the classical baseline. This simple record turns quantum data encoding from a vague design preference into a decision that can be reviewed, reproduced and updated as the workload changes.