How qiskit/qiskit-aer works
Project Type and Purpose
• This is Qiskit Aer, a high-performance quantum circuit simulator library for Qiskit.
• It provides both a Python API (via pybind11) and a C++ core with multiple simulation methods (statevector, density matrix, stabilizer, MPS, tensor network, etc.), plus realistic noise models and GPU acceleration.
File-Tree Analysis & Key Architectural Layers
• Top-level Python package (“qiskit_aer/…”) implements the user-facing API: AerSimulator, backends, noise models, primitives (Estimator, Sampler).
• “src/…” contains the C++ simulation core, subdivided into:
• framework/ – shared data types, JSON parsers, results, linear-algebra abstractions
• simulators/ – concrete simulators (statevector, density matrix, stabilizer, MPS, superoperator, tensor network, unitary)
• noise/ – noise model definitions & passes
• controllers/ – orchestration of shots, chunking, parallel execution
• transpile/ – circuit optimizations (fusion, cache blocking)
• Build and packaging: CMakeLists.txt, cmake/ scripts, conan integration, pyproject.toml / setup.py.
• Third-party libs: BLAS/LAPACK, Thrust, cuStateVec, cuTensorNet for GPUs.
• Tests and CI: Python tests under test/, GitHub workflows for build, tests, docs.
1. Python API Layer
– qiskit_aer package: AerSimulator, backends, primitives, noise-model wrappers.
2. pybind11 Binding Layer
– glue code in qiskit_aer/backends/wrappers & framework/pybind_*.hpp
3. C++ Core
– Framework Module
– Simulator Modules (statevector, density matrix, stabilizer, MPS, superop, tensor network, unitary)
– Noise Module (device models, errors, passes)
– Controller Module (batch executor, parallel executor)
– Transpiler Module (circuit optimizations)
4. External Libraries & Hardware
– BLAS/LAPACK (host CPU)
– CUDA/cuStateVec/cuTensorNet (GPU)
– Thrust (GPU abstractions)
5. Qiskit Terra (upstream circuit & transpile provider)
6. IBM Quantum Backends (for noise-model extraction in runtime)
b. Relationships & Data Flows
• Qiskit Terra → (Circuit) → Qiskit Aer Python API
• Python API → (pybind calls) → C++ Core
• C++ Core → (function calls) → Linear algebra & GPU libraries
• C++ Core → (execute circuits) → Simulator modules produce Results
• Results → (pybind return) → Python API → User
• Python API .from_backend(...) → IBM Quantum → noise model data
c. Architectural Patterns & Principles
• Layered architecture: clear separation of Python API, binding layer, and native core.
• Modular simulator backends: each simulation method is a pluggable component.
• Strategy pattern in controllers: different executors choose shot handling strategy.
• Separation of concerns: framework vs. simulators vs. noise vs. transpile.
• Plugin-style external-library integration (BLAS, CUDA).
d. Key Technologies & Frameworks
• Python: pybind11, setuptools/CMake integration, Qiskit Terra interoperability.
• C++: CMake, conan, OpenMP, AVX2, Thrust.
• GPU: CUDA/cuStateVec/cuTensorNet.