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

Fix compiler adding phases to flux pulses #1099

Open
wants to merge 1 commit into
base: 0.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/qibolab/compilers/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
u3_rule,
z_rule,
)
from qibolab.pulses import PulseSequence, ReadoutPulse
from qibolab.pulses import DrivePulse, PulseSequence


@dataclass
Expand Down Expand Up @@ -131,7 +131,7 @@ def _compile_gate(
# shift start time and phase according to the global sequence
for pulse in gate_sequence:
pulse.start += start
if not isinstance(pulse, ReadoutPulse):
if isinstance(pulse, DrivePulse):
pulse.relative_phase += virtual_z_phases[pulse.qubit]
sequence.add(pulse)

Expand Down
4 changes: 2 additions & 2 deletions src/qibolab/dummy/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,12 @@
},
{
"type": "virtual_z",
"phase": 0.0,
"phase": 0.1,
"qubit": 1
},
{
"type": "virtual_z",
"phase": 0.0,
"phase": 0.2,
"qubit": 2
},
{
Expand Down
15 changes: 15 additions & 0 deletions tests/test_compilers_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,21 @@ def test_cz_to_sequence(platform):
assert sequence == test_sequence


def test_twocz_to_sequence(platform):
if (1, 2) not in platform.pairs:
pytest.skip(
f"Skipping CZ test for {platform} because pair (1, 2) is not available."
)

circuit = Circuit(3)
circuit.add(gates.CZ(1, 2))
circuit.add(gates.CZ(1, 2))

sequence = compile_circuit(circuit, platform)
assert sequence[0].relative_phase == 0
assert sequence[1].relative_phase == 0


def test_cnot_to_sequence():
platform = create_platform("dummy")
circuit = Circuit(4)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_dummy_execute_pulse_sequence_couplers():
result = platform.execute_pulse_sequence(sequence, options)

test_pulses = "PulseSequence\nFluxPulse(0, 30, 0.05, GaussianSquare(5, 0.75), flux-2, 2)\nCouplerFluxPulse(0, 30, 0.05, GaussianSquare(5, 0.75), flux_coupler-1, 1)"
test_phases = {1: 0.0, 2: 0.0}
test_phases = {1: 0.1, 2: 0.2}

assert test_pulses == cz.serial
assert test_phases == cz_phases
Expand Down
Loading