qml.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()
@simulator_tracking @single_tape_support class MyDevice(qml.devices.Device): def execute(self, circuits, execution_config: ExecutionConfig | None = None): return tuple(0.0 for c in circuits)
>>> dev = MyDevice() >>> ops = [qml.S(0)] >>> measurements = [qml.expval(qml.X(0)), qml.expval(qml.Z(0))] >>> t = qml.tape.QuantumScript(ops, measurements,shots=50) >>> with dev.tracker: ... dev.execute((t, ) ) >>> dev.tracker.history {'batches': [1], 'simulations': [1], 'executions': [2], 'results': [0.0], 'shots': [100], 'resources': [Resources(num_wires=1, num_gates=1, gate_types=defaultdict(<class 'int'>, {'S': 1}), gate_sizes=defaultdict(<class 'int'>, {1: 1}), depth=1, shots=Shots(total_shots=50, shot_vector=(ShotCopies(50 shots x 1),)))], 'errors': {}}