zhinst / zhinst-qcodes

QCoDeS drivers for Zurich Instruments devices
MIT License
9 stars 10 forks source link

run() and compile() methods of zhinst.qcodes.control.drivers.hdawg.AWG do not support 2x4 and 1x8 channelgrouping #25

Open haroldmeerwaldt opened 2 years ago

haroldmeerwaldt commented 2 years ago

Hi there,

I would like to use the 1x8 channelgrouping of the HDAWG8, so I can run programs from all 8 outputs synchronized.

The zhinst.qcodes HDAWG driver has 4 qcodes InstrumentChannels of class zhinst.qcodes.control.drivers.hdawg.AWG, regardless of channelgrouping, matching the 4 physical FPGAs I imagine.

If I switch to 1x8 channelgrouping, some methods work fine on the 4 InstrumentChannels (e.g. outputs). The run() method executes, but does not do anything (perhaps the set_sequence_params method as well) . The compile method fails with the following error:

ERROR: hdawg.awgs[3].compile()
hdawg-awg-3: Sequencer status: ELF upload failed!
Traceback (most recent call last):

  File "D:\users\hw_sw_integration\projects\low-level-software\untitled1.py", line 27, in <module>
    hdawg.awgs[3].compile()

  File "D:\users\hw_sw_integration\venv-3.9\lib\site-packages\zhinst\qcodes\control\drivers\hdawg.py", line 256, in compile
    self._awg.compile()

  File "D:\users\hw_sw_integration\venv-3.9\lib\site-packages\zhinst\toolkit\control\drivers\base\awg.py", line 303, in compile
    _logger.error(

  File "D:\users\hw_sw_integration\venv-3.9\lib\site-packages\zhinst\toolkit\interface\interface.py", line 193, in error
    raise LoggerModule.ToolkitError(msg)

ToolkitError: hdawg-awg-3: Sequencer status: ELF upload failed!

The following script will reproduce the error:

from zhinst.qcodes import HDAWG

hdawg = HDAWG("hdawg", "DEV8049")

hdawg.system.awg.channelgrouping(0)  # 4x2 channelgrouping

hdawg.awgs[3].set_sequence_params(sequence_type="Custom", program="")
hdawg.awgs[3].compile()
hdawg.awgs[3].run()
hdawg.awgs[3].output1("on")
hdawg.awgs[3].output1("off")
hdawg.awgs[3].stop()

hdawg.system.awg.channelgrouping(2)  # 1x8 channelgrouping

hdawg.awgs[3].set_sequence_params(sequence_type="Custom", program="")
hdawg.awgs[3].compile()  # <-- gives error
hdawg.awgs[3].run()
hdawg.awgs[3].output1("on")
hdawg.awgs[3].output1("off")
hdawg.awgs[3].stop()

If I take the LabOne interface as guidance, it makes perfect sense that I cannot do this, because there is only 1 AWG sequencer available. From the point of the qcodes driver, I would expect to be able to use the 4 InstrumentChannels, regardless of channelgrouping. I could switch back and forth between AWG channels, but it's not so pretty. For example, the following works:

hdawg.system.awg.channelgrouping(2)

hdawg.awgs[0].set_sequence_params(sequence_type="Custom", program="")
hdawg.awgs[0].compile()
hdawg.awgs[0].run()
hdawg.awgs[3].output1("on")
hdawg.awgs[3].output1("off")
hdawg.awgs[0].stop()

Would it be possible to have hdawg.awgs[0:4] point to the corresponding AWG sequencer, depending on the channelgrouping?

For compile, I am thinking this would mean changing self._index in this line to point to the sequencer: https://github.com/zhinst/zhinst-toolkit/blob/bdeabc0d0e382246f82c9fe758631d43f54ada65/src/zhinst/toolkit/control/drivers/base/awg.py#L262

For run, this would mean changing self._index here: https://github.com/zhinst/zhinst-toolkit/blob/bdeabc0d0e382246f82c9fe758631d43f54ada65/src/zhinst/toolkit/control/drivers/hdawg.py#L342

And I think this would involve changes for all other functionality in the zhinst.toolkit.control.drivers.hdawg.AWG class that uses f"awgs/{self._index}/"

Please let me know what you think.

Sincerely, Harold

tobiasah commented 2 years ago

Thanks for raising this issue. From a first glimpse I would say it sound like a good idea and should be a small adjustment.

I will look into this a bit deeper and also discuss this with our application scientist.

I will keep you updated here. (FYI since we are doing a refactoring of the toolkit and qcodes drivers at the moment it might take until the next LabOne Release end of February before we can ship a proper fix)

haroldmeerwaldt commented 2 years ago

Okay, great. I discussed the use case with Florian a bit earlier. Thanks for the heads up on the timing! For now I'll just switch between InstrumentChannels.

tobiasah commented 2 years ago

@haroldmeerwaldt I am happy to inform you that we have taken the initiative to refactor not only our QCoDeS driver but also zhinst-toolkit. We had some in depth discussions with our application scientists about you proposal. Since the channel grouping is something unique with the HDAWG we decided not to make any automatic channel resolving based on the grouping mode.

I will leave that issue open so that other people can see how one could get around that problem.