[go: up one dir, main page]

Draft: Only on change decorator for rpc calls

Description

This MR adds a decorator that only runs the actual function content if the parameters changed compared to the previous call. We use this construct for example for an awg which takes a complete random amount of time to program but only needs to be programed sometimes when some parameter changes that could occur within a chunk. The decorator can be used in non-async rpc calls or in host phases.

In the following example, the sleep (which delays the kernel execution by this time) is only called when one of the parameters changes.

    @rpc
    @only_on_change
    def test(self,a,b):
        time.sleep(1)

    @kernel
    def step(self, point):
        time0 = self.core.get_rtio_counter_mu()
        self.test(point.test1,point.test2)
        print(self.core.get_rtio_counter_mu()-time0)

I think it is quite useful but I can not really tell if there will be broader use which would justify putting it in atomiq.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Merge request reports

Loading