Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
Classes | Functions | Variables
squander.decomposition.qgd_Wide_Circuit_Optimization Namespace Reference

Classes

class  _SquanderSynthesisFailed
 
class  qgd_Wide_Circuit_Optimization
 
class  SquanderPartitioner
 
class  SquanderSynthesisPass
 

Functions

def _add_swap_as_cnots (circuit, a, b)
 
def _append_topology_safe (new_c, op, topo_edges, width)
 
def _assert_circuit_respects_topology (circuit, topo_edges)
 
def _bqskit_location_respects_topology (location, topo_edges)
 
def _bqskit_synthesis_validation_tolerance (config)
 
def _config_uses_float32 (config)
 
def _copy_bqskit_synthesis_config (config)
 
def _default_bqskit_synthesis_validation_tolerance (config)
 
def _default_squander_tolerance (config)
 
def _fallback_circuit_for_permutation (original_circuit, graph, pi, po)
 
def _patch_eapp_if_needed ()
 
def _squander_synthesize_or_fallback (inner_synthesis, target, target_data, original_circuit, graph, pi, po)
 
def _squander_validation_tolerance (config)
 
def _topo_perm_to_swaps (pi, topo_edges, width)
 
def CircuitGateStats
 
def CNOTGateCount
 
def extract_subtopology (involved_qbits, qbit_map, config)
 
def patched_seqpam_workflow_classes (bqskit_compile_module, use_squander_partitioner, config)
 
def SingleQubitGateCount
 
def TotalRawGateCount
 

Variables

 _BQSKitBasePass = object
 
 _BQSKitSynthesisPass = object
 
dictionary _GATE_DECOMPOSITION
 
 _SKIP_CONFIG_VALUE = object()
 
 _SQUANDER_BQSKIT_SYNTHESIS_CONFIG = None
 
int BQSKIT_FLOAT32_SYNTHESIS_VALIDATION_TOLERANCE = 1e-4
 
int BQSKIT_FLOAT64_SYNTHESIS_VALIDATION_TOLERANCE = 1e-8
 
dictionary CNOT_COUNT_DICT = {g: d.get("CNOT", 0) for g, d in _GATE_DECOMPOSITION.items()}
 
int SQUANDER_FLOAT32_TOLERANCE = 1e-5
 
int SQUANDER_FLOAT64_TOLERANCE = 1e-10
 

Detailed Description

Wide-circuit optimization: partition large circuits into subcircuits, re-decompose
them, and optionally route or fuse results according to configuration.

Function Documentation

◆ _add_swap_as_cnots()

def squander.decomposition.qgd_Wide_Circuit_Optimization._add_swap_as_cnots (   circuit,
  a,
  b 
)
private
Append CNOT(a,b); CNOT(b,a); CNOT(a,b) — equivalent to SWAP(a,b).

Definition at line 118 of file qgd_Wide_Circuit_Optimization.py.

Here is the caller graph for this function:

◆ _append_topology_safe()

def squander.decomposition.qgd_Wide_Circuit_Optimization._append_topology_safe (   new_c,
  op,
  topo_edges,
  width 
)
private
Append *op* to *new_c*, using SWAP bridges for edges not in *topo_edges*.

For gates with ≥3 qubits, decomposes via :func:`squander.utils.circuit_to_CNOT_basis`
and recurses on each resulting gate.

Definition at line 134 of file qgd_Wide_Circuit_Optimization.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _assert_circuit_respects_topology()

def squander.decomposition.qgd_Wide_Circuit_Optimization._assert_circuit_respects_topology (   circuit,
  topo_edges 
)
private
Raise AssertionError if ``circuit`` violates ``topo_edges``.

Topology violations indicate a critical logic bug — the circuit cannot
physically execute on the target hardware.  Execution must stop
immediately so the root cause can be investigated and fixed.

Definition at line 254 of file qgd_Wide_Circuit_Optimization.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _bqskit_location_respects_topology()

def squander.decomposition.qgd_Wide_Circuit_Optimization._bqskit_location_respects_topology (   location,
  topo_edges 
)
private
Return true if ``location`` can be hosted by ``topo_edges``.

Definition at line 229 of file qgd_Wide_Circuit_Optimization.py.

Here is the caller graph for this function:

◆ _bqskit_synthesis_validation_tolerance()

def squander.decomposition.qgd_Wide_Circuit_Optimization._bqskit_synthesis_validation_tolerance (   config)
private

Definition at line 72 of file qgd_Wide_Circuit_Optimization.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _config_uses_float32()

def squander.decomposition.qgd_Wide_Circuit_Optimization._config_uses_float32 (   config)
private

Definition at line 45 of file qgd_Wide_Circuit_Optimization.py.

Here is the caller graph for this function:

◆ _copy_bqskit_synthesis_config()

def squander.decomposition.qgd_Wide_Circuit_Optimization._copy_bqskit_synthesis_config (   config)
private
Copy only plain data needed by BQSKit worker processes.

Definition at line 79 of file qgd_Wide_Circuit_Optimization.py.

Here is the caller graph for this function:

◆ _default_bqskit_synthesis_validation_tolerance()

def squander.decomposition.qgd_Wide_Circuit_Optimization._default_bqskit_synthesis_validation_tolerance (   config)
private

Definition at line 57 of file qgd_Wide_Circuit_Optimization.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _default_squander_tolerance()

def squander.decomposition.qgd_Wide_Circuit_Optimization._default_squander_tolerance (   config)
private

Definition at line 49 of file qgd_Wide_Circuit_Optimization.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _fallback_circuit_for_permutation()

def squander.decomposition.qgd_Wide_Circuit_Optimization._fallback_circuit_for_permutation (   original_circuit,
  graph,
  pi,
  po 
)
private
Build a topology-valid fallback for ``Po.T @ U @ Pi``.

``original_circuit`` is the block circuit passed into BQSKit's
EmbedAllPermutationsPass.  ``graph`` is the block-local coupling graph
selected by EAPP for this synthesis attempt.

Definition at line 271 of file qgd_Wide_Circuit_Optimization.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _patch_eapp_if_needed()

def squander.decomposition.qgd_Wide_Circuit_Optimization._patch_eapp_if_needed ( )
private
Monkey-patch EAPP.run to catch Squander OSR failures per permutation.

IMPORTANT: This patch fully replaces ``EmbedAllPermutationsPass.run``.
It was written against BQSKit's internal EAPP implementation as of
the pip-installed version (see pyproject.toml / requirements for the
exact version).  If BQSKit changes its EAPP internals (scoring function,
subtopology selection, permutation handling, or pass data keys), this
patch may silently diverge and should be re-audited against the new
BQSKit source.

Definition at line 331 of file qgd_Wide_Circuit_Optimization.py.

Here is the caller graph for this function:

◆ _squander_synthesize_or_fallback()

def squander.decomposition.qgd_Wide_Circuit_Optimization._squander_synthesize_or_fallback (   inner_synthesis,
  target,
  target_data,
  original_circuit,
  graph,
  pi,
  po 
)
private
Run Squander synthesis, falling back only for explicit Squander misses.

Definition at line 323 of file qgd_Wide_Circuit_Optimization.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _squander_validation_tolerance()

def squander.decomposition.qgd_Wide_Circuit_Optimization._squander_validation_tolerance (   config)
private

Definition at line 65 of file qgd_Wide_Circuit_Optimization.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _topo_perm_to_swaps()

def squander.decomposition.qgd_Wide_Circuit_Optimization._topo_perm_to_swaps (   pi,
  topo_edges,
  width 
)
private
Decompose permutation *pi* into SWAPs using only edges in *topo_edges*.

Uses BFS on the topology graph to find a SWAP sequence that implements
the permutation.  Returns a list of (u, v) pairs valid in *topo_edges*.

Definition at line 684 of file qgd_Wide_Circuit_Optimization.py.

Here is the caller graph for this function:

◆ CircuitGateStats()

def squander.decomposition.qgd_Wide_Circuit_Optimization.CircuitGateStats (   circ)

Definition at line 900 of file qgd_Wide_Circuit_Optimization.py.

Here is the caller graph for this function:

◆ CNOTGateCount()

def squander.decomposition.qgd_Wide_Circuit_Optimization.CNOTGateCount (   circ)

Definition at line 842 of file qgd_Wide_Circuit_Optimization.py.

Here is the caller graph for this function:

◆ extract_subtopology()

def squander.decomposition.qgd_Wide_Circuit_Optimization.extract_subtopology (   involved_qbits,
  qbit_map,
  config 
)
Return topology edges restricted to ``involved_qbits``, with indices remapped via ``qbit_map``.

Args:
    involved_qbits: Qubit labels present in a partition.
    qbit_map: Maps original qubit index to local index (0..n-1).
    config: Configuration dict containing ``topology`` as a list of edges.

Returns:
    List of ``(u, v)`` pairs in local indices, each edge fully inside the partition.

Definition at line 777 of file qgd_Wide_Circuit_Optimization.py.

◆ patched_seqpam_workflow_classes()

def squander.decomposition.qgd_Wide_Circuit_Optimization.patched_seqpam_workflow_classes (   bqskit_compile_module,
  use_squander_partitioner,
  config 
)
Patch BQSKit workflow factories to use Squander passes.

Replaces QSearch/LEAP with SquanderSynthesisPass.  Squander failures are
caught by the EAPP patch and replaced with SWAP-correct fallbacks.

Definition at line 740 of file qgd_Wide_Circuit_Optimization.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SingleQubitGateCount()

def squander.decomposition.qgd_Wide_Circuit_Optimization.SingleQubitGateCount (   circ)

Definition at line 869 of file qgd_Wide_Circuit_Optimization.py.

◆ TotalRawGateCount()

def squander.decomposition.qgd_Wide_Circuit_Optimization.TotalRawGateCount (   circ)

Definition at line 888 of file qgd_Wide_Circuit_Optimization.py.

Variable Documentation

◆ _BQSKitBasePass

squander.decomposition.qgd_Wide_Circuit_Optimization._BQSKitBasePass = object
private

Definition at line 33 of file qgd_Wide_Circuit_Optimization.py.

◆ _BQSKitSynthesisPass

squander.decomposition.qgd_Wide_Circuit_Optimization._BQSKitSynthesisPass = object
private

Definition at line 34 of file qgd_Wide_Circuit_Optimization.py.

◆ _GATE_DECOMPOSITION

dictionary squander.decomposition.qgd_Wide_Circuit_Optimization._GATE_DECOMPOSITION
private

Definition at line 799 of file qgd_Wide_Circuit_Optimization.py.

◆ _SKIP_CONFIG_VALUE

squander.decomposition.qgd_Wide_Circuit_Optimization._SKIP_CONFIG_VALUE = object()
private

Definition at line 110 of file qgd_Wide_Circuit_Optimization.py.

◆ _SQUANDER_BQSKIT_SYNTHESIS_CONFIG

squander.decomposition.qgd_Wide_Circuit_Optimization._SQUANDER_BQSKIT_SYNTHESIS_CONFIG = None
private

Definition at line 37 of file qgd_Wide_Circuit_Optimization.py.

◆ BQSKIT_FLOAT32_SYNTHESIS_VALIDATION_TOLERANCE

int squander.decomposition.qgd_Wide_Circuit_Optimization.BQSKIT_FLOAT32_SYNTHESIS_VALIDATION_TOLERANCE = 1e-4

Definition at line 42 of file qgd_Wide_Circuit_Optimization.py.

◆ BQSKIT_FLOAT64_SYNTHESIS_VALIDATION_TOLERANCE

int squander.decomposition.qgd_Wide_Circuit_Optimization.BQSKIT_FLOAT64_SYNTHESIS_VALIDATION_TOLERANCE = 1e-8

Definition at line 41 of file qgd_Wide_Circuit_Optimization.py.

◆ CNOT_COUNT_DICT

dictionary squander.decomposition.qgd_Wide_Circuit_Optimization.CNOT_COUNT_DICT = {g: d.get("CNOT", 0) for g, d in _GATE_DECOMPOSITION.items()}

Definition at line 839 of file qgd_Wide_Circuit_Optimization.py.

◆ SQUANDER_FLOAT32_TOLERANCE

int squander.decomposition.qgd_Wide_Circuit_Optimization.SQUANDER_FLOAT32_TOLERANCE = 1e-5

Definition at line 40 of file qgd_Wide_Circuit_Optimization.py.

◆ SQUANDER_FLOAT64_TOLERANCE

int squander.decomposition.qgd_Wide_Circuit_Optimization.SQUANDER_FLOAT64_TOLERANCE = 1e-10

Definition at line 39 of file qgd_Wide_Circuit_Optimization.py.