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

Minor native & sequence improvements #1003

Closed
2 tasks done
alecandido opened this issue Aug 24, 2024 · 2 comments · Fixed by #1026
Closed
2 tasks done

Minor native & sequence improvements #1003

alecandido opened this issue Aug 24, 2024 · 2 comments · Fixed by #1026
Assignees
Milestone

Comments

@alecandido
Copy link
Member

alecandido commented Aug 24, 2024

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:

  • alias Native.create_sequence() with .__call__()
  • alias PulseSequence.concatenate() with .__or__()
    • the true alias for .concatenate() will be .__ior__(), since the operation is in-place
    • but we can make s1 | s2 just by creating a new sequence:
      s = s1.copy()
      s |= s2

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()
@alecandido alecandido added this to the Qibolab 0.2.0 milestone Aug 24, 2024
@alecandido alecandido self-assigned this Aug 26, 2024
@stavros11
Copy link
Member

@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

_synchronize(self, other.channels)

with

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

in order to get the delays.

@alecandido
Copy link
Member Author

alecandido commented Aug 30, 2024

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()).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants