qp.labs.estimator_beta.Deallocate

class Deallocate(num_wires=None, allocated_register=None, state=AllocateState.ZERO, restored=False)[source]

Bases: object

A class used to represent the deallocation of auxiliary wires that were used in the resource decomposition of a ResourceOperator.

Parameters:
  • num_wires (int | None) – the number of wires to be deallocated

  • allocated_register (Allocate | None) – the allocated wire register the we wish to deallocate

  • state (Literal["any", "zero"] | AllocateState) – The quantum state of the wires to be deallocated, valid values include “zero” or “any”.

  • restored (bool) – A guarantee that the allocated register will be restored (deallocated) to its initial state. If True, this requirement will be enforced programmatically.

Raises:
  • ValueError – if num_wires is not a positive integer

  • ValueError – if restored is not a boolean

Example

The simplest way to deallocate a register is to provide the instance of Allocate where the register was allocated.

>>> import pennylane.labs.estimator_beta as qre
>>> allocate_4 = qre.Allocate(4)  # Allocate 4 qubits
>>> qre.Deallocate(allocated_register=allocate_4)
Deallocate(4, state=zero, restored=False)

We can also manually deallocate a register by specifically providing the details of the register.

>>> qre.Deallocate(num_wires=4, state="zero", restored=False)
Deallocate(4, state=zero, restored=False)

Note

If an allocated_register is provided along with the other parameters (num_wires, state, restored) and the two differ, then the details provided in the allocated_register will take precedence.

If a register was allocated with state = "any" and restored = True, this can only be deallocated by passing that specific instance of Allocate to deallocate.

>>> temp_register = qre.Allocate(5, state="any", restored=True)
>>> qre.Deallocate(allocated_register=temp_register)  # Restore the allocated register
Deallocate(5, state=any, restored=True)

allocated_register

The allocated wire register the we wish to deallocate.

num_wires

The number of wires to be deallocated.

restored

A guarantee that the allocated register will be restored (deallocated) to its initial state.

state

The quantum state of the wires to be deallocated, valid values include "zero" or "any".

allocated_register

The allocated wire register the we wish to deallocate.

num_wires

The number of wires to be deallocated.

restored

A guarantee that the allocated register will be restored (deallocated) to its initial state. If True, this requirement will be enforced programmatically.

state

The quantum state of the wires to be deallocated, valid values include “zero” or “any”.

equal(other)

Determine if two instances of the class are equal.

equal(other)[source]

Determine if two instances of the class are equal.