iqm.qrisp_iqm.passes.routing.core.sectionalization.prepare_dag_and_sections

iqm.qrisp_iqm.passes.routing.core.sectionalization.prepare_dag_and_sections#

iqm.qrisp_iqm.passes.routing.core.sectionalization.prepare_dag_and_sections(qc: QuantumCircuit, *, sections: int = 0) → tuple[CircuitDAG, list[Instruction | None], np.ndarray]#

Convert a quantum circuit into a CSR instruction DAG.

Computes sectionalization information for the router.

This is the single entry point that combines DAG construction (via convert_qc_to_sparse_dag()) with section-boundary computation. The returned section_lengths array tells the router how to split the compilation into sections.

Parameters:
  • qc (QuantumCircuit) – The circuit to prepare.

  • sections (int, optional) – 0 (default) for automatic CP-based sections (floor(cp_2qb / 15) + 1), 1 for no sectionalization, N > 1 for exactly N terminator-based sections.

Returns:

  • forward_dag (tuple) – CSR instruction DAG for the forward circuit.

  • forward_instruction_list (list) – Instruction list (entries are Instruction or None).

  • section_lengths (np.ndarray) – Int32 array of per-section node counts. When sectionalization is inactive (sections=1 or no terminators found), this is a single-element array covering the entire DAG.

Return type:

tuple[CircuitDAG, list[Instruction | None], np.ndarray]