How pasqal-io/qadence works
Main Components
• Core Composition & Program Building: Represent the block-based system that lets users compose digital–analog quantum programs. This includes modules like qadence/blocks and the constructors found in qadrence/constructors.
• Backend Management: There are multiple backends for simulation and execution:
– PyQTorch is the default (providing differentiable simulation via PyTorch).
– Additional backends like Pulser (for pulse-sequence-based simulation) and Horqrux (via the JAX engine) are supported.
– The “qadence/backends” directory encapsulates these variants (with submodules for each backend such as horqrux, pulser, pyqtorch).
• Quantum Circuit & Execution Engine: The qadrence/circuit, qadrence/execution, and qadrence/transpile modules are responsible for taking the composed quantum program and preparing or simulating its execution.
• Machine Learning & Differentiation: The qadrence/ml_tools module integrates with PyTorch and provides tools like loss functions, optimizers, and parameter management for automatic differentiation.
• Measurement, Noise, and Error Mitigation: Components for quantum measurements (qadence/measurements), noise handling (qadence/noise), and mitigation (qadence/mitigations) are clearly modularized.
• Supporting Utilities: There are ancillary modules for logging, configuration (log_config.yaml, setup.py, etc.), and exceptions which handle error states, along with a testing framework.
Component Relationships and Data Flow
• The “Circuit/Program” is further processed by the “Transpiler” (transforming, flattening circuits, applying noise models) which connects to both simulation backends and the measurement modules.
• The “Machine Learning Tools” and “Differentiation” modules are connected to the simulation backends and to the program builder via parameterized operations. Indicate bi-directional data flow between parameter updates and circuit simulation.
• Integration points for external dependencies (e.g., integration with Sympy for symbolic parameters, Graphviz for visualization, etc.).
Architectural Patterns and Design Principles
• Modular Layering: The system is highly modular, separating the quantum program definition (blocks, constructors) from simulation (backends/engines) and differentiation (ml_tools).
• Plugin/Extension Mechanism: Due to its support for multiple backends and extras (visualization, protocols, libs), the design encourages extensibility—illustrate this by grouping backend components as interchangeable plugins.
• Data Flow-Driven Execution: Emphasize the flow from quantum program composition to execution, simulation, evaluation (measurement) and iterative learning, which is crucial for automatic differentiation and optimization.
• Error Handling: Although not as visible as the major functional blocks, note the presence of dedicated exception modules meant to capture any errors across the layers.
Relevant Technologies and Frameworks
• Python as the base language.
• PyTorch for differentiable simulation (core to PyQTorch and ml_tools).
• Optional JAX integration for the Horqrux backend.
• Sympy for symbolic parameter definitions.
• Graphviz (in combination with the drawing modules) for circuit visualization.