PeakUsageGreedyQubitManager Class
A qubit manager tracking compute and memory qubits separately.
It consists of two independent qubit managers for each qubit type. Each manager
uses greedy allocation strategy from cirq.GreedyQubitManager.
Qubits of one type, after freed, cannot be reused as qubits of different type. Therefore, peak qubit count is equal to sum of peak qubit counts for each type.
Initialize the PeakUsageGreedyQubitManager.
Constructor
PeakUsageGreedyQubitManager(prefix: str, *, size: int, maximize_reuse: bool)
Parameters
| Name | Description |
|---|---|
|
prefix
Required
|
Naming prefix for allocated qubits. |
|
size
Required
|
Initial pool size passed through to |
|
maximize_reuse
Required
|
Flag to control qubit reuse strategy. If |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
size
Required
|
|
|
maximize_reuse
Required
|
|
Methods
| compute_qubit_count |
Returns the peak number of simultaneously in-use COMPUTE qubits. |
| current_in_use |
Number of qubits currently in use. |
| memory_qubit_count |
Returns the peak number of simultaneously in-use MEMORY qubits. |
| qalloc |
Allocate |
| qborrow |
Borrow qubits (not supported). |
| qfree |
Free the given qubits. |
| qubit_count |
Returns the peak number of qubits of all types. It is equal to sum of peak counts for each type, because qubits of one type cannot be reused as qubits of a different type. |
compute_qubit_count
Returns the peak number of simultaneously in-use COMPUTE qubits.
compute_qubit_count() -> int
current_in_use
Number of qubits currently in use.
current_in_use() -> int
memory_qubit_count
Returns the peak number of simultaneously in-use MEMORY qubits.
memory_qubit_count() -> int
qalloc
Allocate n qubits and update the usage counters.
qalloc(n: int, dim: int, qubit_type: QubitType = QubitType.COMPUTE) -> list[cirq.ops.raw_types.Qid]
Parameters
| Name | Description |
|---|---|
|
n
Required
|
Number of qubits to allocate. |
|
dim
Required
|
Dimension of each qubit. Example: 2 for qubits. |
|
qubit_type
|
Type of qubits (COMPUTE or MEMORY). Default value: QubitType.COMPUTE
|
Returns
| Type | Description |
|---|---|
|
List of allocated qubits. |
qborrow
Borrow qubits (not supported).
qborrow(n: int, dim: int = 2) -> list[cirq.ops.raw_types.Qid]
Parameters
| Name | Description |
|---|---|
|
n
Required
|
|
|
dim
|
Default value: 2
|
qfree
Free the given qubits.
qfree(qubits: Iterable[Qid]) -> None
Parameters
| Name | Description |
|---|---|
|
qubits
Required
|
|
qubit_count
Returns the peak number of qubits of all types.
It is equal to sum of peak counts for each type, because qubits of one type cannot be reused as qubits of a different type.
qubit_count() -> int