qml.QueuingContext

class QueuingContext[source]

Bases: abc.ABC

Abstract base class for classes that exposes a queue for objects.

In PennyLane, the construction of quantum gates is separated from the specific quantum node (BaseQNode) that they belong to. However, including logic for this when creating an instance of Operator does not align with the current architecture. Therefore, there is a need to use a high level object that holds information about the relationship between quantum gates and a quantum node.

The QueuingContext class realizes this by providing access to the current QNode. Furthermore, it provides the flexibility to have multiple objects record the creation of quantum gates.

The QueuingContext class both acts as the abstract base class for all classes that expose a queue for Operations (so-called contexts), as well as the interface to said queues. The active contexts contain maximally one QNode and an arbitrary number of other contexts like the OperationRecorder.

active_context()

Returns the currently active queuing context.

append(obj, **kwargs)

Append an object to the queue(s).

get_info(obj)

Returns information of an object in the queue.

remove(obj)

Remove an object from the queue(s) if it is in the queue(s).

update_info(obj, **kwargs)

Updates information of an object in the queue.

classmethod active_context()[source]

Returns the currently active queuing context.

classmethod append(obj, **kwargs)[source]

Append an object to the queue(s).

Parameters

obj – the object to be appended

classmethod get_info(obj)[source]

Returns information of an object in the queue.

classmethod remove(obj)[source]

Remove an object from the queue(s) if it is in the queue(s).

Parameters

obj – the object to be removed

classmethod update_info(obj, **kwargs)[source]

Updates information of an object in the queue.

Contents

Using PennyLane

Development

API