qml.estimator.wires_manager.WireResourceManager¶
- class WireResourceManager(zeroed, any_state=0, algo_wires=0, tight_budget=False)[source]¶
Bases:
object
Manages and tracks the auxiliary and algorithmic wires used in a quantum circuit.
This class provides a high-level abstraction for managing wire resources within a quantum circuit. The manager tracks the state of three distinct types of wires:
Zeroed state wires: Auxiliary wires that are in the \(|0\rangle\) state. They are converted to an unknown state upon allocation.
Any state wires: Auxiliary wires that are in an unknown state. They are converted to zeroed wires when they are freed.
Algorithmic wires: The core wires used by the quantum algorithm.
- Parameters:
zeroed (int) – Number of zeroed state work wires.
any_state (int) – Number of work wires in an unknown state, default is
0
.algo_wires (int) – Number of algorithmic wires, default value is
0
.tight_budget (bool) – Determines whether extra zeroed state wires can be allocated when they exceed the available amount. The default is
False
.
Example
>>> import pennylane.estimator as qre >>> q = qre.WireResourceManager( ... zeroed=2, ... any_state=2, ... tight_budget=False, ... ) >>> print(q) WireResourceManager(zeroed wires=2, any_state wires=2, algorithmic wires=0, tight budget=False)
Attributes
Returns the number of algorithmic wires.
Returns the number of total wires.
- algo_wires¶
Returns the number of algorithmic wires.
- total_wires¶
Returns the number of total wires.
Methods
free_wires
(num_wires)Frees any_state wires and converts them into zeroed wires.
grab_zeroed
(num_wires)Grabs zeroed wires, and moves them to an arbitrary state; incrementing the number of any_state wires.
- free_wires(num_wires)[source]¶
Frees any_state wires and converts them into zeroed wires.
- Parameters:
num_wires (int) – number of wires to be freed
- Raises:
ValueError – If number of wires to be freed is greater than available any_state wires.
- grab_zeroed(num_wires)[source]¶
Grabs zeroed wires, and moves them to an arbitrary state; incrementing the number of any_state wires.
- Parameters:
num_wires (int) – number of zeroed wires to be grabbed
- Raises:
ValueError – If tight_budget is True and the number of wires to be grabbed is greater than available zeroed wires.