Skip to content

Commit

Permalink
fix: drop compiler phase from flux pulses
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros11 committed Nov 13, 2024
1 parent 49b6572 commit a678413
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
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

0 comments on commit a678413

Please sign in to comment.