I tried to put some function names in a list and let the kernel to call those functions by traversing this list. And get some weird behavior.
Issue Details
Steps to Reproduce
Run the following code:
class DynamicFunction(EnvExperiment):
def build(self):
self.core = self.get_device('core')
self.ttl_2 = self.get_device('ttl2')
self.ttl_3 = self.get_device('ttl3')
self.action_list = []
def prepare(self):
self.action_list.append(getattr(self, 'pulse_1'))
self.action_list.append(getattr(self, 'pulse_2'))
# if replace 'pulse_2' with the following `pulse_3`, it works
# self.action_list.append(getattr(self, 'pulse_3'))
@kernel
def run(self):
self.init_device()
#self.run_static() # this one works
self.run_dynamic() # this does not, see text.
@kernel
def run_static(self):
self.pulse_1()
self.pulse_2()
@kernel
def run_dynamic(self):
for action in self.action_list:
action()
@kernel
def pulse_1(self):
self.ttl_2.pulse(10 * us)
delay(10 * us)
@kernel
def pulse_2(self):
with parallel:
self.ttl_2.pulse(10 * us)
self.ttl_3.pulse(15 * us)
delay(15 * us)
@kernel
def pulse_3(self):
self.ttl_3.pulse(10 * us)
delay(10 * us)
run_static function works nicely but run_dynamic does not work for some functions. and the debug information can't give me any help:
root:While compiling <repository>\NewFeatureTest\Dynamic_load_bug.py
<repository>\NewFeatureTest\Dynamic_load_bug.py:44:5-47:23: fatal: delay delay(15998 mu) was inferred for this function, but its delay is already constrained externally to delay(?)
@kernel
^^^^^^^
I guess it has something to do with the compiler?
Expected Behavior
run_dynamic should have the same behavior with run_static.
Bug Report
One-Line Summary
I tried to put some function names in a
list
and let the kernel to call those functions by traversing thislist
. And get some weird behavior.Issue Details
Steps to Reproduce
Run the following code:
run_static
function works nicely butrun_dynamic
does not work for some functions. and the debug information can't give me any help:I guess it has something to do with the compiler?
Expected Behavior
run_dynamic
should have the same behavior withrun_static
.Your System (omit irrelevant parts)