Split View: 양자 컴퓨팅 입문: 엔지니어를 위한 큐비트부터 양자 머신러닝까지
양자 컴퓨팅 입문: 엔지니어를 위한 큐비트부터 양자 머신러닝까지
1. 양자 컴퓨팅이란?
양자 컴퓨팅은 양자역학의 원리(중첩, 얽힘, 간섭)를 활용하여 고전 컴퓨터로는 현실적으로 풀기 어려운 문제를 해결하는 컴퓨팅 패러다임입니다.
고전 컴퓨터 vs 양자 컴퓨터
| 항목 | 고전 컴퓨터 | 양자 컴퓨터 |
|---|---|---|
| 기본 단위 | 비트 (0 또는 1) | 큐비트 (0, 1, 또는 중첩) |
| 연산 방식 | 직렬/병렬 논리 게이트 | 양자 게이트 (유니터리 변환) |
| 상태 공간 | n비트 = 2^n 상태 중 하나 | n큐비트 = 2^n 상태 동시 표현 |
| 오류 특성 | 결정론적, 예측 가능 | 확률론적, 디코히어런스 취약 |
| 최적 적용 | 범용 연산, 정보 처리 | 최적화, 양자 시뮬레이션, 암호 |
n개의 큐비트는 개의 상태를 동시에 표현할 수 있습니다. 300큐비트 시스템은 우주의 원자 수보다 많은 상태를 동시에 처리할 수 있습니다.
왜 양자 컴퓨팅이 중요한가?
양자 컴퓨팅은 다음 분야에서 혁신적 돌파구를 제공합니다.
- 암호학: Shor 알고리즘은 RSA 암호화의 기반인 소인수분해 문제를 다항 시간에 해결합니다. 현재 2048비트 RSA 키는 고전 컴퓨터로 수백만 년이 걸리지만, 충분한 큐비트를 갖춘 양자 컴퓨터로는 몇 시간 내 해결 가능합니다.
- 신약 개발: 분자 시뮬레이션은 고전 컴퓨터의 지수적 복잡도 한계를 극복하여, 신물질 설계와 단백질 폴딩 예측을 가속화합니다.
- 최적화: 물류, 금융 포트폴리오, 스케줄링 등 NP-hard 문제에서 QAOA 등 양자 알고리즘이 우위를 보입니다.
- AI/머신러닝: 양자 커널, 양자 신경망은 특정 데이터셋에서 고전 ML보다 높은 표현력을 가질 수 있습니다.
양자 우위 vs 양자 패권
양자 패권(Quantum Supremacy): 어떤 고전 컴퓨터도 현실적 시간 내에 수행할 수 없는 작업을 양자 컴퓨터가 수행하는 순간. 2019년 Google의 Sycamore 프로세서가 53큐비트로 특정 샘플링 문제를 200초 내에 해결했으며, 이는 당시 최고의 슈퍼컴퓨터로 1만 년이 걸릴 작업이었습니다.
양자 우위(Quantum Advantage): 실용적으로 유용한 문제에서 양자 컴퓨터가 고전 컴퓨터보다 명확히 빠른 경우. 패권보다 더 높은 실질적 기준입니다.
NISQ 시대
현재는 NISQ(Noisy Intermediate-Scale Quantum) 시대입니다. 50~1000큐비트 규모의 기기가 존재하지만 오류율이 높고 큐비트 코히어런스 시간이 짧습니다. 완전한 오류 정정(Fault-Tolerant Quantum Computing)을 위해서는 수백만 물리적 큐비트가 필요하며, 이는 2030년대 이후를 목표로 하고 있습니다.
2. 큐비트 (Qubit)
큐비트의 물리적 구현
| 방식 | 원리 | 대표 기업 | 특징 |
|---|---|---|---|
| 초전도 큐비트 | 조셉슨 접합, 극저온 냉각 | IBM, Google | 제조 용이, 빠른 게이트 |
| 이온 트랩 | 레이저로 이온 제어 | IonQ, Quantinuum | 높은 피델리티, 느린 게이트 |
| 광자 큐비트 | 광자 편광/경로 | PsiQuantum | 상온 동작, 연결성 제한 |
| 위상 큐비트 | 마요라나 입자 | Microsoft | 이론적 오류 내성 |
| 실리콘 스핀 | 전자 스핀 | Intel | CMOS 호환 |
중첩(Superposition)
큐비트는 측정 전까지 0과 1의 중첩 상태에 있습니다.
여기서 와 는 복소수 진폭(amplitude)이며, 규격화 조건 을 만족합니다.
측정 확률은 다음과 같습니다.
예를 들어 이면 각 상태가 50% 확률로 측정됩니다. 이것이 Hadamard 게이트가 만드는 상태입니다.
블로흐 구(Bloch Sphere) 표현
큐비트 상태는 단위 구(블로흐 구) 위의 점으로 표현됩니다.
- : 북극 =
- : 남극 =
- 적도: 중첩 상태 (예: )
디코히어런스(Decoherence) 문제
큐비트는 환경(열, 전자기파, 진동)과 상호작용하면 중첩 상태를 잃어버립니다. 이를 디코히어런스라 합니다. 현재 초전도 큐비트의 코히어런스 시간은 수십~수백 마이크로초 수준입니다. 오류 정정 없이는 깊은(deep) 회로를 실행하기 어렵습니다.
3. 양자 게이트 (Quantum Gates)
양자 게이트는 유니터리 행렬 로 표현되며 를 만족합니다. 고전 게이트와 달리 모든 양자 게이트는 가역적(reversible)입니다.
주요 단일 큐비트 게이트
Pauli 게이트
- X 게이트: 고전 NOT 게이트에 해당. ,
- Z 게이트: 위상 플립. 에 위상 적용
Hadamard 게이트
로 중첩 상태를 생성합니다.
S, T 게이트 (위상 게이트)
회전 게이트
블로흐 구에서 각 축을 중심으로 회전합니다.
변분 양자 알고리즘(VQA)에서 학습 가능한 파라미터로 사용됩니다.
2큐비트 게이트
CNOT (Controlled-NOT)
제어 큐비트가 일 때 타깃 큐비트를 X 게이트로 플립합니다.
CNOT은 얽힘 생성의 핵심 게이트입니다.
3큐비트: Toffoli (CCNOT) — 두 제어 큐비트가 모두 일 때 타깃을 플립. 양자 회로에서 범용성(universality) 을 보장합니다.
Qiskit으로 Bell 상태 생성
from qiskit import QuantumCircuit
from qiskit_aer import AerSimulator
# Bell 상태 생성 (양자 얽힘)
qc = QuantumCircuit(2, 2)
qc.h(0) # Hadamard 게이트: 큐비트 0을 중첩 상태로
qc.cx(0, 1) # CNOT 게이트: 큐비트 0(제어), 1(타깃) 얽힘 생성
qc.measure([0, 1], [0, 1])
# 회로 출력
print(qc.draw())
# 시뮬레이션 실행
simulator = AerSimulator()
job = simulator.run(qc, shots=1000)
result = job.result()
counts = result.get_counts()
print("측정 결과:", counts)
# 예상 출력: {'00': ~500, '11': ~500}
# 01, 10은 나타나지 않음 → 완전한 얽힘 상태
Bell 상태 는 두 큐비트가 완전히 얽혀 있어, 하나를 측정하면 다른 하나의 상태가 즉시 결정됩니다.
4. 양자 회로 (Quantum Circuits)
상태벡터 시뮬레이션
n큐비트 시스템의 상태는 차원 복소 벡터로 표현됩니다.
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>와 |11>이 각 50% 진폭
GHZ 상태 (3큐비트 얽힘)
GHZ(Greenberger-Horne-Zeilinger) 상태는 3큐비트 최대 얽힘 상태입니다.
qc = QuantumCircuit(3)
qc.h(0)
qc.cx(0, 1)
qc.cx(0, 2)
print(qc.draw())
양자 텔레포테이션 프로토콜
양자 텔레포테이션은 물리적 큐비트를 전송하지 않고, 양자 상태를 고전 통신 채널을 통해 전달하는 프로토콜입니다.
- Alice와 Bob이 Bell 쌍을 공유합니다.
- Alice가 전송할 큐비트와 자신의 Bell 큐비트에 CNOT + H를 적용합니다.
- Alice가 2큐비트를 측정하고 결과(2비트 고전 정보)를 Bob에게 전달합니다.
- Bob이 고전 정보에 따라 X, Z 보정을 적용하면 Alice의 원래 상태를 복원합니다.
양자 오류 정정(QEC) 개요
물리적 큐비트에는 비트 플립, 위상 플립 오류가 발생합니다. 오류 정정 코드(Shor Code, Steane Code, Surface Code)는 여러 물리적 큐비트로 하나의 논리적 큐비트를 인코딩합니다. Surface Code는 가장 유망한 방식으로, 논리적 큐비트 하나에 수백~수천 물리적 큐비트가 필요합니다.
5. 대표 양자 알고리즘
Deutsch-Jozsa 알고리즘
함수 이 상수 함수인지 균형 함수인지를 단 1번의 쿼리로 판별합니다. 고전 알고리즘은 최악의 경우 번의 쿼리가 필요합니다. 최초의 양자 우위 증명 알고리즘입니다.
Grover 검색 알고리즘
비구조화 데이터베이스 N개 항목 중 타깃을 찾는 문제를 쿼리로 해결합니다. 고전 최적은 이므로, 약 제곱근 배속입니다.
from qiskit.circuit.library import GroverOperator
from qiskit import QuantumCircuit
from qiskit_aer import AerSimulator
# 2큐비트 Grover 검색 (타깃: |11>)
oracle = QuantumCircuit(2)
oracle.cz(0, 1) # |11> 상태에 위상 -1 적용 (오라클)
grover_op = GroverOperator(oracle)
qc = QuantumCircuit(2)
qc.h([0, 1]) # 균일 중첩
qc.compose(grover_op, inplace=True) # Grover 반복
qc.measure_all()
simulator = AerSimulator()
job = simulator.run(qc, shots=1000)
result = job.result()
print(result.get_counts())
# |11>이 높은 확률로 나타남
Shor 소인수분해 알고리즘
N을 두 소수의 곱으로 분해하는 문제를 다항 시간에 해결합니다. 고전 최선 알고리즘(GNFS)의 준지수 복잡도 보다 지수적으로 빠릅니다.
이것이 현재 인터넷 보안의 근간인 RSA, ECC 암호를 위협하는 이유입니다. 이에 대응하여 NIST는 양자 내성 암호(PQC: Post-Quantum Cryptography) 표준을 2024년 발표했습니다.
Quantum Fourier Transform (QFT)
이산 푸리에 변환(DFT)을 양자 게이트로 수행합니다. 고전 FFT의 에 비해 지수적 효율. Shor 알고리즘, 위상 추정(Phase Estimation) 등의 핵심 서브루틴입니다.
QAOA (Quantum Approximate Optimization Algorithm)
조합 최적화 문제(Max-Cut, TSP, 스케줄링)를 근사적으로 해결하는 변분 양자 알고리즘입니다. 고전 최적화기와 양자 회로를 하이브리드로 운용합니다.
6. 양자 오류와 노이즈
주요 오류 유형
비트 플립 오류: 또는 로의 의도치 않은 전환. X 채널 노이즈.
위상 플립 오류: 로의 위상 변화. Z 채널 노이즈.
디포라이징 채널: 가장 일반적인 노이즈 모델. 확률 로 X, Y, Z 오류 중 하나가 무작위 적용됩니다.
게이트 피델리티
현재 NISQ 기기의 대표적 오류율:
| 연산 | 대표 오류율 |
|---|---|
| 단일 큐비트 게이트 | 0.1% 미만 |
| 2큐비트 CNOT 게이트 | 0.5~1% |
| 측정(Readout) | 1~2% |
| T1 코히어런스 시간 | 100~500 마이크로초 |
Qiskit으로 노이즈 시뮬레이션
from qiskit_aer.noise import NoiseModel, depolarizing_error
from qiskit_aer import AerSimulator
from qiskit import QuantumCircuit
# 노이즈 모델 생성
noise_model = NoiseModel()
error_1q = depolarizing_error(0.001, 1) # 단일 큐비트 0.1% 오류
error_2q = depolarizing_error(0.01, 2) # 2큐비트 1% 오류
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())
# 이상적: {'00': 500, '11': 500}
# 노이즈 포함: '01', '10'도 소량 등장
7. 양자 머신러닝 (QML)
변분 양자 알고리즘 (VQA)
VQA는 파라미터화된 양자 회로(PQC)를 고전 최적화기로 훈련하는 하이브리드 방식입니다.
- VQE (Variational Quantum Eigensolver): 분자 에너지 최소화
- QAOA: 조합 최적화
- QNN: 분류/회귀 학습
데이터 인코딩 방식
| 방법 | 설명 | 큐비트 수 |
|---|---|---|
| 각도 인코딩 | 로 각 데이터 특징 인코딩 | N 특징 = N 큐비트 |
| 진폭 인코딩 | 상태벡터 진폭으로 인코딩 | 큐비트 |
| 기저 인코딩 | 이진 표현으로 계산 기저에 인코딩 | N 비트 = N 큐비트 |
PennyLane으로 QNN 구현
import pennylane as qml
import numpy as np
dev = qml.device('default.qubit', wires=2)
@qml.qnode(dev)
def quantum_circuit(x, weights):
# 각도 인코딩
qml.AngleEmbedding(x, wires=[0, 1])
# 변분 레이어 (얽힘 포함)
qml.BasicEntanglerLayers(weights, wires=[0, 1])
return qml.expval(qml.PauliZ(0))
# 데이터 및 초기 가중치
x = np.array([0.5, 0.3])
weights = np.random.random((3, 2)) # 3 레이어, 2 와이어
result = quantum_circuit(x, weights)
print(f"기대값: {result:.4f}")
# 그래디언트 계산 (Parameter-Shift Rule)
grad_fn = qml.grad(quantum_circuit, argnum=1)
gradients = grad_fn(x, weights)
print(f"그래디언트: {gradients}")
양자 커널 방법
서포트 벡터 머신(SVM)에서 고전 커널 대신 양자 회로로 특징 맵을 구성합니다.
고전 컴퓨터로 계산하기 어려운 고차원 힐베르트 공간에서의 내적을 양자 컴퓨터가 효율적으로 계산합니다.
현재 QML의 한계
- 바렌 플래토(Barren Plateau): 큐비트 수 증가에 따라 그래디언트가 지수적으로 소멸하는 현상
- 데이터 업로딩 병목: 고전 데이터를 양자 상태로 인코딩하는 비용이 큼
- NISQ 노이즈: 깊은 회로 실행이 어려워 표현력 제한
8. 양자 하드웨어 현황 (2026년)
주요 플랫폼 비교
| 기업 | 방식 | 최대 큐비트 | 특징 |
|---|---|---|---|
| IBM Quantum | 초전도 | Condor 1121큐비트 | 클라우드 접근, 오픈소스 Qiskit |
| 초전도 | Willow 105큐비트 | 오류 정정 이정표 달성 | |
| IonQ | 이온 트랩 | 36 알고리즘 큐비트 | 높은 피델리티 |
| Quantinuum | 이온 트랩 | H2 56큐비트 | TPCP 연산 우수 |
| D-Wave | 양자 어닐링 | 5000+ 큐비트 | 최적화 특화 |
2025년 말 Google은 Willow 칩으로 기존 기준 계산을 증명하였고, IBM은 2025년까지 100,000 큐비트를 목표로 합니다.
2026 로드맵 요약
- 현재: NISQ, 100
1000 물리 큐비트, 오류율 0.11% - 2027~2029: 초기 오류 정정, 수천 물리 큐비트 → 수십 논리 큐비트
- 2030+: 완전 내결함성 양자 컴퓨터, 수백만 물리 큐비트 목표
9. 양자 클라우드 접근
주요 플랫폼
IBM Quantum Experience (quantum.ibm.com): 무료로 127큐비트 이상 실제 기기 접근 가능. Qiskit SDK 기반.
AWS Braket (aws.amazon.com/braket): IonQ, Rigetti, D-Wave 등 다양한 하드웨어를 단일 API로 접근.
Google Quantum AI (quantumai.google): Cirq 프레임워크, 연구 협업 접근.
Azure Quantum (azure.microsoft.com/quantum): IonQ, Quantinuum, Microsoft 토폴로지컬 큐비트.
IBM Quantum 실제 기기 실행
from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2 as Sampler
from qiskit import QuantumCircuit
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
# IBM Quantum 서비스 초기화 (API 토큰 필요)
# service = QiskitRuntimeService(channel="ibm_quantum", token="YOUR_TOKEN")
service = QiskitRuntimeService()
# 가장 한가한 실제 기기 선택
backend = service.least_busy(operational=True, simulator=False)
print(f"사용 백엔드: {backend.name}")
print(f"큐비트 수: {backend.num_qubits}")
# 회로 준비 및 트랜스파일
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)
# Sampler 실행
sampler = Sampler(mode=backend)
job = sampler.run([isa_circuit], shots=1000)
result = job.result()
print(result[0].data.meas.get_counts())
AWS Braket 예제
from braket.aws import AwsDevice
from braket.circuits import Circuit
# AWS Braket 회로
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. 학습 로드맵과 참고 자료
엔지니어별 학습 경로
소프트웨어 엔지니어: Python → Qiskit 기초 → 양자 알고리즘 → QML (PennyLane)
전기/하드웨어 엔지니어: 양자역학 기초 → 큐비트 물리 구현 → 회로 설계 → 오류 정정
AI/ML 엔지니어: 선형대수 강화 → 양자 게이트 이해 → PennyLane → Hybrid QML
필수 참고 자료
- Nielsen & Chuang, Quantum Computation and Quantum Information (Cambridge, 2000) — 분야의 바이블
- Qiskit 공식 문서: qiskit.org
- PennyLane 공식 문서: pennylane.ai
- IBM Quantum Learning: learning.quantum.ibm.com
- arXiv quant-ph 섹션: 최신 연구 논문
퀴즈
Q1. 큐비트와 고전 비트의 가장 큰 차이점은?
정답: 큐비트는 측정 전까지 0과 1의 중첩(superposition) 상태를 동시에 가질 수 있습니다. 고전 비트는 항상 0 또는 1 중 하나입니다.
설명: n큐비트는 2^n개의 상태를 동시에 표현하므로, n=300이면 우주의 원자 수보다 많은 상태를 동시에 처리할 수 있습니다.
Q2. Hadamard 게이트가 |0>에 적용되면 어떤 상태가 되나요?
정답: 플러스 상태, 즉 0과 1이 각각 50% 확률로 측정되는 균등 중첩 상태가 됩니다.
설명: 수식으로는 (1/sqrt(2))(|0> + |1>)로 표현됩니다. 이 상태에서 측정하면 0 또는 1이 동일 확률로 나타납니다. 양자 알고리즘의 시작점으로 자주 사용됩니다.
Q3. Shor 알고리즘이 RSA 암호에 위협이 되는 이유는?
정답: Shor 알고리즘은 큰 수의 소인수분해를 **다항 시간 O((log N)^3)**에 해결합니다. RSA는 소인수분해의 어려움에 기반하므로, 충분한 큐비트의 양자 컴퓨터가 완성되면 현재 RSA 암호는 해독될 수 있습니다.
설명: 고전 컴퓨터 최선 알고리즘은 준지수 시간이 필요합니다. 이 때문에 NIST는 양자 내성 암호(PQC) 표준을 2024년 발표했습니다.
Q4. NISQ(Noisy Intermediate-Scale Quantum) 시대란 무엇인가요?
정답: 현재 양자 컴퓨터의 발전 단계로, 50~수천 큐비트를 보유하지만 오류율이 높아 완전한 오류 정정이 불가능한 시기입니다.
설명: NISQ 기기는 제한적 알고리즘에서 유용성을 보여주고 있지만, 본격적인 양자 우위를 위해서는 오류 정정이 필요합니다. 완전한 내결함성 양자 컴퓨터는 2030년대 이후를 목표로 합니다.
Q5. 양자 머신러닝의 바렌 플래토 문제란?
정답: 큐비트 수가 증가할수록 양자 신경망의 그래디언트가 지수적으로 0에 수렴하여 학습이 불가능해지는 현상입니다.
설명: 고전 딥러닝의 기울기 소실(vanishing gradient) 문제와 유사합니다. 레이어 구조 설계, 지역 비용 함수 활용, 사전 훈련 기법 등으로 완화를 시도하고 있습니다.
양자 컴퓨팅은 아직 NISQ 시대에 있지만, 그 발전 속도는 매우 빠릅니다. 지금 Qiskit과 PennyLane으로 시작하면, 양자 컴퓨팅이 실용화되는 시대에 충분한 전문성을 갖출 수 있습니다. 큐비트를 직접 다루며 미래를 준비해 보세요.
Quantum Computing for Engineers: From Qubits to Quantum Machine Learning
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
| Aspect | Classical Computer | Quantum Computer |
|---|---|---|
| Basic unit | Bit (0 or 1) | Qubit (0, 1, or superposition) |
| Operations | Sequential/parallel logic gates | Quantum gates (unitary transformations) |
| State space | n bits = one of 2^n states | n qubits = 2^n states simultaneously |
| Error characteristics | Deterministic, predictable | Probabilistic, decoherence-prone |
| Best suited for | General-purpose computation | Optimization, quantum simulation, cryptography |
With n qubits representing 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
| Technology | Principle | Key Companies | Characteristics |
|---|---|---|---|
| Superconducting | Josephson junction, cryogenic cooling | IBM, Google | Easy to fabricate, fast gates |
| Trapped ion | Laser-controlled ions | IonQ, Quantinuum | High fidelity, slower gates |
| Photonic | Photon polarization/path | PsiQuantum | Room temperature, limited connectivity |
| Topological | Majorana fermions | Microsoft | Theoretically error-resilient |
| Silicon spin | Electron spin | Intel | CMOS-compatible |
Superposition
Before measurement, a qubit exists in a superposition of 0 and 1:
where and are complex amplitudes satisfying the normalization condition .
Measurement probabilities are:
When and , 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):
- : North pole =
- : South pole =
- Equator: Superposition states (e.g., )
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 satisfying . Unlike classical logic gates, all quantum gates are reversible.
Single-Qubit Gates
Pauli Gates
- X gate: Quantum NOT. ,
- Z gate: Phase flip. Applies phase to
Hadamard Gate
Transforms , creating a uniform superposition.
S and T Gates (Phase gates)
Rotation Gates
These serve as trainable parameters in variational quantum algorithms.
Two-Qubit Gates
CNOT (Controlled-NOT): Flips the target qubit when the control qubit is .
Toffoli (CCNOT): Three-qubit gate. Flips target when both control qubits are . 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 . 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 -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:
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:
- Alice and Bob share a Bell pair.
- Alice applies CNOT and H to her qubit and the Bell qubit.
- Alice measures her 2 qubits and sends 2 classical bits to Bob.
- 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 is constant or balanced in exactly 1 query. Classically, worst case requires queries. This was the first proof of quantum advantage.
Grover's Search Algorithm
Finds a target in an unsorted database of N items in queries. Classical brute-force requires , 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 polynomial time. The best classical algorithm (GNFS) runs in sub-exponential time , 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 quantum gates, exponentially faster than classical FFT at . 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: or — an unintended X channel flip.
Phase-flip error: — a Z channel phase change.
Depolarizing channel: The most common noise model. With probability , one of X, Y, or Z is applied randomly:
Gate Fidelity on Current NISQ Devices
| Operation | Typical Error Rate |
|---|---|
| Single-qubit gate | Below 0.1% |
| Two-qubit CNOT gate | 0.5–1% |
| Readout | 1–2% |
| T1 coherence time | 100–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:
Key variants:
- VQE (Variational Quantum Eigensolver): Molecular energy minimization
- QAOA: Combinatorial optimization
- QNN: Classification and regression
Data Encoding Strategies
| Method | Description | Qubit Cost |
|---|---|---|
| Angle encoding | Each feature encoded as Ry rotation angle | N features = N qubits |
| Amplitude encoding | Features stored in state vector amplitudes | log2(N) qubits |
| Basis encoding | Binary representation in computational basis | N 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:
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
| Company | Technology | Max Qubits | Highlights |
|---|---|---|---|
| IBM Quantum | Superconducting | Condor 1121 qubits | Cloud access, open-source Qiskit |
| Superconducting | Willow 105 qubits | Error correction milestone | |
| IonQ | Trapped ion | 36 algorithmic qubits | High fidelity |
| Quantinuum | Trapped ion | H2 56 qubits | Excellent TPCP operations |
| D-Wave | Quantum annealing | 5000+ qubits | Optimization-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.