from qiskit_ibm_runtime.fake_provider import FakeFez

from common import ghz, transpile_for

# Fake backend : la copie figée d'une calibration d'ibm_fez, livrée avec le SDK
backend = FakeFez()
print("Machine :", backend.name, "|", backend.num_qubits, "qubits")
print("Calibration figée du :", backend.properties().last_update_date.date())

qc = ghz(4)
isa = transpile_for(backend, qc, level=1)
print("Qubits physiques choisis :", isa.layout.final_index_layout())
print("Avant : profondeur", qc.depth(), "|", dict(qc.count_ops()))
print("Après : profondeur", isa.depth(), "|", dict(isa.count_ops()))
print("Portes à 2 qubits :", isa.num_nonlocal_gates())
print("Durée estimée :", round(isa.estimate_duration(backend.target, unit="u"), 2), "µs")
print("Dont une mesure :", round(backend.target["measure"][(0,)].duration * 1e6, 2), "µs")
