Policy movement
Move Policy DSL placement strategy.
Sidecar to :mod:bloqade.lanes.heuristics.physical.movement —
:class:PolicyPlacementStrategy mirrors
:class:~bloqade.lanes.heuristics.physical.movement.PhysicalPlacementStrategy
but routes each per-stage move synthesis call through the Starlark Move
Policy DSL (bloqade.lanes.bytecode._native.PolicyRunner) instead of the
TargetSolver-based path. Keeping the DSL path out of the strategy file
means main can keep evolving movement.py without colliding with DSL work.
PolicyPlacementStrategy
dataclass
PolicyPlacementStrategy(
arch_spec: ArchSpec = get_physical_arch_spec(),
target_generator: (
TargetGeneratorABC | TargetGeneratorCallable | None
) = None,
*,
traversal: PolicyTraversal
)
Bases: PlacementStrategyABC
flowchart TD
bloqade.lanes.heuristics.physical.policy_movement.PolicyPlacementStrategy[PolicyPlacementStrategy]
bloqade.lanes.analysis.placement.strategy.PlacementStrategyABC[PlacementStrategyABC]
bloqade.lanes.analysis.placement.strategy.PlacementStrategyABC --> bloqade.lanes.heuristics.physical.policy_movement.PolicyPlacementStrategy
click bloqade.lanes.heuristics.physical.policy_movement.PolicyPlacementStrategy href "" "bloqade.lanes.heuristics.physical.policy_movement.PolicyPlacementStrategy"
click bloqade.lanes.analysis.placement.strategy.PlacementStrategyABC href "" "bloqade.lanes.analysis.placement.strategy.PlacementStrategyABC"
Physical placement strategy backed by a Starlark Move Policy DSL.
Each CZ-stage move synthesis call is dispatched through
:class:bloqade.lanes.bytecode._native.PolicyRunner and the policy
file named by traversal.policy_path. Target generation reuses the
same target_generator / default-fallback pipeline as
:class:~bloqade.lanes.heuristics.physical.movement.PhysicalPlacementStrategy.
traversal is keyword-only so it can be required without colliding
with the defaulted fields PlacementStrategyABC inherits.
rust_nodes_expanded_total
property
rust_nodes_expanded_total: int
Total Rust DSL kernel node expansions for this strategy instance.
measure_placements
measure_placements(
state: AtomState, qubits: tuple[int, ...]
) -> AtomState
Place a terminal measurement of all qubits.
layout stays canonical (indexed by qubit id) — it must not be
permuted, since reordering it would relabel qubits. The measurement
order is carried by place.EndMeasure.qubits and applied when the
measurement is lowered (see place2move.InsertMeasure), which indexes
this canonical layout by qubits so each result reads the location of
the qubit it measures (qubits is a permutation once StaticPlacement
blocks are merged).
A UserMoved state is accepted here: a user-directed move that ends
at a measurement is committed — the atoms stay at their moved layout and
are measured there, and the compiler tracks the final positions within
the single zone. UserMoved is a ConcreteState subclass, so it
flows through the concrete-state path below. PalindromePlacementStrategy
overrides this to reject UserMoved instead: under palindrome a
user-move is only committed by a following CZ, never a measurement.
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/heuristics/physical/policy_movement.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
PolicyTraversal
dataclass
PolicyTraversal(
policy_path: str,
policy_params: dict[str, Any] | None = None,
max_expansions: int | None = 300,
timeout_s: float | None = None,
)
Config for the Move Policy DSL placement strategy.
Sidecar to
:class:~bloqade.lanes.heuristics.physical.movement.RustPlacementTraversal
that only carries DSL-relevant knobs.
compute_move_layers_dsl
compute_move_layers_dsl(
*,
arch_spec: ArchSpec,
initial: dict[int, LocationAddress],
target: dict[int, LocationAddress],
blocked: list[LocationAddress],
traversal: PolicyTraversal,
runner: PolicyRunner | None = None
) -> tuple[tuple[LaneAddress, ...], ...]
Solve a single move synthesis problem via the Move Policy DSL.
Sidecar to
:func:bloqade.lanes.heuristics.move_synthesis.compute_move_layers,
routed through :class:PolicyRunner rather than :class:TargetSolver.
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/heuristics/physical/policy_movement.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |