Choosing a quantum data encoding method is an algorithm-design decision, not a formatting detail. This guide compares basis, angle, amplitude, binary and feature-map encoding, then provides a repeatable way to estimate qubit requirements, circuit depth, data-loading overhead and noise exposure before you build a quantum machine-learning experiment.
Overview
Quantum data encoding converts classical values into the state of one or more qubits. The choice affects almost every later stage of a quantum machine-learning workflow: how many qubits are needed, how many gates must be executed, how much preprocessing is required and whether a simulator or quantum device can run the circuit within practical limits.
There is no universally best encoding. A small categorical dataset may suit basis encoding, while normalised continuous features are often more natural for angle encoding. Amplitude encoding can represent many values with relatively few qubits in theory, but preparing the required state may introduce substantial circuit and implementation overhead. A parameterised feature map may be preferable when the encoding and trainable circuit need to work together as one model component.
| Method | Typical input | Qubit estimate | Main trade-off |
|---|---|---|---|
| Basis | Binary or categorical values | One qubit per binary variable in a simple design | Clear and shallow, but limited representation of continuous values |
| Angle | Scaled continuous features | Often one qubit per feature, depending on the circuit | Simple loading, but qubit use grows with feature count |
| Amplitude | Normalised vectors | Approximately log2(N) qubits for N amplitudes | Compact qubit count, but state preparation can be costly |
| Binary or bit-string | Integers, labels or discrete states | Enough qubits to represent the chosen range | Efficient for discrete data, less direct for smooth numeric relationships |
| Feature map | Problem-specific numeric or structured data | Determined by the selected map and feature grouping | Can capture interactions, while depth and entanglement increase |
These are planning estimates rather than guarantees. SDK templates, connectivity constraints, compiler transformations and the chosen ansatz can change the final circuit substantially.
How to estimate
Use the following process before selecting a circuit or provider.
1. Describe the data after preprocessing
Record the number of rows, the number of features, feature types, value ranges, missing-value treatment and whether labels are included. Do not count a feature that will be removed before the quantum circuit. Conversely, include every derived feature that will actually be encoded.
2. Estimate the qubit requirement
For a straightforward angle-encoding design, begin with:
Estimated qubits = number of encoded features
This can change if features are grouped, reused across layers or encoded in separate circuit executions.
For amplitude encoding, a vector with N entries requires a state space with at least N amplitudes. The basic planning estimate is:
Estimated qubits = ceiling(log2(N))
If the vector length is not a power of two, padding may be needed. The estimate describes the register size; it does not describe the cost of preparing the state.
For binary encoding of an integer range from zero to M, use enough qubits to represent every required value:
Estimated qubits = ceiling(log2(M + 1))
Basis encoding may use one qubit per binary variable in a simple implementation. A categorical variable may require one-hot encoding, a binary code or another representation, so its qubit cost depends on the selected preprocessing.
3. Estimate circuit depth and repeated data loading
Count the encoding gates separately from the trainable model. A circuit with few qubits can still be impractical if state preparation or feature interactions create substantial depth. Track:
- single-qubit rotations used to load features;
- entangling gates in the feature map;
- repeated encoding layers;
- ancilla qubits or temporary registers;
- measurement repetitions, often called shots, for each circuit evaluation; and
- the number of circuit evaluations required by training.
A useful workload estimate is:
Total evaluations = training steps × batches × circuit evaluations per step
This is not a cloud-price calculation. It is a repeatable way to compare experiments before applying the provider's current pricing and execution rules.
4. Check noise exposure
Deeper circuits usually create more opportunities for gate errors, decoherence and compilation overhead. Treat depth as a design constraint, not merely a performance metric. Compare candidate encodings at the same preprocessing quality and with the same model-training protocol, then test both an ideal simulator and a noise-aware or hardware execution path where available.
Inputs and assumptions
Write down these inputs before making an encoding decision:
- Feature count: how many values enter the quantum circuit at one time?
- Feature type: binary, categorical, ordinal, continuous, sparse or sequential?
- Value range: must continuous values be scaled to an angle range or normalised as a vector?
- Data volume: how many samples will be encoded during training and evaluation?
- Model objective: classification, regression, similarity estimation, optimisation or generative modelling?
- Execution target: simulator, local device, IBM Quantum, Azure Quantum workflow, Amazon Braket or another provider?
- Accuracy requirement: is the experiment exploratory, or must it support a reproducible business decision?
Angle encoding is often a practical first baseline for a modest number of continuous features because preprocessing and circuit inspection are relatively direct. Scale values consistently, document the scaling rule and avoid allowing an outlier to determine the useful range for every sample.
Amplitude encoding is attractive when the register size is the primary constraint. However, the state-preparation step must be included in the comparison. A low qubit count alone does not prove that the overall workflow is cheaper, shallower or more accurate.
Basis and binary encodings are appropriate when the data is naturally discrete. They can preserve exact bit structure, but converting a continuous dataset into coarse bins may discard information. Feature maps combine data-dependent rotations with, in some designs, entangling operations. They should be assessed as complete circuit blocks rather than judged only by their first layer.
SDK syntax changes over time, so keep the conceptual design separate from implementation details. The same encoding decision can usually be expressed in Qiskit, PennyLane or Cirq, but gate names, feature-map helpers, device interfaces and transpilation behaviour may differ. Validate examples against the version used by the project.
Worked examples
Example 1: Eight continuous features
Suppose a classifier uses eight scaled continuous features. A simple angle-encoding baseline starts with eight qubits and one rotation family per feature. If the trainable circuit adds two repeated layers, record the encoding gates, trainable gates and entangling gates separately. The first comparison should be against a classical baseline and a reduced feature set, not against an imagined quantum advantage.
An amplitude alternative would represent a vector of eight values using a register sized for eight amplitudes, subject to normalisation and any padding rules. The comparison is therefore not “eight qubits versus three qubits” alone. Measure state-preparation depth, total compiled gates, training stability and predictive performance under the same evaluation split.
Example 2: A binary optimisation input
Consider a problem with 12 binary decision variables. Basis encoding can map each variable to a qubit, giving an initial estimate of 12 qubits. This representation is easy to interpret: measuring a qubit produces a candidate bit value. If the algorithm is a QAOA-style optimisation workflow, add the cost and mixer circuits to the encoding assessment. The relevant question is whether the full problem circuit fits the intended simulator or device workflow, not whether the initial encoding is shallow.
Example 3: A 10-category feature
A single categorical variable with 10 possible values can be represented in different ways. One-hot encoding requires 10 binary indicators before quantum loading, while a compact binary code needs enough bits to represent at least 10 states. The compact code uses fewer qubits, but it introduces an ordering and may make two categories look numerically related when they are not. Test the representation against the model objective and document how invalid or unused bit patterns are handled.
For each example, keep a small experiment log containing the encoding, qubit count, compiled depth, two-qubit gate count where available, number of circuit evaluations, validation score and simulator or device conditions. This makes later comparisons more useful than a single headline metric.
When to recalculate
Revisit the estimate whenever the dataset, model or execution environment changes. Recalculate when features are added or removed, categorical values change, scaling is revised, a different feature map is selected, the ansatz gains another layer, batches or training steps change, or the workflow moves from simulation to hardware execution.
Also review the calculation when an SDK releases a new circuit-construction or compilation workflow, when a provider changes device availability or pricing inputs, or when a benchmark is repeated with a different noise model. Do not carry forward an old cost or depth estimate simply because the source code still runs.
A practical decision rule is:
- Start with the simplest encoding that preserves the information required by the task.
- Build a classical baseline and a shallow quantum baseline.
- Record qubits, compiled depth, entangling gates and total circuit evaluations.
- Compare accuracy, variance and execution burden using the same data split.
- Try a more complex encoding only when it addresses a measured limitation.
For a deeper model workflow, see the practical PennyLane hybrid model tutorial. Developers comparing implementation choices can also use the Qiskit, PennyLane and Cirq SDK guide. The best encoding is the one whose assumptions, resource requirements and results remain clear when the experiment is rerun.