Quantum hardware simulator backend implementation with realistic noise modeling.
This backend simulates quantum circuits on a virtual quantum device, incorporating various noise models to mimic real quantum hardware behavior. It supports asynchronous job execution, job tracking, and comprehensive result extraction including state trajectories and density matrix calculations. The backend adheres to the QuantumBackend protocol, ensuring compatibility with the broader QClojure framework.
The simulator backend supports predefined quantum devices with specific topologies and noise characteristics, as well as custom configurations. Noise models can include gate errors, readout errors, and decoherence effects, allowing for realistic simulation of quantum algorithms under noisy conditions.
The simulator backend is stateful, managing job submissions and their execution status. It also tracks the current device and allows for device selection.
Key Features:
Quantum hardware simulator backend implementation with realistic noise modeling. This backend simulates quantum circuits on a virtual quantum device, incorporating various noise models to mimic real quantum hardware behavior. It supports asynchronous job execution, job tracking, and comprehensive result extraction including state trajectories and density matrix calculations. The backend adheres to the QuantumBackend protocol, ensuring compatibility with the broader QClojure framework. The simulator backend supports predefined quantum devices with specific topologies and noise characteristics, as well as custom configurations. Noise models can include gate errors, readout errors, and decoherence effects, allowing for realistic simulation of quantum algorithms under noisy conditions. The simulator backend is stateful, managing job submissions and their execution status. It also tracks the current device and allows for device selection. Key Features: - Realistic noise modeling (depolarizing, amplitude damping, phase damping, etc.) - Asynchronous job submission and tracking - Comprehensive result extraction (measurement results, expectation values, density matrices) - Support for predefined quantum devices and custom configurations - Integration with QClojure's optimization and circuit transformation pipelines - Adherence to the QuantumBackend protocol for seamless integration
(cleanup-completed-jobs!)
(cleanup-completed-jobs! max-age-ms)
Remove completed jobs older than specified time (in milliseconds).
Parameters:
Returns: Number of jobs cleaned up
Remove completed jobs older than specified time (in milliseconds). Parameters: - max-age-ms: Maximum age for completed jobs (default: 1 hour) Returns: Number of jobs cleaned up
(coupling device)
Get the qubit coupling of the device.
Parameters:
Returns: Qubit coupling as vector of vectors
Get the qubit coupling of the device. Parameters: - device: Device map Returns: Qubit coupling as vector of vectors
(create-hardware-simulator)
(create-hardware-simulator config)
(create-hardware-simulator config device)
Create a hardware simulator for a specific device.
Parameters:
Returns: QuantumHardwareSimulator instance
Create a hardware simulator for a specific device. Parameters: - config: Optional simulator configuration - :max-qubits - Maximum number of qubits to simulate (default: 16) - device: Optional device map with max-qubits, native-gates, topology and/or coupling and noise-model Returns: QuantumHardwareSimulator instance
(execute-circuit circuit device options)
Execute a noisy quantum circuit with comprehensive result extraction.
This function provides a high-level interface similar to the ideal simulator but with realistic noise modeling. It automatically enables trajectory collection when density matrix-based calculations are needed.
Parameters:
Returns: Comprehensive results with both raw simulation data and extracted observables
Examples: (execute-circuit bell-circuit {:shots 1000 :result-specs {:measurement {:shots 1000} :expectation {:observables [obs/pauli-z obs/pauli-x]} :density-matrix true}})
(execute-circuit vqe-circuit qs/|00⟩ {:shots 2000 :result-specs {:hamiltonian {:hamiltonian h2-hamiltonian} :state-vector true} :noise-model {:depolarizing-rate 0.01}})
Execute a noisy quantum circuit with comprehensive result extraction. This function provides a high-level interface similar to the ideal simulator but with realistic noise modeling. It automatically enables trajectory collection when density matrix-based calculations are needed. Parameters: - circuit: Quantum circuit to simulate - initial-state: Initial quantum state (optional, defaults to |00...0⟩) - options: Execution options including: - :shots - Number of measurement shots (default: 1024) - :result-specs - Map specifying what results to extract - :noise-model - Noise model configuration (optional) - :collect-trajectories - Enable trajectory collection (auto-detected from result specs) - :max-trajectories - Maximum trajectories to collect (default: 100) Returns: Comprehensive results with both raw simulation data and extracted observables Examples: (execute-circuit bell-circuit {:shots 1000 :result-specs {:measurement {:shots 1000} :expectation {:observables [obs/pauli-z obs/pauli-x]} :density-matrix true}}) (execute-circuit vqe-circuit qs/|00⟩ {:shots 2000 :result-specs {:hamiltonian {:hamiltonian h2-hamiltonian} :state-vector true} :noise-model {:depolarizing-rate 0.01}})
(execute-circuit-simulation-with-trajectories circuit
initial-state
options
noise-model)
Execute a quantum circuit simulation collecting state trajectories.
This enhanced version supports comprehensive result extraction similar to the ideal simulator, including expectation values, variances, probabilities, and other quantum mechanical observables computed from the noisy simulation.
Parameters:
Returns: Simulation results including trajectory-based density matrix and extracted results
Execute a quantum circuit simulation collecting state trajectories. This enhanced version supports comprehensive result extraction similar to the ideal simulator, including expectation values, variances, probabilities, and other quantum mechanical observables computed from the noisy simulation. Parameters: - circuit: Quantum circuit to simulate - initial-state: Initial quantum state for simulation - options: Execution options including shot count, trajectory collection settings, and result specs - noise-model: Noise model configuration Returns: Simulation results including trajectory-based density matrix and extracted results
(execute-single-noisy-shot-with-trajectory circuit noise-model)
(execute-single-noisy-shot-with-trajectory circuit initial-state noise-model)
Execute a single shot of a noisy quantum circuit, returning both outcome and final state.
Parameters:
Returns: Map containing :outcome (measurement bitstring) and :final-state (quantum state)
Execute a single shot of a noisy quantum circuit, returning both outcome and final state. Parameters: - circuit: Quantum circuit to simulate - initial-state: Initial quantum state (optional, defaults to |00...0⟩) - noise-model: Noise model configuration Returns: Map containing :outcome (measurement bitstring) and :final-state (quantum state)
(max-qubits backend)
Get the maximum number of qubits supported by the backend.
Parameters:
Returns: Maximum qubit count (default: 16)
Get the maximum number of qubits supported by the backend. Parameters: - backend: Backend instance Returns: Maximum qubit count (default: 16)
(native-gates device)
Get the set of native gates supported by the backend.
Parameters:
Returns: Set of native gate keywords (default: all QClojure gates)
Get the set of native gates supported by the backend. Parameters: - backend: Backend instance Returns: Set of native gate keywords (default: all QClojure gates)
(reset-simulator-state!)
Reset the hardware simulator state, clearing all jobs and counters.
Returns: Updated state
Reset the hardware simulator state, clearing all jobs and counters. Returns: Updated state
(simulator-statistics)
Get statistics about the hardware simulator state.
Returns: Map with job counts and statistics
Get statistics about the hardware simulator state. Returns: Map with job counts and statistics
cljdoc builds & hosts documentation for Clojure/Script libraries
Ctrl+k | Jump to recent docs |
← | Move to previous article |
→ | Move to next article |
Ctrl+/ | Jump to the search field |