wy_qcos.transpiler.cmss.mapping.na.zap package

Submodules

wy_qcos.transpiler.cmss.mapping.na.zap.na_zap_mapping module

class wy_qcos.transpiler.cmss.mapping.na.zap.na_zap_mapping.NA_ZAP_Route

基类:ABC

prepare_data(qbit_num, gates, qpu_configs)

Prepare QPU configuration, gates and qubit num, build topo graph.

Description:

This method sets up internal data structures: - stores qpu_config, storage and operate areas - constructs an adjacency graph (ag) restricted to operate_area - precomputes all-pairs shortest path lengths on the operate graph - initializes scheduling lists and result container

参数:
  • qbit_num (int) -- Number of logical qubits.

  • gates (list) -- List of gate objects (IR).

  • qpu_configs -- QPU configuration. Expected keys: - "storage_area": iterable of storage locations - "operate_area": iterable of operate locations - "coupler_map": mapping of couplers - "readout_error": dict of readout errors (used later)

抛出:

MappingException -- If storage area size is smaller than qbit_num.

scheduling()

ASAP scheduling (As-Soon-As-Possible) for the given gates IR.

This scheduler groups gates into time stages respecting device constraints:

  • single-qubit gates can be scheduled on their qubit's earliest available time.

  • two-qubit gates need a pair of operate-area atoms (Rydberg pair),and the number of parallel two-qubit gates per stage is limited by the number of available operate-area coupler edges

It builds:

  • self.gate_scheduling_list: list of gate-lists per stage

  • self.qubit_scheduling_list: list of qubit-id lists per stage

  • self.storage_area_oloc and self.operate_area_oloc placeholders (filled later)

返回:

list of measurement gate objects encountered (measure operations).

返回类型:

list

get_cost(mapping)

Calculate the movement cost for a given mapping plan.

Description:

Cost is computed as Manhattan-like distance between consecutive stages for each atom movement. The objective is to minimize total movement steps.

Notes about movement model (device-specific): - Only single-atom moves are supported. - Movement is grid-like (row/column moves). - Each moved grid step costs 1 time unit (ms in device model).

参数:

mapping (list[dict]) -- mapping for each stage. Each stage is a dict mapping logical qubit id -> physical location string.

返回:

total movement cost across the mapping plan.

返回类型:

int

get_steps(posa, posb)

Calculate the movement cost for given neutral atoms pos.

参数:
  • posa (str) -- neutral atoms a position.

  • posb (str) -- neutral atoms b position.

返回:

(pos_a, pos_b) a pair of neutral atoms node movement cost.

返回类型:

int

find_ryd_pos(stage)

Find an unused Rydberg (operate-area) atom pair for a given stage.

Description:

This function randomly samples edges (pairs of operate-area nodes) and returns the first pair where both positions are free (not occupied) in the operate_area_oloc at the provided stage.

参数:

stage (int) -- stage index for which to find a free Rydberg pair.

返回:

(pos_a, pos_b) a pair of operate-area node identifiers.

返回类型:

tuple

find_pos(stage)

Find an unused storage-area position for a given stage.

Description:

Randomly picks a storage-area location that is currently free in storage_area_oloc[stage].

参数:

stage (int) -- stage index for which to find a free storage location.

返回:

a storage-area location identifier which is free.

返回类型:

any

get_init_mapping_and_placing(mapping)

Initialize atom positions across mapping stages.

Description:

The method assigns initial storage-area positions for logical qubits at stage 0 based on readout_error ranking (prefer lower error).For subsequent stages, it allocates operate-area pairs for two-qubit gates and appropriate storage positions for single-qubit gates, attempting to reuse previous positions when possible.

参数:

mapping (list[dict]) -- preallocated mapping list (each stage a dict logical_qubit_id -> None/position). This list will be filled in place.

返回:

mapping after initial placement (same structure as input).

返回类型:

list[dict]

update_mapping(mapping)

Propose a new mapping by randomly updating the current mapping.

Description:

The update strategies include: - swapping operate-area positions between neighbors - swapping operate-area pairs - swapping or moving storage-area positions

参数:

mapping (list[dict]) -- current mapping plan (stages -> dicts).

返回:

new mapping plan (deep copy) proposed by random update.

返回类型:

list[dict]

get_affect_cost(affect_qubit_id, idx, mapping)

Get cost for update mapping affected atom cost.

参数:
  • affect_qubit_id (list) -- update mapping affected atom list.

  • idx -- int : update mapping stage id.

  • mapping (list[dict]) -- mapping plan across stages to update

  • from. (occupancy)

update_storage_and_operate_area_oloc(mapping)

Update storage and operate areas oloc if a new mapping is accepted.

Description:

This function rebuild storage_area_oloc and operate_area_oloc from the provided mapping: positions (keys) map to logical qubit id or -1 if free.

参数:
  • mapping (list[dict]) -- mapping plan across stages to update

  • from. (occupancy)

init_para()

Initialize parameters for simulated annealing (SA).

返回:

(alpha, t, markovlen)

alpha (float): temperature decay factor per outer loop. t (tuple): temperature range as (t_min, t_init). markovlen (int): number of inner iterations (Markov chain length).

返回类型:

tuple

sa_mapping_and_placing()

Perform simulated annealing to search a mapping and placement.

Description:

The SA objective is to minimize total movement cost computed by get_cost. Procedure: - initialize mapping using get_init_mapping_and_placing - iteratively propose new mappings via update_mapping - accept lower-cost mappings or accept worse mappings with a probability dependent on temperature - gradually lower temperature until below t_min, then validate best mapping

返回:

best mapping plan found after annealing and validation.

返回类型:

list[dict]

recover(mapping)

Recover the mapping result in SA update_mapping.

Description:

Restore the mapping scheme based on the recorded original positions of neutral atoms

参数:

mapping (list[dict]) -- mapping to recover.

validate_mapping(mapping)

Validate the final mapping and remove redundant moves.

Description:

Post-processing: if a logical qubit stays in storage across two consecutive stages, the mapping keep the previous storage position (no move required).

参数:

mapping (list[dict]) -- mapping to validate.

返回:

cleaned mapping after validation.

返回类型:

list[dict]

routing_asap(mapping, measure)

Convert the mapping plan into a sequence of Move and gates.

Description:

For each stage (except initial), create Move operations for atoms whose positions changed compared to previous stage. Then insert scheduled gates for that stage and finally append measurement operations (with updated physical positions).

参数:
  • mapping (list[dict]) -- mapping plan across stages.

  • measure (list) -- list of measurement gate objects collected

  • scheduling. (during)

返回:

list of operations(Move and gate objects)ready for execution.

返回类型:

list

execute_with_order()

Run scheduling, mapping and routing to produce final op list.

Description:
Workflow:
  1. scheduling() to generate gate stages and measure ops

  2. sa_mapping_and_placing() to find a mapping plan

  3. routing_asap() to create Move and gate execution sequence

返回:

ordered list of operations (Move and gates) mapping logical

qubits to physical qpu positions ready for execution.

返回类型:

list

Module contents