Skip to content

Commit

Permalink
feat: Add GPI gate
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-pasquale committed Feb 15, 2024
1 parent 8bb0327 commit eed9857
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/qibolab/compilers/compiler.py
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
cnot_rule,
cz_rule,
gpi2_rule,
gpi_rule,
identity_rule,
measurement_rule,
rz_rule,
@@ -52,6 +53,7 @@ def default(cls):
gates.CZ: cz_rule,
gates.CNOT: cnot_rule,
gates.GPI2: gpi2_rule,
gates.GPI: gpi_rule,
gates.M: measurement_rule,
}
)
10 changes: 10 additions & 0 deletions src/qibolab/compilers/default.py
Original file line number Diff line number Diff line change
@@ -35,6 +35,16 @@ def gpi2_rule(gate, platform):
return sequence, {}


def gpi_rule(gate, platform):
"""Rule for GPI."""
qubit = gate.target_qubits[0]
theta = gate.parameters[0]
sequence = PulseSequence()
pulse = platform.create_RX_pulse(qubit, start=0, relative_phase=theta)
sequence.add(pulse)
return sequence, {}


def u3_rule(gate, platform):
"""U3 applied as RZ-RX90-RZ-RX90-RZ."""
qubit = gate.target_qubits[0]
14 changes: 14 additions & 0 deletions tests/test_compilers_default.py
Original file line number Diff line number Diff line change
@@ -104,6 +104,20 @@ def test_rz_to_sequence(platform):
assert len(sequence) == 0


def test_gpi_to_sequence(platform):
circuit = Circuit(1)
circuit.add(gates.GPI(0, phi=0.2))
sequence = compile_circuit(circuit, platform)
assert len(sequence.pulses) == 1
assert len(sequence.qd_pulses) == 1

RX_pulse = platform.create_RX_pulse(0, start=0, relative_phase=0.2)
s = PulseSequence(RX_pulse)

np.testing.assert_allclose(sequence.duration, RX_pulse.duration)
assert sequence.serial == s.serial


def test_gpi2_to_sequence(platform):
circuit = Circuit(1)
circuit.add(gates.GPI2(0, phi=0.2))

0 comments on commit eed9857

Please sign in to comment.