Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
Functions
tools Namespace Reference

Functions

def build_dependency
 
def gate_desc_to_gate_index (circ, preparts, qubit_groups_only=False)
 
def get_bqskit_partitions (filename, max_partition_size, partitioner)
 
def get_float_ops (num_qubit, gate_qubits, control_qubits, is_pure=False, io_penalty=48)
 
def get_qiskit_fusion_partitions (filename, max_partition_size)
 
def get_qiskit_partitions (filename, max_partition_size)
 
def get_qubits
 
def parts_to_float_ops (num_qubit, gate_to_qubit, gate_to_tqubit, allparts)
 
def qiskit_to_squander_name (qiskit_name)
 
def total_float_ops (num_qubit, max_qubits_per_partition, gate_to_qubit, gate_to_tqubit, allparts)
 
def translate_param_order
 

Function Documentation

◆ build_dependency()

def tools.build_dependency (   c)

Definition at line 136 of file tools.py.

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

◆ gate_desc_to_gate_index()

def tools.gate_desc_to_gate_index (   circ,
  preparts,
  qubit_groups_only = False 
)
Map gate descriptions to indices for partitioning
Args:

    circ: SQUANDER Circuit

    preparts: Partition descriptions
Returns:

    Partitioned gate indices

Definition at line 188 of file tools.py.

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

◆ get_bqskit_partitions()

def tools.get_bqskit_partitions (   filename,
  max_partition_size,
  partitioner 
)
Partition circuit using BQSKit partitioners
Args:

    filename: QASM file path

    max_partition_size: Max qubits per partition

    partitioner: BQSKit Partitioning strategy
Returns:

    Parameters, partitioned circuit, parameter order (source_idx, dest_idx, param_count), partitions

Definition at line 359 of file tools.py.

Here is the call graph for this function:

◆ get_float_ops()

def tools.get_float_ops (   num_qubit,
  gate_qubits,
  control_qubits,
  is_pure = False,
  io_penalty = 48 
)
Compute the number of floating-point operations (FLOPs) required
for simulating a quantum gate acting on a set of qubits.

Args:
    num_qubit (int): Total number of qubits in the system.
    gate_qubits (int): Number of qubits the gate acts on (including controls).
    control_qubits (int): Number of control qubits for the gate.
    is_pure (bool, optional): Whether the gate is a "pure" controlled gate
        (i.e., all controlled gates share the same target qubit). Defaults to False.

Returns:
    int: Estimated number of floating-point operations required.

Definition at line 26 of file tools.py.

Here is the caller graph for this function:

◆ get_qiskit_fusion_partitions()

def tools.get_qiskit_fusion_partitions (   filename,
  max_partition_size 
)
Generate circuit partitions from a QASM file using Qiskit's fusion
metadata and Squander's partitioning utilities.

This function:
  1. Parses the QASM file into a Squander circuit.
  2. Runs the circuit on Qiskit's AerSimulator with gate fusion enabled.
  3. Extracts the fusion metadata (grouped qubit operations).
  4. Uses Squander's Kahn-based partitioning to produce circuit partitions.

Args:
    filename (str): Path to the QASM file to be parsed.
    max_partition_size (int): Maximum number of qubits allowed in each
        fusion partition (i.e., `fusion_max_qubit` for Qiskit).

Returns:
    tuple:
        parameters (list): Parameter list extracted from the Squander circuit.
        partitioned_circ (object): Partitioned Squander circuit object.
        param_order (list): Order of parameters corresponding to the partitioned circuit.
        parts (list[list]): Partitioning of the circuit into gate groups,
            represented as lists of gate indices.

Definition at line 302 of file tools.py.

Here is the call graph for this function:

◆ get_qiskit_partitions()

def tools.get_qiskit_partitions (   filename,
  max_partition_size 
)
Partition circuit using Qiskit multi-qubit blocks
Args:

    filename: QASM file path

    max_partition_size: Max qubits per partition
Returns:

    Parameters, partitioned circuit, parameter order (source_idx, dest_idx, param_count), partitions

Definition at line 259 of file tools.py.

Here is the call graph for this function:

◆ get_qubits()

def tools.get_qubits (   gate)

Definition at line 13 of file tools.py.

Here is the caller graph for this function:

◆ parts_to_float_ops()

def tools.parts_to_float_ops (   num_qubit,
  gate_to_qubit,
  gate_to_tqubit,
  allparts 
)
Compute FLOPs for each partition of gates in a quantum circuit.

Args:
    num_qubit (int): Total number of qubits in the system.
    gate_to_qubit (dict): Mapping from gate ID to the set of qubits
        it acts on.
    gate_to_tqubit (dict or None): Mapping from gate ID to its target qubit
        (used for distinguishing control vs. target qubits). If None,
        control qubits are assumed to be 0.
    allparts (list[list]): Partitioning of gates, where each part is a
        collection (e.g., list or set) of gate IDs.

Returns:
    list[int]: FLOP counts for each partition in `allparts`.

Definition at line 48 of file tools.py.

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

◆ qiskit_to_squander_name()

def tools.qiskit_to_squander_name (   qiskit_name)
Convert Qiskit gate name to SQUANDER name
Args:

    qiskit_name: Qiskit gate name
Returns:

    SQUANDER gate name

Definition at line 167 of file tools.py.

Here is the caller graph for this function:

◆ total_float_ops()

def tools.total_float_ops (   num_qubit,
  max_qubits_per_partition,
  gate_to_qubit,
  gate_to_tqubit,
  allparts 
)
Compute the total FLOPs across all partitions of a quantum circuit,
scaled by the number of qubits outside the maximum partition.

Args:
    num_qubit (int): Total number of qubits in the system.
    max_qubits_per_partition (int): Maximum number of qubits any partition
        can act on.
    gate_to_qubit (dict): Mapping from gate ID to the set of qubits
        it acts on.
    gate_to_tqubit (dict or None): Mapping from gate ID to its target qubit.
        If None, control qubits are assumed to be 0.
    allparts (list[list]): Partitioning of gates, where each part is a
        collection of gate IDs.

Returns:
    int: Total number of floating-point operations across all partitions.

Definition at line 86 of file tools.py.

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

◆ translate_param_order()

def tools.translate_param_order (   params)

Definition at line 112 of file tools.py.

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