qp.labs.estimator_beta.Deallocate¶
- class Deallocate(num_wires=None, allocated_register=None, state=AllocateState.ZERO, restored=False)[source]¶
Bases:
objectA 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
Allocatewhere 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_registeris provided along with the other parameters (num_wires,state,restored) and the two differ, then the details provided in theallocated_registerwill take precedence.If a register was allocated with
state = "any"andrestored = True, this can only be deallocated by passing that specific instance ofAllocateto 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)
Attributes
The allocated wire register the we wish to deallocate.
The number of wires to be deallocated.
A guarantee that the allocated register will be restored (deallocated) to its initial 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”.
Methods