memq_dqc.builder¶
builder
¶
Circuit builder utilities.
circuit_qubit_physical_map
¶
circuit_qubit_physical_map(
schedule: list[PartitionAssignment],
swaps: list[list[SwapOp]],
) -> list[dict[int, tuple[int, int]]]
Create circuit-to-physical qubit maps for each time interval.
A physical qubit is characterized by an (int, int) tuple, where first element represents QPU index, second element represents qubit index for that given QPU. A circuit qubit is the qubit index as defined in the original input circuit.
Source code in src/memq_dqc/builder/extract_utils.py
identify_remote_gates
¶
identify_remote_gates(
circuit: Circuit, partition: Partitioner
) -> list[tuple[Op, dict[str, int]]]
Identify remote gates in the scheduled circuit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
circuit
|
Circuit
|
The circuit representing the quantum circuit. |
required |
partition
|
Partitioner
|
The Partitioner object containing the partitioning schedule. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[Op, dict[str, int]]]
|
Augmented list of operations with two-qubit gates replaced with remote |
list[tuple[Op, dict[str, int]]]
|
variants where applicable. |
Source code in src/memq_dqc/builder/extract_utils.py
synthesize_state_teleportation_swaps
¶
Synthesize swaps to realize the state teleportation schedule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schedule
|
list[PartitionAssignment]
|
A list of time steps, each mapping QPUs to logical qubits. |
required |
Returns:
| Type | Description |
|---|---|
list[list[SwapOp]]
|
Swap operations per timestep that transform each assignment into the |
list[list[SwapOp]]
|
next. The returned list has length |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the schedule changes QPU counts or partition sizes. |
RuntimeError
|
If swap synthesis fails to reach a target assignment. |
Source code in src/memq_dqc/builder/extract_utils.py
window_final_op_id_map
¶
window_final_op_id_map(
windows: list[list[Op]],
) -> dict[int, int]
Create a map from window index to final operation ID.
This is useful to determine when we have reached the end of a given window, in order to insert swaps to prepare the correct partition for the next window. NOTE: does not include the final window, since no swaps need to be inserted after it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
windows
|
list[list[Op]]
|
List of operation windows. |
required |
Returns:
| Type | Description |
|---|---|
dict[int, int]
|
A dictionary mapping window indices to the final operation ID. |
Source code in src/memq_dqc/builder/extract_utils.py
extract_distributed_circuit
¶
extract_distributed_circuit(
partitioner: Partitioner,
*,
ebit_assignment: bool = True,
group_gates: bool = True,
max_group_size: int | None = None,
group_size_profile: SchedulerHardwareProfile
| None = None,
verbosity: Literal["quiet", "info", "debug"] = "quiet",
) -> Program
Extract a distributed OpenQASM program from a completed partitioner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
partitioner
|
Partitioner
|
Partitioner with a completed partitioning run. |
required |
ebit_assignment
|
bool
|
Whether the compiler assigns concrete e-bit pairs into the scheduler DAG. If false, schedulers choose from viable e-bit pair candidates. |
True
|
group_gates
|
bool
|
Whether compatible remote gate groups should share one cat-entanglement region in the emitted program. |
True
|
max_group_size
|
int | None
|
Optional maximum number of two-qubit gates per emitted gate group. |
None
|
group_size_profile
|
SchedulerHardwareProfile | None
|
Scheduler hardware profile whose timing bounds each gate group's duration to the EPR lifetime. When omitted the EPR-lifetime cap is disabled. |
None
|
verbosity
|
Literal['quiet', 'info', 'debug']
|
Logging verbosity for this workflow call. |
'quiet'
|
Returns:
| Type | Description |
|---|---|
Program
|
Distributed OpenQASM program with communication operations inserted. |