Skip to content

Commit

Permalink
feat: Update for virtual phases
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-pasquale committed Nov 15, 2024
1 parent b7afb14 commit 5d236bf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/qibocal/protocols/rabi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def fit_amplitude_function(
)
if signal is False:
perr = np.sqrt(np.diag(perr))
if y_limits is not None and x_limits is not None:
if None not in y_limits and None not in x_limits:
popt = [
y_limits[0] + (y_limits[1] - y_limits[0]) * popt[0],
(y_limits[1] - y_limits[0]) * popt[1],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ def _plot(data: ChevronData, fit: ChevronResults, target: QubitPairId):
def _update(results: ChevronResults, platform: Platform, target: QubitPairId):
if isinstance(target, list):
target = tuple(target)

if target not in results.duration:
target = (target[1], target[0])

getattr(update, f"{results.native}_duration")(
results.duration[target], platform, target
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,12 +474,10 @@ def _plot(data: VirtualZPhasesData, fit: VirtualZPhasesResults, target: QubitPai


def _update(results: VirtualZPhasesResults, platform: Platform, target: QubitPairId):
# FIXME: quick fix for qubit order
qubit_pair = tuple(sorted(target))
target = tuple(sorted(target))
# update.virtual_phases(
# results.virtual_phase[target], results.native, platform, target
# )
update.virtual_phases(
results.virtual_phase[target], results.native, platform, target
)
getattr(update, f"{results.native}_duration")(
results.flux_pulse_duration[target], platform, target
)
Expand Down
47 changes: 25 additions & 22 deletions src/qibocal/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np
from pydantic import BaseModel
from qibolab import Platform
from qibolab import Platform, PulseSequence, VirtualZ

from qibocal.auto.operation import QubitId, QubitPairId

Expand Down Expand Up @@ -112,43 +112,46 @@ def readout_fidelity(fidelity: float, platform: Platform, qubit: QubitId):
def virtual_phases(
phases: dict[QubitId, float], native: str, platform: Platform, pair: QubitPairId
):
pass
# """Update virtual phases for given qubits in pair in results."""
# virtual_z_pulses = {
# pulse.qubit.name: pulse
# for pulse in getattr(platform.pairs[pair].native_gates, native).pulses
# if isinstance(pulse, VirtualZPulse)
# }
# for qubit_id, phase in phases.items():
# if qubit_id in virtual_z_pulses:
# virtual_z_pulses[qubit_id].phase = phase
# else:
# virtual_z_pulses[qubit_id] = VirtualZPulse(
# phase=phase, qubit=platform.qubits[qubit_id]
# )
# getattr(platform.pairs[pair].native_gates, native).pulses.append(
# virtual_z_pulses[qubit_id]
# )
native_sequence = getattr(platform.natives.two_qubit[pair], native)
new_native = PulseSequence()
if len(native_sequence) > 1:
new_native += native_sequence[0]
else:
new_native = native_sequence
for qubit, phase in phases.items():
new_native.append((platform.qubits[qubit].drive, VirtualZ(phase=phase)))

platform.update(
{f"native_gates.two_qubit.{f'{pair[0]}-{pair[1]}'}.{native}": new_native}
)


def CZ_duration(duration: int, platform: Platform, pair: QubitPairId):
"""Update CZ duration for specific pair."""
platform.update({f"native_gates.two_qubit.{pair}.CZ.0.1.duration": duration})
platform.update(
{f"native_gates.two_qubit.{f'{pair[0]}-{pair[1]}'}.CZ.0.1.duration": duration}
)


def CZ_amplitude(amp: float, platform: Platform, pair: QubitPairId):
"""Update CZ amplitude for specific pair."""
platform.update({f"native_gates.two_qubit.{pair}.CZ.0.1.amp": amp})
platform.update(
{f"native_gates.two_qubit.{f'{pair[0]}-{pair[1]}'}.CZ.0.1.amplitude": amp}
)


def iSWAP_duration(duration: int, platform: Platform, pair: QubitPairId):
"""Update iSWAP_duration duration for specific pair."""
platform.update({f"native_gates.two_qubit.{pair}.CZ.0.1.duration": duration})
platform.update(
{f"native_gates.two_qubit.{f'{pair[0]}-{pair[1]}'}.CZ.0.1.duration": duration}
)


def iSWAP_amplitude(amp: float, platform: Platform, pair: QubitPairId):
"""Update iSWAP_duration amplitude for specific pair."""
platform.update({f"native_gates.two_qubit.{pair}.CZ.0.1.amp": amp})
platform.update(
{f"native_gates.two_qubit.{f'{pair[0]}-{pair[1]}'}.CZ.0.1.amplitude": amp}
)


def t1(t1: int, platform: Platform, qubit: QubitId):
Expand Down

0 comments on commit 5d236bf

Please sign in to comment.