qp.devices.modifiers.simulator_tracking¶
- simulator_tracking(cls)[source]¶
Modifies all methods to add default simulator style tracking.
- Parameters:
cls (type) – a subclass of
pennylane.devices.Device
- Returns
type: The inputted class that has now been modified to update the tracker upon function calls.
Simulator style tracking updates:
executions: the number of unique circuits that would be required on quantum hardwareshots: the number of shotsresources: theResourcesfor the executed circuit."errors": combined algorithmic errors from the quantum operations executed by the qnode.simulations: the number of simulations performed. One simulation can cover multiple QPU executions, such as for non-commuting measurements and batched parameters.batches: The number of timesexecute()is called.results: The results of each call ofexecute()derivative_batches: How many timescompute_derivatives()is called.execute_and_derivative_batches: How many timesexecute_and_compute_derivatives()is calledvjp_batches: How many timescompute_vjp()is calledexecute_and_vjp_batches: How many timesexecute_and_compute_vjp()is calledjvp_batches: How many timescompute_jvp()is calledexecute_and_jvp_batches: How many timesexecute_and_compute_jvp()is calledderivatives: How many circuits are submitted tocompute_derivatives()orexecute_and_compute_derivatives().vjps: How many circuits are submitted topennylane.devices.Device.compute_vjp()orexecute_and_compute_vjp()jvps: How many circuits are submitted tocompute_jvp()orexecute_and_compute_jvp()
import pennylane as qp from pennylane.devices.modifiers import simulator_tracking, single_tape_support @simulator_tracking @single_tape_support class MyDevice(qp.devices.Device): def execute(self, circuits, execution_config: ExecutionConfig | None = None): return tuple(0.0 for c in circuits)
>>> dev = MyDevice() >>> ops = [qp.S(0)] >>> measurements = [qp.expval(qp.X(0)), qp.expval(qp.Z(0))] >>> t = qp.tape.QuantumScript(ops, measurements,shots=50) >>> with dev.tracker: ... dev.execute((t, ) ) (0.0,) >>> import pprint >>> pprint.pprint(dev.tracker.history) {'batches': [1], 'errors': [{}], 'executions': [2], 'resources': [SpecsResources(gate_types={'S': 1}, gate_sizes={1: 1}, measurements={'expval(PauliX)': 1, 'expval(PauliZ)': 1}, num_allocs=1, depth=1)], 'results': [0.0], 'shots': [100], 'simulations': [1]}