qiboteam / qibolab

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

drag pulse tunning routines not working with ZI drivers #837

Closed DavidSarlle closed 3 months ago

DavidSarlle commented 3 months ago

Thre routines for chracterizing the drag pulse (allXY drag pulse tuning and drag pulse tunning) are not working with ZI drivers present on qibolab main and using qibocal main. I have also tried with the @andrea-pasquale Pr https://github.com/qiboteam/qibocal/pull/689, but same error.

Both routines are raising the same error regarding rel_sigma:

  File "/nfs/users/david.fuentes/qibocal/src/qibocal/protocols/characterization/allxy/allxy_drag_pulse_tuning.py", line 82, in _acquisition
    results = platform.execute_pulse_sequence(
  File "/nfs/users/david.fuentes/qibolab/src/qibolab/platform.py", line 195, in execute_pulse_sequence
    return self._execute(sequence, options, **kwargs)
  File "/nfs/users/david.fuentes/qibolab/src/qibolab/platform.py", line 169, in _execute
    new_result = instrument.play(
  File "/nfs/users/david.fuentes/qibolab/src/qibolab/instruments/zhinst.py", line 611, in play
    self.experiment_flow(qubits, couplers, sequence, options)
  File "/nfs/users/david.fuentes/qibolab/src/qibolab/instruments/zhinst.py", line 599, in experiment_flow
    self.sequence_zh(sequence, qubits, couplers)
  File "/nfs/users/david.fuentes/qibolab/src/qibolab/instruments/zhinst.py", line 642, in sequence_zh
    zhsequence[f"{pulse.type.name.lower()}{pulse.qubit}"].append(ZhPulse(pulse))
  File "/nfs/users/david.fuentes/qibolab/src/qibolab/instruments/zhinst.py", line 151, in __init__
    self.zhpulse = select_pulse(pulse, pulse.type.name.lower())
  File "/nfs/users/david.fuentes/qibolab/src/qibolab/instruments/zhinst.py", line 97, in select_pulse
    sigma = pulse.shape.rel_sigma
AttributeError: 'str' object has no attribute 'rel_sigma'
alecandido commented 3 months ago

Thanks @DavidSarlle for the report. I suspect a bug in the pulse manipulation.

The problem is that the pulse.shape has not been evaluated (Shape.eval) at some point, and it's still a string. It should be some kind of deserialization problem.

I will reproduce it myself, it should be simple enough to isolate.

alecandido commented 3 months ago

Unfortunately, I tried with iqm5q, and I'm currently unable to connect (with qibolab_platforms_qrc@main).

This problem should be possible to be debugged without a connection, since you don't need to actually acquire results to reproduce it (it is happening while instantiating the sequence). However, at the moment a connection is always early requested, before doing anything else, and this is preventing to debug it locally (I tried to pretend to be connected, manually setting .is_connected = True and skipping the actual connection in various places, but it was more complicated than that).

Hopefully, it will be simpler to debug after @hay-k refactoring. And his PR (i.e. #797) might already solve the issue (since several simplifications are applied), though it is definitely not specific to this problem.

DavidSarlle commented 3 months ago

qibolab_platforms_qrc@main

Thanks @alecandido for debugging. If you use https://github.com/qiboteam/qibolab_platforms_qrc/pull/126, you should be able to connect to the instruments and reproduce the error

alecandido commented 3 months ago

I'm actually getting

RuntimeError: Cannot establish connection to <qibolab.instruments.zhinst.Zurich object at 0x73ddfd509930> instruments. Error captured: 'Could not connect to a Zurich Instruments data server on host 'localhost' and port 8004. Make sure that the server is running, host / port names are correct, API / DataServer versions match. Connection failed due to inaccessible port 8004 on host 'localhost'.'

trying to connect on zh_tests (that I expect to be the queue I was supposed to use to debug).

I will try with iqm5q.

alecandido commented 3 months ago

Ok, I reproduced the bug with iqm5q (we should really fix this unnecessary connection requirement...).

I will try to check with the debugger where the string is not being deserialized properly.

DavidSarlle commented 3 months ago

@alecandido thanks. The zh_test should be down. I also noticed that qblox06 is also up, and they should be down because the instruments are in use by other qpus. I do not know who bring them up...

alecandido commented 3 months ago

@alecandido thanks. The zh_test should be down. I also noticed that qblox06 is also up, and they should be down because the instruments are in use by other qpus. I do not know who bring them up...

Indeed, I thought that was the agreed protocol (if they are up, the middleware team is supposed to use those to debug). No worries, we sorted out :)

Concerning the bug, the problem is between Qibolab and Qibocal, i.e.:

Those functions are already deprecated in 0.2, and we're greatly simplifying the way Pulses are handled. Unfortunately, we're not ready enough to provide something to use, even experimentally.

My best suggestion to quickly patch this issue would be to change the create_RX_drag_pulse function, by assigning an actual instance of Drag, instead of using a string: https://github.com/qiboteam/qibolab/blob/2b7eb9e0ff07d02490c1cb12b96b0cf96fbfc635/src/qibolab/platform.py#L422 This is a proper fix for that function, since it should be the intended way of using that.

I'm not sure why the problem is found only with the ZI drivers, but I suppose that other drivers could be actually evaluating it? Not sure...

I will try the patch and report.

andrea-pasquale commented 3 months ago

Thre routines for chracterizing the drag pulse (allXY drag pulse tuning and drag pulse tunning) are not working with ZI drivers present on qibolab main and using qibocal main. I have also tried with the @andrea-pasquale Pr https://github.com/qiboteam/qibocal/pull/689, but same error.

Both routines are raising the same error regarding rel_sigma:


  File "/nfs/users/david.fuentes/qibocal/src/qibocal/protocols/characterization/allxy/allxy_drag_pulse_tuning.py", line 82, in _acquisition

    results = platform.execute_pulse_sequence(

  File "/nfs/users/david.fuentes/qibolab/src/qibolab/platform.py", line 195, in execute_pulse_sequence

    return self._execute(sequence, options, **kwargs)

  File "/nfs/users/david.fuentes/qibolab/src/qibolab/platform.py", line 169, in _execute

    new_result = instrument.play(

  File "/nfs/users/david.fuentes/qibolab/src/qibolab/instruments/zhinst.py", line 611, in play

    self.experiment_flow(qubits, couplers, sequence, options)

  File "/nfs/users/david.fuentes/qibolab/src/qibolab/instruments/zhinst.py", line 599, in experiment_flow

    self.sequence_zh(sequence, qubits, couplers)

  File "/nfs/users/david.fuentes/qibolab/src/qibolab/instruments/zhinst.py", line 642, in sequence_zh

    zhsequence[f"{pulse.type.name.lower()}{pulse.qubit}"].append(ZhPulse(pulse))

  File "/nfs/users/david.fuentes/qibolab/src/qibolab/instruments/zhinst.py", line 151, in __init__

    self.zhpulse = select_pulse(pulse, pulse.type.name.lower())

  File "/nfs/users/david.fuentes/qibolab/src/qibolab/instruments/zhinst.py", line 97, in select_pulse

    sigma = pulse.shape.rel_sigma

AttributeError: 'str' object has no attribute 'rel_sigma'

Thanks @DavidSarlle for opening the issue. Indeed I saw the same error when I was testing https://github.com/qiboteam/qibocal/pull/689. As @alecandido was saying the issue is related to the fact that the pulse shape is not evaluated. I have opened #835 to fix this issue in qibolab. If I remember correctly the PR is only missing a few tests and coverage.

alecandido commented 3 months ago

@andrea-pasquale sorry, I didn't notice there was already a PR. That's exactly what I was doing.

Please @DavidSarlle, just test @andrea-pasquale's PR, that should be the fix you were looking for.

DavidSarlle commented 3 months ago

Sorry @andrea-pasquale @alecandido I did not know that here was a PR in qibolab fixing this issue.

I have tried with https://github.com/qiboteam/qibolab/pull/835 and https://github.com/qiboteam/qibocal/pull/689 it works. Thanks @andrea-pasquale and @alecandido!

alecandido commented 3 months ago

Sorry @andrea-pasquale @alecandido I did not know that here was a PR in qibolab fixing this issue.

I actually forgot myself... (I received the notification, had a look, and forgot, ...)