Skip to content

Alap

ALAP (As-Late-As-Possible) scheduling policy.

alap_reorder_policy

alap_reorder_policy(
    stmts: list[_SchedulableStmt],
) -> list[_SchedulableStmt]

ALAP scheduling policy. Hard barriers (Initialize, EndMeasure) divide the body into independent segments; each segment is scheduled separately.

Gates are assigned to their latest valid layer, deferring single-qubit gates as long as possible to minimise the qubit footprint of earlier CZ-anchored StaticPlacement regions.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/rewrite/reorder_static_placement/alap.py
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
def alap_reorder_policy(
    stmts: list[_SchedulableStmt],
) -> list[_SchedulableStmt]:
    """ALAP scheduling policy. Hard barriers (Initialize, EndMeasure) divide
    the body into independent segments; each segment is scheduled separately.

    Gates are assigned to their *latest* valid layer, deferring single-qubit
    gates as long as possible to minimise the qubit footprint of earlier
    CZ-anchored StaticPlacement regions.
    """
    result: list[_SchedulableStmt] = []
    segment: list[_SchedulableStmt] = []

    for stmt in stmts:
        if isinstance(stmt, _BARRIERS):
            result.extend(_alap_schedule(segment))
            result.append(stmt)
            segment = []
        else:
            segment.append(stmt)
    result.extend(_alap_schedule(segment))
    return result