qiboteam / qibolab

Quantum hardware module and drivers for Qibo.
https://qibo.science
Apache License 2.0
43 stars 13 forks source link

Minor native & sequence improvements #1003

Closed alecandido closed 2 days ago

alecandido commented 3 weeks ago

The idea is to make it simpler to create sequences.

Currently, you have to do something like this:

qd_seq = natives.RX.create_sequence()
probe_seq = natives.MZ.create_sequence()
sequence = PulseSequence()
sequence.concatenate(qd_seq) 
sequence.concatenate(probe_seq)

(cf. conftest.py, the execute fixture)

A couple of proposals to make it simpler are:

It should be possible to then write it like the following:

q0 = natives  # assuming they are the natives for qubit 0
sequence = q0.RX() | q0.MZ()
stavros11 commented 2 weeks ago

@alecandido following the meeting last Wednesday, I understood that PulseSequence.concatenate in the last example pads the the sequence with delays so that the MZ plays after RX. However, the following example:

from qibolab import create_platform
from qibolab.sequence import PulseSequence

def sequence_print(sequence: PulseSequence):
    for ch, pulse in sequence:
        print(ch, pulse)
    print()

platform = create_platform("dummy")

q0 = platform.natives.single_qubit[0]
rx_sequence = q0.RX.create_sequence()
mz_sequence = q0.MZ.create_sequence()

sequence = PulseSequence()
sequence.concatenate(rx_sequence)
sequence.concatenate(mz_sequence)

sequence_print(rx_sequence)
sequence_print(mz_sequence)
sequence_print(sequence)

shows that there are no delays present in sequence.

I think we need to replace https://github.com/qiboteam/qibolab/blob/888753403e496f843d67dd398b3f8ec424ee3749/src/qibolab/sequence.py#L106

with

_synchronize(self, self.channels | other.channels) 

in order to get the delays.

alecandido commented 2 weeks ago

Yes, that's correct. I can add this change (and a test) in the PR that will implement this issue.

Two concatenated PulseSequence should actually start one after the other. If they need to be played in parallel (as it could be the case for different qubits) you should instead use .extend() (or the associated list operator, i.e. +, which will create a new sequence, same as | will do for .concatenate()).