memq_dqc.verify¶
verify
¶
Verification helpers for memq_dqc outputs.
dist_to_mono_circuit
¶
Convert a distributed circuit to an executable monolithic circuit.
Takes a distributed circuit and rewrites it into an equivalent, locally-executable form by:
- replacing remote operations with their local equivalents (
rcx->cx,rcp->cp,rcry->cry,rcz->cz,rswap->swap), keeping only the two data-qubit operands; - dropping the cat-entanglement scaffolding (
catent/catdisent) that wraps remote operations, since the local equivalents need no shared entanglement; - removing communication-qubit (
c*) declarations and any remaining gates that act on communication qubits; - dropping the custom
distgates.incinclude, which is no longer referenced once remote operations are removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dist_circuit_path
|
str
|
Path to the distributed circuit file. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A qasm string representing the monolithic version of the distributed |
str
|
circuit. |
Source code in src/memq_dqc/verify/verify.py
dist_to_mono_program
¶
Rewrite a distributed program into a monolithic program.
Performs the same rewrite as dist_to_mono_circuit but operates on an in-memory program rather than a file, so no serialization round-trip is required. See dist_to_mono_circuit for the full list of transformations applied.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dist_program
|
Program
|
Parsed distributed OpenQASM 3 program. |
required |
Returns:
| Type | Description |
|---|---|
Program
|
An equivalent monolithic OpenQASM 3 program with remote |
Program
|
operations replaced by their local equivalents. |
Source code in src/memq_dqc/verify/verify.py
manual_cost_verification
¶
Return the total manual cost of remote operations in a QASM string.
Costs are in e-bit pairs
rswap costs REMOTE_SWAP_EBIT_COST (two teleportations).
rcp, rcry, rcx, and rcz each cost
REMOTE_GATE_EBIT_COST.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qasm
|
str
|
OpenQASM source code to analyze. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Sum of remote operation costs. |
Source code in src/memq_dqc/verify/verify.py
verify_distributed_circuit
¶
verify_distributed_circuit(
original: Program | str,
distributed: Program | str,
*,
method: Literal["sampling", "statevector"] = "sampling",
shots: int = 50000000,
fidelity_threshold: float = 0.9,
max_qubits: int = 28,
atol: float = 1e-09,
verbosity: Literal["quiet", "info", "debug"] = "quiet",
) -> bool
Verify the correctness of a distributed circuit.
Evaluates the distributed circuit as a single, monolithic circuit where
remote operations are assumed to operate perfectly, then compares it to
the original circuit using the chosen method:
"sampling"simulates both circuits forshotsshots and compares their measured output distributions via Hellinger fidelity. This is an approximate, stochastic check whose accuracy depends on the shot count."statevector"computes each circuit's exact output distribution from its statevector (no shots) for circuits with final measurements and checks that they match withinatol. The comparison is mapped through each circuit's own measurement-to-classical-bit mapping, so it is invariant to how data qubits are laid out or relabeled across QPUs. It preserves the full classical output width, including unwritten bits. This is deterministic and exact, but memory grows as2**nin the qubit countn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
original
|
Program | str
|
The original circuit, either as a parsed OpenQASM 3
program or a path to its |
required |
distributed
|
Program | str
|
The distributed circuit, either as a parsed
OpenQASM 3 program or a path to its |
required |
method
|
Literal['sampling', 'statevector']
|
Verification method, either |
'sampling'
|
shots
|
int
|
Number of shots to execute the circuits for. Used only by the
|
50000000
|
fidelity_threshold
|
float
|
The minimum Hellinger fidelity required for the
distributed circuit to be considered correct. Used only by the
|
0.9
|
max_qubits
|
int
|
Maximum circuit width the |
28
|
atol
|
float
|
Maximum total-variation distance between the exact output
distributions for the circuits to be considered equivalent. Used
only by the |
1e-09
|
verbosity
|
Literal['quiet', 'info', 'debug']
|
Logging verbosity for this workflow call. |
'quiet'
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the distributed circuit reproduces the original circuit's |
bool
|
output distribution under the chosen method, False otherwise. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/memq_dqc/verify/verify.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |