qcmet.benchmarks.HamiltonianSimulation#
- class qcmet.benchmarks.HamiltonianSimulation(simulation_name, qubits, evolution_circuit=None, init_circuit=None, n_steps=1, save_path=None)[source]#
Benchmark class for simulating quantum dynamics of a Hamiltonian with Trotter evolution.
This class implements a general Trotterized Hamiltonian simulation bencharking workflow, including estimating the final populations under a Trotterized evolution for an initial state a parameterized ansatz and evaluating the the normalized fidelity as the final metric.
Concrete HamiltonianSimulation instances should either inherit from this base class and overwrite the _trotter_step function, or pass in the a single Trotter layer (as qiskit circuit) into the constructor.
- __init__(simulation_name, qubits, evolution_circuit=None, init_circuit=None, n_steps=1, save_path=None)[source]#
Initialize the HamiltonianSimulation benchmark instance with configuration and circuits.
Stores the evolution circuit (a single Trotter step), and initial circuit, if these are not passed in, the respective properties/functions should be overwritten in inheriting classes. Sets the number of steps for the application of the Trotter evolution ansatz.
- Parameters:
simulation_name (str) – Name of the Hamiltonian simulation.
qubits (list[int]) – List of qubit indices used in the simulation.
evolution_circuit (QuantumCircuit, optional) – Circuit representing one step of the system’s evolution.
init_circuit (QuantumCircuit, optional) – Circuit for preparing the initial quantum state.
n_steps (int, optional) – Number of Trotter steps to apply. Defaults to 1.
save_path (str | Path | FileManager | None, optional) – Directory path to save results. Defaults to None.
Methods
__init__(simulation_name, qubits[, ...])Initialize the HamiltonianSimulation benchmark instance with configuration and circuits.
analyze()Analyze measurements to return benchmark results.
generate_circuits()Generate benchmark circuits, user facing.
has_plotting()Check if _plot function is implemented in benchmark.
load_circuit_measurements(circuit_measurements)Load measurement counts into the experiment_data DataFrame.
measurements_to_probabilities()Convert raw measurement counts to normalized probabilities.
plot([axes])Plot benchmark result, user facing.
run([device, num_shots, max_circs_per_job])Run benchmark.
save()Save benchmark current state.
set_save_path(save_path)Set benchmark save path if not set in class constructor.
Attributes
circuitsGets all benchmark circuits.
Return the composed quantum circuit with initial state, Trotter steps, and measurements.
experiment_dataGetter for experiment_data dataframe.
Return the initial quantum circuit for state preparation.
num_qubitsNumber of qubits in this benchmark.
- property evolution_circuit#
Return the composed quantum circuit with initial state, Trotter steps, and measurements.
- Returns:
The composed quantum circuit with initial state preparation, Trotter evolution, and measurement.
- Return type:
QuantumCircuit
- property initial_state#
Return the initial quantum circuit for state preparation.
- Returns:
The initial state circuit or a default empty circuit.
- Return type:
QuantumCircuit