Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make execution parameters private #1052

Merged
merged 7 commits into from
Sep 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: Fix usage of execution parameters
  • Loading branch information
alecandido committed Sep 19, 2024
commit 15abc19a7f66938d8e2c6c03a0175b0534f6748d
16 changes: 5 additions & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -6,13 +6,7 @@
import numpy.typing as npt
import pytest

from qibolab import (
AcquisitionType,
AveragingMode,
ExecutionParameters,
Platform,
create_platform,
)
from qibolab import AcquisitionType, AveragingMode, Platform, create_platform
from qibolab._core.platform.load import PLATFORMS
from qibolab._core.sequence import PulseSequence
from qibolab._core.sweeper import ParallelSweepers, Parameter, Sweeper
@@ -114,7 +108,7 @@ def wrapped(
sequence: Optional[PulseSequence] = None,
target: Optional[int] = None,
) -> npt.NDArray:
options = ExecutionParameters(
options = dict(
nshots=nshots,
acquisition_type=acquisition_type,
averaging_mode=averaging_mode,
@@ -124,8 +118,8 @@ def wrapped(
natives = connected_platform.natives.single_qubit[0]

if sequence is None:
qd_seq = natives.RX.create_sequence()
probe_seq = natives.MZ.create_sequence()
qd_seq = natives.RX()
probe_seq = natives.MZ()
probe_pulse = probe_seq[0][1].probe
acq = probe_seq[0][1].acquisition
wrapped.acquisition_duration = acq.duration
@@ -151,7 +145,7 @@ def wrapped(
assert target is not None
assert sweepers is not None

results = connected_platform.execute([sequence], options, sweepers)
results = connected_platform.execute([sequence], sweepers, **options)
return results[target]

return wrapped
3 changes: 1 addition & 2 deletions tests/integration/test_sequence.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from qibolab import create_platform
from qibolab._core.execution_parameters import ExecutionParameters
from qibolab._core.pulses import Delay


@@ -33,7 +32,7 @@ def test_sequence_creation():
# ----------------------------------------------------

nshots = 17
res = platform.execute([seq], ExecutionParameters(nshots=nshots))
res = platform.execute([seq], nshots=nshots)

for r in res.values():
assert r.shape == (nshots,)
19 changes: 8 additions & 11 deletions tests/test_dummy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from qibolab import AcquisitionType, ExecutionParameters, create_platform
from qibolab import AcquisitionType, create_platform
from qibolab._core.platform.platform import Platform
from qibolab._core.pulses import Delay, GaussianSquare, Pulse
from qibolab._core.sequence import PulseSequence
@@ -29,24 +29,22 @@ def test_dummy_execute_coupler_pulse(platform: Platform):
)
sequence.append((channel, pulse))

options = ExecutionParameters(nshots=None)
_ = platform.execute([sequence], options)
_ = platform.execute([sequence], nshots=None)


def test_dummy_execute_pulse_sequence_couplers():
platform = create_platform("dummy")
sequence = PulseSequence()

natives = platform.natives
cz = natives.two_qubit[(1, 2)].CZ.create_sequence()
cz = natives.two_qubit[(1, 2)].CZ()

sequence.concatenate(cz)
sequence.append((platform.qubits[0].probe, Delay(duration=40)))
sequence.append((platform.qubits[2].probe, Delay(duration=40)))
sequence.concatenate(natives.single_qubit[0].MZ.create_sequence())
sequence.concatenate(natives.single_qubit[2].MZ.create_sequence())
options = ExecutionParameters(nshots=None)
_ = platform.execute([sequence], options)
sequence.concatenate(natives.single_qubit[0].MZ())
sequence.concatenate(natives.single_qubit[2].MZ())
_ = platform.execute([sequence], nshots=None)


@pytest.mark.parametrize(
@@ -61,9 +59,8 @@ def test_dummy_execute_pulse_sequence_unrolling(
natives = platform.natives
sequences = []
for _ in range(nsequences):
sequences.append(natives.single_qubit[0].MZ.create_sequence())
options = ExecutionParameters(nshots=nshots, acquisition_type=acquisition)
result = platform.execute(sequences, options)
sequences.append(natives.single_qubit[0].MZ())
result = platform.execute(sequences, nshots=nshots, acquisition_type=acquisition)
assert len(next(iter(result.values()))) == nshots
for r in result.values():
if acquisition is AcquisitionType.INTEGRATION: