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:

@simulator_tracking
@single_tape_support
class MyDevice(qml.devices.Device):

    def execute(self, circuits, execution_config = qml.devices.DefaultExecutionConfig):
        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': {}}