Skip to content

Circuit depth

FlatKernelCircuitDepthValidation dataclass

FlatKernelCircuitDepthValidation(
    single_qubit_gate_threshold: int,
    two_qubit_gate_threshold: int,
)

Bases: ValidationPass


              flowchart TD
              bloqade.squin.analysis.validation.circuit_depth.circuit_depth.FlatKernelCircuitDepthValidation[FlatKernelCircuitDepthValidation]

              

              click bloqade.squin.analysis.validation.circuit_depth.circuit_depth.FlatKernelCircuitDepthValidation href "" "bloqade.squin.analysis.validation.circuit_depth.circuit_depth.FlatKernelCircuitDepthValidation"
            

Validate static single- and two-qubit gate counts in reachable Squin IR.

This pass counts supported gate statements rather than scheduling gates into parallel layers. A loop body contributes once regardless of trip count, and both regions of an scf.IfElse contribute. Other gate arities are ignored.

Parameters:

Name Type Description Default
single_qubit_gate_threshold int

Maximum allowed single-qubit gate count.

required
two_qubit_gate_threshold int

Maximum allowed two-qubit gate count.

required

name

name() -> str

Return the human-readable validation name.

Source code in .venv/lib/python3.12/site-packages/bloqade/squin/analysis/validation/circuit_depth/circuit_depth.py
113
114
115
def name(self) -> str:
    """Return the human-readable validation name."""
    return "Circuit Depth Validation"

run

run(
    method: Method,
) -> tuple[
    ForwardFrame[EmptyLattice], list[ir.ValidationError]
]

Analyze method and return its final frame and validation errors.

Source code in .venv/lib/python3.12/site-packages/bloqade/squin/analysis/validation/circuit_depth/circuit_depth.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
def run(
    self, method: ir.Method
) -> tuple[ForwardFrame[EmptyLattice], list[ir.ValidationError]]:
    """Analyze ``method`` and return its final frame and validation errors."""
    analysis = _CircuitDepthAnalysis(
        method.dialects,
        predicate=_count_gates,
        single_qubit_gate_threshold=self.single_qubit_gate_threshold,
        two_qubit_gate_threshold=self.two_qubit_gate_threshold,
    )
    frame, _ = analysis.run(method)

    self._analysis = analysis
    errors = analysis.get_validation_errors()

    return frame, errors