Skip to content

qnetbench.policies

The arbitration seam and its three baseline policies.

Narrative guide: Arbitration and policies.

qnetbench.policies.base

The arbitration seam.

A Policy orders contending entanglement requests. It is only consulted in policy:<name> arbitration mode; in native mode the backend uses its own default (FIFO on the reference backend, the simulator's own layer on SeQUeNCe/NetSquid). Routing is a single hop in Phase 0's topologies and is added to this Protocol when multi-hop swapping lands.

PendingRequest dataclass

PendingRequest(
    req_id: int,
    src: NodeId,
    dst: NodeId,
    n: int,
    demand: Demand,
    request_time: SimTime,
)

req_id instance-attribute

req_id: int

src instance-attribute

src: NodeId

dst instance-attribute

dst: NodeId

n instance-attribute

n: int

demand instance-attribute

demand: Demand

request_time instance-attribute

request_time: SimTime

effective_deadline

effective_deadline() -> float

Absolute time this request must be served by, or +inf if unbounded.

Source code in qnetbench/policies/base.py
def effective_deadline(self) -> float:
    """Absolute time this request must be served by, or +inf if unbounded."""
    if self.demand.deadline is not None:
        return self.demand.deadline
    if self.demand.latency_budget is not None:
        return self.request_time + self.demand.latency_budget
    return float("inf")

Policy

Bases: Protocol

name instance-attribute

name: str

order

order(
    pending: list[PendingRequest], now: SimTime
) -> list[int]

Return the req_ids of pending, most-urgent first.

Source code in qnetbench/policies/base.py
def order(self, pending: list[PendingRequest], now: SimTime) -> list[int]:
    """Return the req_ids of `pending`, most-urgent first."""
    ...

The baseline policies

qnetbench.policies.builtin

The three published-style baseline policies used for the cross-policy evaluation. Their ranking is expected to invert across workload classes.

Fifo

First-in, first-out: order by request time. The common default.

name class-attribute instance-attribute
name = 'fifo'
order
order(
    pending: list[PendingRequest], now: float
) -> list[int]
Source code in qnetbench/policies/builtin.py
def order(self, pending: list[PendingRequest], now: float) -> list[int]:
    return [p.req_id for p in sorted(pending, key=lambda p: (p.request_time, p.req_id))]

FidelityFirst

Serve the highest fidelity demand first — favours fidelity-thresholded workloads (QKD) at the expense of deadline-critical ones.

name class-attribute instance-attribute
name = 'fidelity_first'
order
order(
    pending: list[PendingRequest], now: float
) -> list[int]
Source code in qnetbench/policies/builtin.py
def order(self, pending: list[PendingRequest], now: float) -> list[int]:
    def key(p: PendingRequest) -> tuple[float, float, int]:
        return (-p.demand.min_fidelity, p.request_time, p.req_id)

    return [p.req_id for p in sorted(pending, key=key)]

Edf

Earliest-deadline-first — favours deadline-critical workloads (distributed gates) at the expense of steady rate-hungry ones.

name class-attribute instance-attribute
name = 'edf'
order
order(
    pending: list[PendingRequest], now: float
) -> list[int]
Source code in qnetbench/policies/builtin.py
def order(self, pending: list[PendingRequest], now: float) -> list[int]:
    def key(p: PendingRequest) -> tuple[float, float, int]:
        return (p.effective_deadline(), p.request_time, p.req_id)

    return [p.req_id for p in sorted(pending, key=key)]

get_policy

get_policy(name: str) -> Policy
Source code in qnetbench/policies/builtin.py
def get_policy(name: str) -> Policy:
    try:
        return _REGISTRY[name]
    except KeyError:
        raise KeyError(f"unknown policy {name!r}; known: {sorted(_REGISTRY)}") from None

available_policies

available_policies() -> list[str]
Source code in qnetbench/policies/builtin.py
def available_policies() -> list[str]:
    return sorted(_REGISTRY)