QubitTürk · Quantum Science, Technology & AcademyQubitTürkAbout
Sign In / Join Free
SDKSDK Reference5 SDK · 8 Devre / Circuits

Quantum Programming & the Quantum Rosetta Stone

Inspect eight canonical quantum circuits and algorithms across OpenQASM 3.0, Qiskit, Cirq, PennyLane, and Modern Q#; verify exact mathematical state vectors and launch any blueprint directly inside the 16-qubit Qubit Lab.

8 CANONICAL CIRCUITS & ALGORITHMS

2 Qubits · Gate Depth: 2

Bell Entanglement Pair (|Φ⁺⟩)

Launch in Qubit Lab ↗

The canonical two-qubit circuit preparing the maximally entangled |Φ⁺⟩ Bell pair via a single Hadamard and CNOT gate. Each individual qubit has a maximally mixed reduced state (I/2), while joint Z-basis measurements yield perfectly correlated |00⟩ or |11⟩ outcomes.

STATE VECTOR / UNITARY FORM|Φ⁺⟩ = (|00⟩ + |11⟩) / √2 = CNOT₀,₁ (H ⊗ I)|00⟩

Engineering Note: Because |00⟩ and |11⟩ are bit-reversal symmetric, Qiskit's little-endian bit ordering and Cirq/PennyLane/Q#'s big-endian ordering produce identical output distributions.

bell-entanglement.pyQiskit >= 1.2 (QuantumCircuit + Statevector / SamplerV2)

Modern primitives-based circuit and statevector SDK for the IBM Quantum stack

from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler
from qiskit.quantum_info import Statevector

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

# Exact statevector inspection: (|00> + |11>) / sqrt(2)
psi = Statevector.from_instruction(qc)

# Shot-based execution via Qiskit V2 primitive (SamplerV2 interface)
qc_measured = qc.copy()
qc_measured.measure_all()
sampler = StatevectorSampler()
counts = sampler.run([qc_measured], shots=1024).result()[0].data.meas.get_counts()
print("Amplitudes:", psi.to_dict(), "Counts:", counts)

CIRCUIT BLUEPRINT MATRIX

Verified Quantum Circuit Templates

Quick-reference engineering matrix summarizing qubit register width, gate depth, analytical state forms, and direct Quirk studio presets.

Circuit / AlgorithmQubits & DepthMathematical FormActions
Bell Entanglement Pair (|Φ⁺⟩)2Q · d=2|Φ⁺⟩ = (|00⟩ + |11⟩) / √2 = CNOT₀,₁ (H ⊗ I)|00⟩
3-Qubit GHZ Tripartite Entanglement (|GHZ₃⟩)3Q · d=3|GHZ₃⟩ = (|000⟩ + |111⟩) / √2 = CNOT₁,₂ CNOT₀,₁ (H ⊗ I ⊗ I)|000⟩
Quantum State Teleportation3Q · d=6|ψ⟩₀ ⊗ |Φ⁺⟩₁₂ = ½ ∑_{a,b∈{0,1}} |a,b⟩₀₁ ⊗ (X^b Z^a)† |ψ⟩₂
Superdense Coding2Q · d=5(H ⊗ I) CNOT₀,₁ (Z^{b₁} X^{b₀} ⊗ I)|Φ⁺⟩ = |b₁ b₀⟩
Deutsch–Jozsa Algorithm (Phase Kickback & Interference)3Q · d=5(H^{⊗n} ⊗ I) U_f (H^{⊗n}|0⟩^{⊗n} ⊗ |−⟩) ──► P(|0⟩^{⊗n}) = |2^{-n} ∑_{x} (−1)^{f(x)}|²
3-Qubit Grover Search (Phase Oracle + Diffusion)3Q · d=15G^k |s⟩ = ((2|s⟩⟨s| − I) U_ω)^k H^{⊗3}|000⟩, P(|101⟩)_{k=2} = sin²(5θ) = 121/128 ≈ 0.9453
4-Qubit Quantum Fourier Transform (QFT₄)4Q · d=10QFT₁₆|x⟩ = ¼ ∑_{k=0}^{15} e^{2πi x k / 16}|k⟩ = ⨂_{j=0}^{3} (|0⟩ + e^{2πi · 0.x_{3-j}…x_3}|1⟩) / √2
3-Qubit Bit-Flip Syndrome Error Correction ([3, 1, 3] QEC)5Q · d=9|ψ_L⟩ = α|000⟩ + β|111⟩, S = ⟨Z₀Z₁, Z₁Z₂⟩ ──► (s₀, s₁) ∈ {(0,0)→I, (1,0)→X₀, (1,1)→X₁, (0,1)→X₂}

OPEN-SOURCE QUANTUM SOFTWARE STACK

SDK & Library Developer Reference Guides

Architectural paradigms, SPDX open-source licenses, installation commands, hardware backends, and runnable quickstart examples for six foundational quantum SDKs.

SDKSDK ReferenceApache-2.0Python (Rust-accelerated core)

Qiskit

Circuit Compilation, V2 Primitives (SamplerV2 / EstimatorV2) & Hardware Transpilation

Maintainer: IBM Quantum & Open-Source Contributors

Industry-standard open-source quantum SDK initiated by IBM Quantum with a Rust-accelerated transpiler core. Modern Qiskit 1.x/2.x replaces legacy backend execution with standardized SamplerV2 (bitstring distributions) and EstimatorV2 (Pauli observable expectation values) primitives.

$ pip install qiskit qiskit-aer

Key Engineering Strengths

  • Rust-backed multi-pass transpiler with SABRE qubit routing, layout synthesis, and unitary gate cancellation
  • First-class dynamic circuits (if_test, while_loop, switch) and bidirectional OpenQASM 3.0 serialization
  • Comprehensive operator algebra (qiskit.quantum_info) and error-mitigation workflows viaV2 primitives

Hardware Ecosystem: IBM Quantum superconducting processors (Heron, Eagle) plus IonQ, Quantinuum, IQM, Rigetti, and AQT backends through community provider packages.

Show Runnable Quickstart Snippet
from qiskit import QuantumCircuit
from qiskit.quantum_info import SparsePauliOp
from qiskit.primitives import StatevectorEstimator

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

zz = SparsePauliOp.from_list([("ZZ", 1.0), ("XX", 1.0)])
ev = StatevectorEstimator().run([(qc, zz)]).result()[0].data.evs
print("<ZZ + XX> on |Phi+> =", float(ev))  # 2.0
SDKSDK ReferenceApache-2.0Python

Cirq

Moment-Scheduled NISQ & Surface-Code Circuit Engineering

Maintainer: Google Quantum AI

Python framework engineered by Google Quantum AI to expose processor lattice geometry (GridQubit / LineQubit), explicit parallel gate slices (Moments), and realistic Kraus/depolarizing noise models.

$ pip install cirq

Key Engineering Strengths

  • Explicit Moment time-slice scheduling and native 2D lattice placement via cirq.GridQubit
  • Fine-grained Kraus channel, readout error, and DensityMatrixSimulator noise modeling
  • Seamless interoperability with Stim (QEC), OpenFermion (chemistry), and Qualtran (fault-tolerant algorithms)

Hardware Ecosystem: Google Quantum AI superconducting processors (Sycamore, Willow) alongside IonQ, Pasqal neutral-atom arrays, Rigetti, and AQT trapped-ion devices.

Show Runnable Quickstart Snippet
import cirq

qubits = cirq.GridQubit.rect(1, 2)
noisy_bell = cirq.Circuit(
    cirq.H(qubits[0]),
    cirq.CNOT(qubits[0], qubits[1]),
).with_noise(cirq.depolarize(p=0.005))

rho = cirq.DensityMatrixSimulator().simulate(noisy_bell).final_density_matrix
print("Purity Tr(rho^2):", float((rho @ rho).trace().real))
SDKSDK ReferenceApache-2.0Python / C++ (Lightning & Catalyst JIT)

PennyLane

Differentiable Quantum Programming & Hybrid Quantum-Classical Computing

Maintainer: Xanadu Quantum Technologies

Treats parameterized quantum circuits (@qml.qnode) as first-class differentiable functions compatible with JAX, PyTorch, and NumPy. Combines analytic parameter-shift gradients, adjoint differentiation, quantum chemistry Hamiltonians, and MLIR-based Catalyst JIT compilation.

$ pip install pennylane

Key Engineering Strengths

  • Hardware-compatible analytic parameter-shift rules and fast simulator adjoint differentiation with JAX and PyTorch
  • Built-in quantum chemistry Hamiltonian builders (qml.qchem), Trotterization, and block-encoding primitives
  • Unified plugin interface switching cleanly between lightning.qubit/gpu simulators and cloud QPU backends

Hardware Ecosystem: Xanadu photonic hardware, Amazon Braket (QuEra, IonQ, Rigetti, IQM), IBM Quantum, Azure Quantum, and GPU-accelerated Lightning / CUDA-Q backends.

Show Runnable Quickstart Snippet
import pennylane as qml
from pennylane import numpy as np

dev = qml.device("default.qubit", wires=1)

@qml.qnode(dev)
def cost(theta):
    qml.RX(theta, wires=0)
    return qml.expval(qml.PauliZ(0))

grad_fn = qml.grad(cost)
print("d<Z>/dtheta at pi/2 =", float(grad_fn(np.array(np.pi / 2, requires_grad=True))))
SDKSDK ReferenceMITQ# (Rust/WASM compiler core + Python bindings)

Q# / Azure Quantum Development Kit

Fault-Tolerant Algorithm Design, QIR Compilation & Resource Estimation

Maintainer: Microsoft Quantum

Domain-specific quantum programming language featuring automatic Adjoint and Controlled functor synthesis, within-apply uncomputation blocks, and LLVM-based Quantum Intermediate Representation (QIR) generation via a lightweight Rust compiler.

$ pip install qsharp

Key Engineering Strengths

  • Compiler-synthesized Adjoint and Controlled unitary functors plus safe ancilla uncomputation via within { ... } apply { ... }
  • Integrated Fault-Tolerant Resource Estimator computing physical qubits, surface-code distances, and T-factory footprints
  • Standards-based Quantum Intermediate Representation (QIR) emission and zero-dependency Rust/WASM execution

Hardware Ecosystem: Azure Quantum hardware targets including Quantinuum H-Series trapped ions, IonQ, Rigetti, Pasqal, Atom Computing, and QIR-compliant control stacks.

Show Runnable Quickstart Snippet
import qsharp

qsharp.eval("""
operation ApplyControlledPhaseKick(ctrl : Qubit, target : Qubit) : Unit is Adj + Ctl {
    within { H(target); }
    apply { Controlled Z([ctrl], target); }
}
""")
out = qsharp.run("{ use (a, b) = (Qubit(), Qubit()); X(a); ApplyControlledPhaseKick(a, b); MResetZ(b) }", shots=8)
print("Deterministic kickback outcomes:", out)
SDKSDK ReferenceApache-2.0OpenQASM 3.0 Grammar (ANTLR4 / Rust & Python AST parsers)

OpenQASM 3.0

Vendor-Neutral Quantum Assembly & Real-Time Classical Control Specification

Maintainer: OpenQASM Technical Steering Committee (Linux Foundation)

Open specification governed under the Linux Foundation that extends static quantum assembly into a full real-time quantum-classical language supporting typed classical variables, loops, low-latency mid-circuit conditionals, timing boxes, and pulse-level defcal blocks.

$ pip install openqasm3

Key Engineering Strengths

  • Portable circuit interchange format across Qiskit, Cirq, PennyLane, Quantinuum TKET, and cloud hardware providers
  • Native sub-coherence-time classical control flow (if/else, for, while) essential for active QEC and repeat-until-success protocols
  • Multi-level abstraction spanning unitary gates, duration-constrained timing boxes, and hardware defcal pulse schedules

Hardware Ecosystem: IBM Quantum, Amazon Braket, Quantinuum TKET, FPGA/AWG quantum control systems (Zurich Instruments, Qblox), and cross-SDK transpilers.

Show Runnable Quickstart Snippet
OPENQASM 3.0;
include "stdgates.inc";

// Repeat-until-success state reset using real-time control flow
qubit q;
bit m = 1;

h q;
m = measure q;
if (m == 1) {
  x q;
}
SDKSDK ReferenceApache-2.0C++ (SIMD AVX2/SSE2) with Python API

Stim

High-Speed Stabilizer Circuit & Quantum Error Correction Simulator

Maintainer: Craig Gidney (Google Quantum AI)

Authored by Craig Gidney (Quantum 5, 497, 2021), Stim exploits Gottesman–Knill stabilizer tableaux and 256-bit SIMD bit-packing to sample noisy thousand-qubit surface-code and qLDPC syndrome circuits at megahertz shot rates—orders of magnitude faster than statevector simulators.

$ pip install stim pymatching

Key Engineering Strengths

  • Built-in noisy circuit generators for rotated surface codes, color codes, and repetition codes under circuit-level Pauli noise
  • Automatic Detector Error Model (DEM) extraction feeding directly into PyMatching minimum-weight perfect matching decoders
  • Simulates thousands of Clifford qubits and millions of syndrome rounds in seconds on a single CPU core

Hardware Ecosystem: De facto standard QEC benchmarking and syndrome-decoding backbone across superconducting (Google Willow, IBM), neutral-atom (QuEra/Harvard), and trapped-ion fault-tolerance research.

Show Runnable Quickstart Snippet
import stim
import pymatching

circuit = stim.Circuit.generated(
    "surface_code:rotated_memory_z",
    distance=5,
    rounds=5,
    after_clifford_depolarization=0.002,
)
matcher = pymatching.Matching.from_detector_error_model(circuit.detector_error_model(decompose_errors=True))
syndromes, actual_obs = circuit.compile_detector_sampler().sample(shots=10_000, separate_observables=True)
predicted_obs = matcher.decode_batch(syndromes)
print("Logical error rate (d=5, p=0.2%):", float((predicted_obs != actual_obs).mean()))