Skip to content

Commit

Permalink
fix: Fix following introduction of CNOT native
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-pasquale committed Jan 26, 2024
1 parent 1faf3ce commit c03218d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ def _aquisition(
# Patch to get the coupler until the routines use QubitPair
if platform.couplers:
sequence.add(
cz.coupler_pulses(
platform.pairs[tuple(sorted(ordered_pair))].coupler.name
)
cz.coupler_pulses(platform.pairs[tuple(ordered_pair)].coupler.name)
)

if params.parking:
Expand Down
4 changes: 0 additions & 4 deletions src/qibocal/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,13 @@ def virtual_phases(phases: dict[QubitId, float], platform: Platform, pair: Qubit

def CZ_duration(duration: int, platform: Platform, pair: QubitPairId):
"""Update CZ duration for specific pair."""
if pair not in platform.pairs:
pair = (pair[1], pair[0])
for pulse in platform.pairs[pair].native_gates.CZ.pulses:
if pulse.qubit.name == pair[1]:
pulse.duration = int(duration)


def CZ_amplitude(amp: float, platform: Platform, pair: QubitPairId):
"""Update CZ amplitude for specific pair."""
if pair not in platform.pairs:
pair = (pair[1], pair[0])
for pulse in platform.pairs[pair].native_gates.CZ.pulses:
if pulse.qubit.name == pair[1]:
pulse.amplitude = float(amp)
Expand Down
2 changes: 1 addition & 1 deletion src/qibocal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def allocate_qubits_pairs(
platform: Optional[Platform], qubit_pairs_ids: list[tuple[QubitId, QubitId]]
) -> dict[tuple[QubitId, QubitId], QubitPair]:
"""Construct the map from the chosen id pairs to the corresponding physical qubit pairs available on the platform."""
return {tuple(qq): platform.pairs[tuple(sorted(qq))] for qq in qubit_pairs_ids}
return {tuple(qq): platform.pairs[tuple(qq)] for qq in qubit_pairs_ids}


def allocate_single_qubits_lists(
Expand Down
2 changes: 1 addition & 1 deletion tests/runcards/protocols.yml
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ actions:
- id: chevron id
priority: 0
operation: chevron
qubits: [[0, 2],[1,2],[3,2], [2,3]]
qubits: [[0, 2],[1,2]]
parameters:
amplitude_min: 0.1
amplitude_max: 0.6
Expand Down
15 changes: 8 additions & 7 deletions tests/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,15 @@ def test_virtual_phases_update(pair):

@pytest.mark.parametrize("pair", PAIRS)
def test_CZ_params_update(pair):
update.CZ_amplitude(RANDOM_FLOAT, PLATFORM, pair)
update.CZ_duration(RANDOM_INT, PLATFORM, pair)
if hasattr(PLATFORM.pairs[pair].native_gates, "CZ"):
if PLATFORM.pairs[pair].native_gates.CZ is not None:
update.CZ_amplitude(RANDOM_FLOAT, PLATFORM, pair)
update.CZ_duration(RANDOM_INT, PLATFORM, pair)

if PLATFORM.pairs[pair].native_gates.CZ is not None:
for pulse in PLATFORM.pairs[pair].native_gates.CZ.pulses:
if pulse.qubit.name == pair[1]:
assert pulse.duration == RANDOM_INT
assert pulse.amplitude == RANDOM_FLOAT
for pulse in PLATFORM.pairs[pair].native_gates.CZ.pulses:
if pulse.qubit.name == pair[1]:
assert pulse.duration == RANDOM_INT
assert pulse.amplitude == RANDOM_FLOAT


@pytest.mark.parametrize("qubit", QUBITS)
Expand Down

0 comments on commit c03218d

Please sign in to comment.