Skip to content

Commit

Permalink
do nothing on Init gate instead of warning (#166)
Browse files Browse the repository at this point in the history
* do nothing on init gate instead of showing a warning in adjust_transport_time()
  • Loading branch information
Asa-Kosto-QTM authored Apr 11, 2024
1 parent ecdd930 commit 8438142
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions pytket/phir/phirgen_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,33 +280,31 @@ def format_and_add_primary_commands(
groups2qops(fmt_g2q, ops)


def get_transport_time_for_gate(gate: str, machine: "Machine") -> float:
"""Return the transport time on the machine for the given gate type."""
match gate:
case "RZ" | "R1XY":
return machine.sq_time
case "RZZ":
return machine.tq_time
case "Measure":
return machine.meas_prep_time
case "Init":
return 0
case _:
logger.warning("Gate type %s not assigned a transport duration", gate)
return 0


def adjust_phir_transport_time(ops: list["JsonDict"], machine: "Machine") -> None:
"""Analyze the generated phir and adjust the transport time."""
adjustment = 0.0
for op in ops:
if "qop" in op:
match op["qop"]:
case "RZ" | "R1XY":
adjustment += machine.sq_time
case "RZZ":
adjustment += machine.tq_time
case "Measure":
adjustment += machine.meas_prep_time
case _:
logger.warning(
"Gate type %s not assigned a transport duration", op["qop"]
)
adjustment += get_transport_time_for_gate(op["qop"], machine)
if "block" in op and op["block"] == "qparallel":
first_op = op["ops"][0]["qop"]
match first_op:
case "RZ" | "R1XY":
adjustment += machine.sq_time
case "RZZ":
adjustment += machine.tq_time
case _:
logger.warning(
"Gate type %s not assigned a transport duration", first_op
)
adjustment += get_transport_time_for_gate(first_op, machine)
if "mop" in op and op["mop"] == "Transport":
cost, units = op["duration"]
op["duration"] = cost + adjustment, units
Expand Down

0 comments on commit 8438142

Please sign in to comment.