Choosing a quantum data encoding method is a modeling decision, not just a circuit-building detail. This guide compares basis, angle, amplitude, and feature-map encoding so you can match a dataset’s size, value range, sparsity, and learning objective to a practical quantum circuit design.
Overview
Quantum data encoding, sometimes called quantum feature mapping, converts classical values into the state of one or more qubits. The encoding determines how much circuit work is required before the algorithm can perform useful computation. It also affects trainability, measurement strategy, simulator cost, and whether a circuit is realistic for available hardware.
There is no universally best approach. A small binary dataset may suit basis encoding, while a compact collection of continuous features may be easier to test with angle encoding. Amplitude encoding can represent many values with relatively few qubits, but preparing the required state can introduce substantial overhead. Feature maps add structured rotations and entanglement to expose relationships between features; they are often used in variational algorithms and quantum machine learning rather than as a standalone replacement for preprocessing.
Before selecting a method, define four properties of the dataset:
- Feature count: How many input variables must be represented?
- Value type: Are the values binary, categorical after encoding, continuous, sparse, or already normalized?
- Objective: Do you need a simple demonstration, a classifier, a kernel, an optimization loop, or a reusable data pipeline?
- Execution target: Will the circuit run only on a simulator, or must it eventually run on quantum hardware?
Encoding is only one part of resource planning. After choosing a representation, estimate qubits, gate count, depth, shots, and runtime using the principles in Quantum Circuit Resource Estimation: Qubits, Gates, Depth, Shots, and Runtime.
Comparison of common quantum data encoding methods
| Method | Typical qubits | Data preparation | Normalization | Best starting use |
|---|---|---|---|---|
| Basis encoding | Often one qubit per binary bit | Apply X gates to represent 1 values | Not usually required for binary input | Binary states, discrete demonstrations, combinatorial representations |
| Angle encoding | Often one qubit per feature | Map values to rotation angles | Scaling to a suitable angle range is usually required | Small tabular datasets and variational models |
| Amplitude encoding | For a vector of length N, typically enough qubits to index N amplitudes | Prepare a quantum state whose amplitudes contain the values | Required because amplitudes must form a normalized state | Compact vector representations when state preparation is available |
| Feature-map encoding | Depends on the feature-map design | Rotations, repeated layers, and sometimes entangling gates | Input scaling is commonly needed | Quantum kernels and variational quantum machine learning |
The qubit counts in this table are planning guides, not fixed rules. A feature map may reuse features, repeat layers, or use additional ancillas. An amplitude-encoding implementation may also require a state-preparation routine whose depth is more important than its qubit count.
Checklist by scenario
Choose basis encoding for binary or discrete inputs
Basis encoding represents a bit string directly in computational basis states. For example, the classical value 101 can be represented by preparing three qubits so their measured state corresponds to that bit pattern. In a simple circuit, this means applying an X gate to qubits representing 1 bits and leaving the others in the zero state.
Use this method when interpretability and straightforward preparation matter more than dense representation. It is useful for teaching how to build a quantum circuit, testing bitwise logic, and representing discrete candidate solutions. It becomes less convenient when continuous features need to be preserved, because discretization can discard information and increase the number of bits required.
- Confirm that converting values to bits does not remove information needed by the model.
- Record the bit ordering convention used by the SDK and your preprocessing code.
- Test a small set of known bit strings before adding a learning loop.
Choose angle encoding for small continuous datasets
Angle encoding maps a feature to a gate parameter, such as the angle of an RX, RY, or RZ rotation. A circuit might use one qubit per feature and apply a rotation based on the corresponding value. The exact gate and scaling convention should be treated as part of the experiment configuration.
This is usually the most accessible starting point for quantum programming with Python because the relationship between a classical feature and a circuit parameter is easy to inspect. Before encoding, scale features consistently. A raw value with a large magnitude can produce rotations that wrap around or behave very differently from a small value. Standardization, min-max scaling, clipping, or a domain-specific transformation may be appropriate, but the choice should be recorded and evaluated rather than assumed.
Angle encoding is a practical baseline for a quantum machine learning tutorial: build the circuit, attach a measurement or expectation-value readout, and compare results against a classical baseline. It may require many qubits when the feature count is high, so reduce features or use a classical projection before encoding if the target backend cannot support the circuit.
Choose amplitude encoding for compact vector representation
Amplitude encoding stores normalized classical values in the amplitudes of a quantum state. In principle, this can represent a vector using fewer qubits than one-feature-per-qubit approaches. However, the apparent qubit advantage does not automatically make the method cheaper or more practical. Preparing an arbitrary state can require a nontrivial circuit, and that preparation cost may dominate the computation.
Use amplitude encoding when the compact state representation is central to the experiment and you have a credible state-preparation method for the selected SDK or backend. Start with short vectors and a simulator. Verify that the prepared state matches the intended vector before adding a classifier or optimizer.
- Pad the vector to a supported length when required by the preparation routine.
- Normalize the vector and define how an all-zero or near-zero vector is handled.
- Measure state-preparation depth, not only the number of qubits.
- Check whether the chosen hardware or service supports the preparation approach you intend to use.
Choose a feature map when relationships between features matter
A feature map is a parameterized circuit that embeds classical features through rotations and, in many designs, interactions between qubits. Entangling terms can encode relationships that are not represented by independent single-qubit rotations. In practice, “feature-map encoding” describes a family of circuit designs rather than one universal method.
Use a feature map when you are evaluating a quantum kernel, variational classifier, or another hybrid quantum-classical workflow. Keep the first experiment shallow and make the feature map configurable. Compare a circuit with single-feature rotations against one with entangling terms so you can test whether the added depth improves validation performance rather than assuming it will.
For a complete workflow, pair the encoding with a classical optimizer, validation split, reproducible seed where supported, and an explicit baseline. The guide How to Build a Hybrid Quantum-Classical Workflow in Python provides useful context for organizing that loop.
A small Python notebook template
The following framework-neutral template separates preprocessing from circuit construction. Replace the circuit library calls with the syntax required by your selected SDK, such as Qiskit, Cirq, or PennyLane.
import numpy as np
# X: rows are samples; columns are features
X = np.asarray(X, dtype=float)
# Example: scale each feature to a bounded interval
low = X.min(axis=0)
high = X.max(axis=0)
span = np.where(high > low, high - low, 1.0)
X_scaled = (X - low) / span
angles = np.pi * X_scaled
for sample in angles:
# Create a circuit with len(sample) qubits.
# Apply one chosen rotation per feature.
# Add optional entangling gates only as an explicit experiment.
# Measure or return expectation values.
pass
For amplitude encoding, add a separate validation cell that checks the vector norm and compares measured probabilities or simulator state data with the expected amplitudes. For basis encoding, convert each row to a documented bit representation and test the measured bit string on a noiseless simulator first.
What to double-check
- Preprocessing leakage: Fit scaling parameters on the training data only when evaluating a model. Applying information from the test set can make the comparison misleading.
- Qubit ordering: SDKs may display or index bits in different orders. Use a known basis state to confirm how classical columns map to qubits.
- Depth after compilation: A short logical circuit may become deeper after it is translated to a backend’s gate set and connectivity. Compare compiled circuits when hardware execution is planned.
- Measurement design: Decide whether you need samples, probabilities, expectation values, or kernel estimates. The readout determines how many shots and how much post-processing are required.
- Simulator assumptions: State-vector simulation, shot-based simulation, and noisy simulation answer different questions. A result from one mode should not automatically be treated as a hardware result.
- Classical baseline: Compare the quantum pipeline with a simple classical model using the same train-test split and preprocessing. This identifies whether the encoding is adding useful signal.
- Backend fit: Check qubit availability, connectivity, supported gates, queue or execution constraints, and account structure before committing to cloud runs. See How to Choose a Quantum Computing Backend for a Workload.
When moving from a notebook to a managed service, separate encoding logic from backend configuration. This makes it easier to test the same circuit on a local simulator and a cloud target without silently changing the data transformation.
Common mistakes
- Choosing by qubit count alone: Amplitude encoding may use fewer qubits, but state preparation can add substantial depth and noise sensitivity.
- Skipping normalization: Rotation angles and amplitudes have mathematical constraints. Raw features should not be passed into an encoding routine without checking its expected range.
- Encoding every feature immediately: More features can mean more qubits, deeper circuits, and harder interpretation. Begin with a deliberately small subset.
- Calling every circuit a feature map: A single rotation layer, an amplitude-preparation routine, and an entangling variational ansatz serve different purposes. Document the circuit’s role.
- Ignoring data-loading overhead: A model can appear efficient after encoding while spending most of its resources preparing the input state.
- Comparing incompatible experiments: Keep preprocessing, shots, measurements, optimizer settings, and evaluation splits consistent when comparing methods.
- Moving to hardware too early: Validate mapping, output interpretation, and basic learning behavior on a simulator before paying for or waiting on hardware execution. For cloud options, consult the Quantum Cloud Computing Cost Guide.
When to revisit
Revisit the encoding decision whenever the dataset, model, or execution environment changes. A method that works for six scaled features may not remain practical for sixty. A circuit that behaves well in an ideal simulator may need a shallower feature map after compilation to a constrained device.
Use this checklist before each major experiment or planning cycle:
- List the current feature count, value ranges, sparsity, and missing-value policy.
- Write down the selected encoding, scaling rule, qubit count, circuit depth, and measurement method.
- Run a small representative sample through a simulator and verify the encoded state or rotation parameters.
- Compare at least one alternative encoding and one classical baseline under the same evaluation conditions.
- Recheck SDK syntax, supported circuit templates, compilation behavior, simulator limits, and backend constraints after significant framework or platform changes.
- Record the result in the notebook so the next dataset change does not restart the investigation from zero.
As a rule of thumb, start with angle encoding for a small, scaled tabular dataset; use basis encoding when the input is naturally binary; investigate amplitude encoding only when its state-preparation cost is understood; and introduce a feature map when feature interactions are part of the hypothesis. This gives you a repeatable path from a simple quantum circuit to a measured hybrid experiment rather than committing to the most compact-looking representation on paper.