def _make_rx_gates(node_id: int, benchmarks: List[Operation]) -> List[GateInfo]: default_duration = _operation_names_to_compiler_duration_default[Supported1QGate.RX] gates = [ GateInfo( operator=Supported1QGate.RX, parameters=[0.0], arguments=[node_id], fidelity=PERFECT_FIDELITY, duration=default_duration, ) ] fidelity = _get_frb_sim_1q(node_id, benchmarks) for param in [np.pi, -np.pi, np.pi / 2, -np.pi / 2]: gates.append( GateInfo( operator=Supported1QGate.RX, parameters=[param], arguments=[node_id], fidelity=fidelity, duration=default_duration, ) ) return gates
def _make_rx_gates() -> List[GateInfo]: gates = [] for param in [0.0, np.pi, -np.pi, np.pi / 2, -np.pi / 2]: gates.append( GateInfo(operator=Supported1QGate.RX, parameters=[param], arguments=["_"])) return gates
def _make_wildcard_2q_gates() -> List[GateInfo]: return [ GateInfo( operator="_", parameters=["_"], arguments=["_", "_"], fidelity=PERFECT_FIDELITY, duration=PERFECT_DURATION, ) ]
def _make_rz_gates(node_id: int, benchmarks: List[Operation]) -> List[GateInfo]: fidelity = _get_frb_sim_1q(node_id, benchmarks) return [ GateInfo( operator=Supported1QGate.RZ, parameters=["_"], arguments=[node_id], fidelity=fidelity, duration=PERFECT_DURATION, ) ]
def _make_xy_gates(characteristics: List[Characteristic]) -> List[GateInfo]: default_duration = _operation_names_to_compiler_duration_default[Supported2QGate.XY] default_fidelity = _operation_names_to_compiler_fidelity_default[Supported2QGate.XY] fidelity = default_fidelity for characteristic in characteristics: if characteristic.name == "fXY": fidelity = characteristic.value break return [ GateInfo( operator=Supported2QGate.XY, parameters=["theta"], arguments=["_", "_"], fidelity=fidelity, duration=default_duration, ) ]
def test_qubit_dead_serialization(): "test that the qubit is marked dead if it has no gates" gate_info = GateInfo( operator=Supported1QGate.RX, parameters=[0.0], arguments=[0], fidelity=1e0, duration=50, ) qubit = Qubit( id=0, gates=[gate_info], ) assert "dead" not in qubit.dict().keys() qubit = Qubit( id=0, gates=[], dead=True, ) assert qubit.dict()["dead"] is True
def test_edge_dead_serialization(): "test that the edge is marked dead if it has no gates" gate_info = GateInfo( operator=Supported2QGate.CZ, parameters=[], arguments=["_", "_"], fidelity=0.89, duration=200, ) edge = Edge( ids=[0, 1], gates=[gate_info], ) assert "dead" not in edge.dict().keys() edge = Edge( ids=[0, 1], gates=[], dead=True, ) assert edge.dict()["dead"] is True
def _make_i_gates() -> List[GateInfo]: return [ GateInfo(operator=Supported1QGate.I, parameters=[], arguments=["_"]) ]
def _make_wildcard_2q_gates() -> List[GateInfo]: return [GateInfo(operator="_", parameters=["_"], arguments=["_", "_"])]
def _make_xy_gates() -> List[GateInfo]: return [ GateInfo(operator=Supported2QGate.XY, parameters=["theta"], arguments=["_", "_"]) ]
def _make_iswap_gates() -> List[GateInfo]: return [ GateInfo(operator=Supported2QGate.ISWAP, parameters=[], arguments=["_", "_"]) ]
def _make_rz_gates() -> List[GateInfo]: return [ GateInfo(operator=Supported1QGate.RZ, parameters=["theta"], arguments=["_"]) ]