Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
planner_calibration/common.py
Go to the documentation of this file.
1 from __future__ import annotations
2 
3 from dataclasses import dataclass
4 from typing import Iterable
5 
6 PLANNER_CANDIDATE_SCHEMA_VERSION = "phase3_planner_calibration_candidate_v1"
7 PLANNER_FAMILY_SPAN_BUDGET = "phase3_span_budget"
8 SUPPORTED_CANDIDATE_PARTITION_QUBITS = (2, 3, 4)
9 
10 
11 @dataclass(frozen=True)
13  schema_version: str
14  candidate_id: str
15  planner_family: str
16  planner_variant: str
17  max_partition_qubits: int
18 
19  @property
20  def planner_settings(self) -> dict[str, int]:
21  return {"max_partition_qubits": self.max_partition_qubits}
22 
23  def to_dict(self) -> dict[str, object]:
24  return {
25  "schema_version": self.schema_version,
26  "candidate_id": self.candidate_id,
27  "planner_family": self.planner_family,
28  "planner_variant": self.planner_variant,
29  "planner_settings": dict(self.planner_settings),
30  "max_partition_qubits": self.max_partition_qubits,
31  }
32 
33 
35  *,
36  max_partition_qubits_values: Iterable[int] = SUPPORTED_CANDIDATE_PARTITION_QUBITS,
37 ) -> tuple[PlannerCandidate, ...]:
38  normalized_values = tuple(sorted({int(value) for value in max_partition_qubits_values}))
39  if not normalized_values:
40  raise ValueError("Planner-candidate surface requires at least one candidate")
41  if normalized_values[0] <= 0:
42  raise ValueError(
43  "Planner-candidate surface requires max_partition_qubits > 0 for every candidate"
44  )
45 
46  return tuple(
48  schema_version=PLANNER_CANDIDATE_SCHEMA_VERSION,
49  candidate_id=f"span_budget_q{max_partition_qubits}",
50  planner_family=PLANNER_FAMILY_SPAN_BUDGET,
51  planner_variant=f"max_partition_qubits_{max_partition_qubits}",
52  max_partition_qubits=max_partition_qubits,
53  )
54  for max_partition_qubits in normalized_values
55  )
56 
57 
58 # Compatibility aliases for existing semantic imports.
59 PLANNER_CALIBRATION_CANDIDATE_SCHEMA_VERSION = PLANNER_CANDIDATE_SCHEMA_VERSION
60 PLANNER_CALIBRATION_PLANNER_FAMILY_SPAN_BUDGET = PLANNER_FAMILY_SPAN_BUDGET
61 PLANNER_CALIBRATION_SUPPORTED_CANDIDATE_PARTITION_QUBITS = SUPPORTED_CANDIDATE_PARTITION_QUBITS
62 PlannerCalibrationPlannerCandidate = PlannerCandidate
63 
64 
66  *,
67  max_partition_qubits_values: Iterable[int] = SUPPORTED_CANDIDATE_PARTITION_QUBITS,
68 ) -> tuple[PlannerCandidate, ...]:
69  return build_planner_candidates(max_partition_qubits_values=max_partition_qubits_values)
def build_planner_calibration_planner_candidates