Skip to content
Published on

Quantum Computing for Engineers: From Qubits to Quantum Machine Learning

Authors

1. What Is Quantum Computing?

Quantum computing is a computing paradigm that harnesses the principles of quantum mechanics — superposition, entanglement, and interference — to solve problems that are practically intractable for classical computers.

Classical vs. Quantum Computers

AspectClassical ComputerQuantum Computer
Basic unitBit (0 or 1)Qubit (0, 1, or superposition)
OperationsSequential/parallel logic gatesQuantum gates (unitary transformations)
State spacen bits = one of 2^n statesn qubits = 2^n states simultaneously
Error characteristicsDeterministic, predictableProbabilistic, decoherence-prone
Best suited forGeneral-purpose computationOptimization, quantum simulation, cryptography

With n qubits representing 2n2^n states simultaneously, a 300-qubit system can process more states than there are atoms in the observable universe.

Why Does Quantum Computing Matter?

Quantum computing offers transformative breakthroughs in:

  • Cryptography: Shor's algorithm solves the integer factorization problem — the foundation of RSA encryption — in polynomial time. Breaking 2048-bit RSA would take classical computers millions of years; a fault-tolerant quantum computer could do it in hours.
  • Drug Discovery: Quantum simulation overcomes the exponential complexity barrier of classical molecular simulation, accelerating new material design and protein-folding prediction.
  • Optimization: NP-hard problems in logistics, financial portfolio optimization, and scheduling can benefit from algorithms like QAOA.
  • AI / Machine Learning: Quantum kernels and quantum neural networks may offer superior expressibility over classical ML on certain datasets.

Quantum Advantage vs. Quantum Supremacy

Quantum Supremacy: The moment a quantum computer performs a task that no classical computer can complete in a realistic time. In 2019, Google's Sycamore processor solved a specific sampling problem in 200 seconds — a task estimated to take the best classical supercomputer 10,000 years.

Quantum Advantage: The stricter, more practical bar — when a quantum computer is demonstrably faster on a useful problem, not merely a contrived benchmark.

The NISQ Era

We currently live in the NISQ (Noisy Intermediate-Scale Quantum) era. Devices with 50–1,000 qubits exist but suffer from high error rates and short coherence times. Achieving full Fault-Tolerant Quantum Computing (FTQC) requires millions of physical qubits, a target set for the 2030s and beyond.


2. Qubits

Physical Implementations

TechnologyPrincipleKey CompaniesCharacteristics
SuperconductingJosephson junction, cryogenic coolingIBM, GoogleEasy to fabricate, fast gates
Trapped ionLaser-controlled ionsIonQ, QuantinuumHigh fidelity, slower gates
PhotonicPhoton polarization/pathPsiQuantumRoom temperature, limited connectivity
TopologicalMajorana fermionsMicrosoftTheoretically error-resilient
Silicon spinElectron spinIntelCMOS-compatible

Superposition

Before measurement, a qubit exists in a superposition of 0 and 1:

ψ=α0+β1|\psi\rangle = \alpha|0\rangle + \beta|1\rangle

where α\alpha and β\beta are complex amplitudes satisfying the normalization condition α2+β2=1|\alpha|^2 + |\beta|^2 = 1.

Measurement probabilities are:

P(0)=α2,P(1)=β2P(0) = |\alpha|^2, \quad P(1) = |\beta|^2

When α=12\alpha = \frac{1}{\sqrt{2}} and β=12\beta = \frac{1}{\sqrt{2}}, each outcome has exactly 50% probability — this is the state produced by the Hadamard gate.

Bloch Sphere Representation

Any single-qubit pure state can be represented as a point on the unit sphere (Bloch sphere):

ψ=cos ⁣(θ2)0+eiϕsin ⁣(θ2)1|\psi\rangle = \cos\!\left(\frac{\theta}{2}\right)|0\rangle + e^{i\phi}\sin\!\left(\frac{\theta}{2}\right)|1\rangle

  • θ=0\theta = 0: North pole = 0|0\rangle
  • θ=π\theta = \pi: South pole = 1|1\rangle
  • Equator: Superposition states (e.g., +=12(0+1)|+\rangle = \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle))

Quantum gates correspond to rotations on this sphere.

Decoherence

Qubits lose their quantum superposition when they interact with the environment (heat, electromagnetic noise, vibration). This is called decoherence. Current superconducting qubits have coherence times of tens to hundreds of microseconds — a critical limiting factor for running deep circuits.


3. Quantum Gates

Quantum gates are represented by unitary matrices UU satisfying UU=IUU^\dagger = I. Unlike classical logic gates, all quantum gates are reversible.

Single-Qubit Gates

Pauli Gates

X=(0110),Y=(0ii0),Z=(1001)X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}, \quad Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}, \quad Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}

  • X gate: Quantum NOT. 01|0\rangle \to |1\rangle, 10|1\rangle \to |0\rangle
  • Z gate: Phase flip. Applies 1-1 phase to 1|1\rangle

Hadamard Gate

H=12(1111)H = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}

Transforms 012(0+1)=+|0\rangle \to \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle) = |+\rangle, creating a uniform superposition.

S and T Gates (Phase gates)

S=(100i),T=(100eiπ/4)S = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}, \quad T = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{pmatrix}

Rotation Gates

Rx(θ)=eiθX/2,Ry(θ)=eiθY/2,Rz(θ)=eiθZ/2R_x(\theta) = e^{-i\theta X/2}, \quad R_y(\theta) = e^{-i\theta Y/2}, \quad R_z(\theta) = e^{-i\theta Z/2}

These serve as trainable parameters in variational quantum algorithms.

Two-Qubit Gates

CNOT (Controlled-NOT): Flips the target qubit when the control qubit is 1|1\rangle.

CNOT=(1000010000010010)\text{CNOT} = \begin{pmatrix} 1&0&0&0 \\ 0&1&0&0 \\ 0&0&0&1 \\ 0&0&1&0 \end{pmatrix}

Toffoli (CCNOT): Three-qubit gate. Flips target when both control qubits are 1|1\rangle. Together with single-qubit gates, ensures universality.

Creating a Bell State with Qiskit

from qiskit import QuantumCircuit
from qiskit_aer import AerSimulator

# Create a Bell state (maximum entanglement)
qc = QuantumCircuit(2, 2)
qc.h(0)       # Hadamard: put qubit 0 into superposition
qc.cx(0, 1)   # CNOT: entangle qubit 0 (control) and qubit 1 (target)
qc.measure([0, 1], [0, 1])

print(qc.draw())

# Simulate
simulator = AerSimulator()
job = simulator.run(qc, shots=1000)
result = job.result()
counts = result.get_counts()
print("Measurement results:", counts)
# Expected: {'00': ~500, '11': ~500}
# 01 and 10 never appear — perfect entanglement

The Bell state is Φ+=12(00+11)|\Phi^+\rangle = \frac{1}{\sqrt{2}}(|00\rangle + |11\rangle). Measuring one qubit instantly determines the other, no matter how far apart they are.


4. Quantum Circuits

Statevector Simulation

An n-qubit system's state is a 2n2^n-dimensional complex vector.

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)

sv = Statevector.from_instruction(qc)
print(sv)
# [0.707+0j, 0, 0, 0.707+0j]
# |00> and |11> each with amplitude 1/sqrt(2)

GHZ State (3-Qubit Entanglement)

The GHZ (Greenberger-Horne-Zeilinger) state is the 3-qubit maximally entangled state:

GHZ=12(000+111)|GHZ\rangle = \frac{1}{\sqrt{2}}(|000\rangle + |111\rangle)

qc = QuantumCircuit(3)
qc.h(0)
qc.cx(0, 1)
qc.cx(0, 2)
print(qc.draw())

Quantum Teleportation Protocol

Quantum teleportation transmits a quantum state using a classical communication channel and a shared entangled pair — without physically moving the qubit:

  1. Alice and Bob share a Bell pair.
  2. Alice applies CNOT and H to her qubit and the Bell qubit.
  3. Alice measures her 2 qubits and sends 2 classical bits to Bob.
  4. Bob applies X and/or Z corrections based on the classical bits, recovering Alice's original state.

Quantum Error Correction (QEC) Overview

Physical qubits experience bit-flip and phase-flip errors. QEC codes (Shor Code, Steane Code, Surface Code) encode one logical qubit into multiple physical qubits. The Surface Code is the most promising approach, requiring hundreds to thousands of physical qubits per logical qubit.


5. Landmark Quantum Algorithms

Deutsch-Jozsa Algorithm

Determines whether a function f:{0,1}n{0,1}f:\{0,1\}^n \to \{0,1\} is constant or balanced in exactly 1 query. Classically, worst case requires 2n1+12^{n-1}+1 queries. This was the first proof of quantum advantage.

Grover's Search Algorithm

Finds a target in an unsorted database of N items in O(N)O(\sqrt{N}) queries. Classical brute-force requires O(N)O(N), so Grover provides a quadratic speedup.

from qiskit.circuit.library import GroverOperator
from qiskit import QuantumCircuit
from qiskit_aer import AerSimulator

# 2-qubit Grover search (target: |11>)
oracle = QuantumCircuit(2)
oracle.cz(0, 1)   # Oracle: applies phase -1 to |11>

grover_op = GroverOperator(oracle)

qc = QuantumCircuit(2)
qc.h([0, 1])                          # Uniform superposition
qc.compose(grover_op, inplace=True)   # Grover iteration
qc.measure_all()

simulator = AerSimulator()
job = simulator.run(qc, shots=1000)
result = job.result()
print(result.get_counts())
# |11> appears with high probability

Shor's Factoring Algorithm

Factors an integer N into its prime components in O((logN)3)O((\log N)^3) polynomial time. The best classical algorithm (GNFS) runs in sub-exponential time O(e1.9(logN)1/3(loglogN)2/3)O(e^{1.9(\log N)^{1/3}(\log\log N)^{2/3}}), making Shor exponentially faster.

This is why RSA and ECC encryption are threatened. In response, NIST published Post-Quantum Cryptography (PQC) standards in 2024.

Quantum Fourier Transform (QFT)

Performs the Discrete Fourier Transform using O(n2)O(n^2) quantum gates, exponentially faster than classical FFT at O(NlogN)O(N \log N). It is the core subroutine in Shor's algorithm and quantum phase estimation.

QAOA (Quantum Approximate Optimization Algorithm)

A variational quantum algorithm for combinatorial optimization problems (Max-Cut, TSP, scheduling). It operates as a hybrid of classical optimizer and quantum circuit, making it suitable for near-term NISQ devices.


6. Quantum Errors and Noise

Error Types

Bit-flip error: 01|0\rangle \to |1\rangle or 10|1\rangle \to |0\rangle — an unintended X channel flip.

Phase-flip error: +|+\rangle \to |-\rangle — a Z channel phase change.

Depolarizing channel: The most common noise model. With probability pp, one of X, Y, or Z is applied randomly:

E(ρ)=(1p)ρ+p3(XρX+YρY+ZρZ)\mathcal{E}(\rho) = (1-p)\rho + \frac{p}{3}(X\rho X + Y\rho Y + Z\rho Z)

Gate Fidelity on Current NISQ Devices

OperationTypical Error Rate
Single-qubit gateBelow 0.1%
Two-qubit CNOT gate0.5–1%
Readout1–2%
T1 coherence time100–500 microseconds

Noise Simulation with Qiskit

from qiskit_aer.noise import NoiseModel, depolarizing_error
from qiskit_aer import AerSimulator
from qiskit import QuantumCircuit

# Build noise model
noise_model = NoiseModel()
error_1q = depolarizing_error(0.001, 1)   # 0.1% single-qubit error
error_2q = depolarizing_error(0.01, 2)    # 1% two-qubit error
noise_model.add_all_qubit_quantum_error(error_1q, ['h', 'x'])
noise_model.add_all_qubit_quantum_error(error_2q, ['cx'])

qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()

sim = AerSimulator(noise_model=noise_model)
job = sim.run(qc, shots=1000)
print(job.result().get_counts())
# Ideal: {'00': 500, '11': 500}
# With noise: small counts of '01', '10' appear

7. Quantum Machine Learning (QML)

Variational Quantum Algorithms (VQA)

VQA trains a parameterized quantum circuit (PQC) using a classical optimizer in a hybrid loop:

minθψ(θ)Hψ(θ)\min_\theta \langle \psi(\theta) | H | \psi(\theta) \rangle

Key variants:

  • VQE (Variational Quantum Eigensolver): Molecular energy minimization
  • QAOA: Combinatorial optimization
  • QNN: Classification and regression

Data Encoding Strategies

MethodDescriptionQubit Cost
Angle encodingEach feature encoded as Ry rotation angleN features = N qubits
Amplitude encodingFeatures stored in state vector amplitudeslog2(N) qubits
Basis encodingBinary representation in computational basisN bits = N qubits

Implementing a QNN with PennyLane

import pennylane as qml
import numpy as np

dev = qml.device('default.qubit', wires=2)

@qml.qnode(dev)
def quantum_circuit(x, weights):
    # Angle encoding
    qml.AngleEmbedding(x, wires=[0, 1])
    # Variational layer with entanglement
    qml.BasicEntanglerLayers(weights, wires=[0, 1])
    return qml.expval(qml.PauliZ(0))

# Input data and initial weights
x = np.array([0.5, 0.3])
weights = np.random.random((3, 2))  # 3 layers, 2 wires

result = quantum_circuit(x, weights)
print(f"Expectation value: {result:.4f}")

# Compute gradients via Parameter-Shift Rule
grad_fn = qml.grad(quantum_circuit, argnum=1)
gradients = grad_fn(x, weights)
print(f"Gradients: {gradients}")

Quantum Kernel Methods

Replace the classical kernel in SVMs with a quantum feature map:

K(xi,xj)=ϕ(xi)ϕ(xj)2K(x_i, x_j) = |\langle \phi(x_i)|\phi(x_j)\rangle|^2

A quantum computer efficiently computes inner products in a high-dimensional Hilbert space that is exponentially expensive to simulate classically.

Current Limitations of QML

  • Barren Plateaus: As the number of qubits grows, gradients vanish exponentially, making training infeasible.
  • Data Loading Bottleneck: Encoding classical data into quantum states (amplitude encoding) can negate quantum speedup.
  • NISQ Noise: High error rates limit circuit depth and expressibility.

8. Quantum Hardware Landscape (2026)

Platform Comparison

CompanyTechnologyMax QubitsHighlights
IBM QuantumSuperconductingCondor 1121 qubitsCloud access, open-source Qiskit
GoogleSuperconductingWillow 105 qubitsError correction milestone
IonQTrapped ion36 algorithmic qubitsHigh fidelity
QuantinuumTrapped ionH2 56 qubitsExcellent TPCP operations
D-WaveQuantum annealing5000+ qubitsOptimization-specific

2026 Roadmap Summary

  • Now: NISQ, 100–1000 physical qubits, error rates 0.1–1%
  • 2027–2029: Early error correction, thousands of physical qubits → tens of logical qubits
  • 2030+: Fault-tolerant quantum computing, target of millions of physical qubits

9. Quantum Cloud Access

Key Platforms

IBM Quantum (quantum.ibm.com): Free access to real devices with 127+ qubits. Based on the Qiskit SDK.

AWS Braket (aws.amazon.com/braket): Single API access to IonQ, Rigetti, D-Wave, and Amazon's own simulators.

Google Quantum AI (quantumai.google): Cirq framework, research collaboration access.

Azure Quantum (azure.microsoft.com/quantum): IonQ, Quantinuum, and Microsoft's topological qubit efforts.

Running on a Real IBM Quantum Device

from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2 as Sampler
from qiskit import QuantumCircuit
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager

# Initialize IBM Quantum service (requires API token)
# service = QiskitRuntimeService(channel="ibm_quantum", token="YOUR_TOKEN")
service = QiskitRuntimeService()

# Select the least busy real device
backend = service.least_busy(operational=True, simulator=False)
print(f"Backend: {backend.name}")
print(f"Qubits: {backend.num_qubits}")

# Prepare and transpile circuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()

pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuit = pm.run(qc)

# Run with Sampler primitive
sampler = Sampler(mode=backend)
job = sampler.run([isa_circuit], shots=1000)
result = job.result()
print(result[0].data.meas.get_counts())

AWS Braket Example

from braket.aws import AwsDevice
from braket.circuits import Circuit

circuit = Circuit()
circuit.h(0)
circuit.cnot(0, 1)
circuit.measure([0, 1])

device = AwsDevice("arn:aws:braket:::device/quantum-simulator/amazon/sv1")
task = device.run(circuit, shots=1000)
result = task.result()
print(result.measurement_counts)

10. Learning Roadmap and References

Learning Paths by Engineer Type

Software Engineers: Python → Qiskit basics → Quantum algorithms → QML with PennyLane

Electrical / Hardware Engineers: Quantum mechanics fundamentals → Physical qubit implementations → Circuit design → Error correction

AI / ML Engineers: Linear algebra deep dive → Quantum gates → PennyLane → Hybrid QML models

Essential References

  • Nielsen & Chuang, Quantum Computation and Quantum Information (Cambridge, 2000) — the field's bible
  • Qiskit documentation: qiskit.org
  • PennyLane documentation: pennylane.ai
  • IBM Quantum Learning: learning.quantum.ibm.com
  • arXiv quant-ph section: latest research preprints

Quiz

Q1. What is the fundamental difference between a qubit and a classical bit?

Answer: A qubit can exist in a superposition of 0 and 1 simultaneously before measurement. A classical bit is always definitively either 0 or 1.

Explanation: With n qubits representing 2^n states simultaneously, a 300-qubit system can process more states than there are atoms in the observable universe. This exponential parallelism is the core promise of quantum computing.

Q2. What state does the Hadamard gate produce when applied to |0>?

Answer: The plus state — an equal superposition where measuring yields 0 or 1 with 50% probability each.

Explanation: Mathematically expressed as (1/sqrt(2))(|0> + |1>). This state is the starting point for most quantum algorithms, as it creates the uniform superposition needed for quantum parallelism.

Q3. Why does Shor's algorithm threaten RSA encryption?

Answer: Shor's algorithm solves integer factorization in polynomial time O((log N)^3), while the best classical algorithm requires sub-exponential time. Since RSA security relies on the hardness of factoring large numbers, a fault-tolerant quantum computer would be able to break current RSA encryption.

Explanation: This has motivated NIST to standardize Post-Quantum Cryptography (PQC) algorithms in 2024, designed to be secure against quantum attacks.

Q4. What is the NISQ era and why does it matter for engineers?

Answer: NISQ (Noisy Intermediate-Scale Quantum) describes today's quantum computers — 50 to several thousand qubits with error rates too high for full error correction.

Explanation: NISQ devices are powerful enough to explore near-term applications (QAOA, VQE, QML) but not yet capable of running deep fault-tolerant algorithms like Shor's. Engineers building quantum applications today must design algorithms that tolerate noise and work within shallow circuit depths.

Q5. What is the barren plateau problem in quantum machine learning?

Answer: As the number of qubits and circuit depth increases, the gradients of a quantum neural network vanish exponentially, making training practically impossible.

Explanation: Similar to the vanishing gradient problem in classical deep learning. Mitigation strategies include using local cost functions, careful circuit architecture design, layer-wise pre-training, and identity block initialization.


Quantum computing is still in its NISQ era, but the pace of progress is remarkable. Start with Qiskit and PennyLane today, and you will be well positioned when fault-tolerant quantum computers become a practical reality. The future belongs to engineers who understand both the quantum and classical worlds.