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

compiler: arguments with default value not working in delay_mu #2219

Open
fsagbuya opened this issue Sep 25, 2023 · 1 comment
Open

compiler: arguments with default value not working in delay_mu #2219

fsagbuya opened this issue Sep 25, 2023 · 1 comment

Comments

@fsagbuya
Copy link
Contributor

fsagbuya commented Sep 25, 2023

Bug Report

One-Line Summary

Error when passing argument (in this case with a type hint) with default value in delay_mu, also occur in simple arguments without the type hint.

Issue Details

Steps to Reproduce

  1. Run the sample code in dashboard or artiq_compile:
from artiq.experiment import *


class DelayTest(EnvExperiment):
    """delay_mu test with default arg value"""

    def build(self):
        self.setattr_device("core")

    @kernel
    def run(self):
        self.core.reset()
        self.delay_test()

    @kernel
    def delay_test(self, duration: TInt64 = 10):
        delay_mu(duration)

Expected Behavior

Will successfully compile/run. Current workaround requires running the method in a separate manner.

Sample:

    @kernel
    def run(self):
        self.core.reset()
        self.delay_test(10)

    @kernel
    def delay_test(self, duration: TInt64):
        delay_mu(duration)

Actual (undesired) Behavior

Returns an error log:

Traceback (most recent call last):
  File "/nix/store/vmk6vpqlcdr5qhrdq18qjliszi5zjwjh-python3.10-artiq-8.8463+e90cd31.beta/bin/.artiq_compile-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/artiq/frontend/artiq_compile.py", line 67, in main
    core.compile(exp.run, [exp_inst], {},
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/artiq/coredevice/core.py", line 110, in compile
    module = Module(stitcher,
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/artiq/compiler/module.py", line 75, in __init__
    iodelay_estimator.visit_fixpoint(src.typedtree)
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/artiq/compiler/transforms/iodelay_estimator.py", line 83, in visit_fixpoint
    self.visit(node)
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/pythonparser/algorithm.py", line 41, in visit
    return self._visit_one(obj)
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/pythonparser/algorithm.py", line 32, in _visit_one
    return getattr(self, visit_attr)(node)
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/artiq/compiler/transforms/iodelay_estimator.py", line 91, in visit_ModuleT
    self.visit(stmt)
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/pythonparser/algorithm.py", line 41, in visit
    return self._visit_one(obj)
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/pythonparser/algorithm.py", line 32, in _visit_one
    return getattr(self, visit_attr)(node)
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/artiq/compiler/transforms/iodelay_estimator.py", line 143, in visit_FunctionDefT
    self.visit_function(node.args, body, node.signature_type.find(), node.loc)
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/artiq/compiler/transforms/iodelay_estimator.py", line 102, in visit_function
    self.visit(body)
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/pythonparser/algorithm.py", line 39, in visit
    return [self.visit(elt) for elt in obj]
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/pythonparser/algorithm.py", line 39, in <listcomp>
    return [self.visit(elt) for elt in obj]
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/pythonparser/algorithm.py", line 41, in visit
    return self._visit_one(obj)
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/pythonparser/algorithm.py", line 34, in _visit_one
    return self.generic_visit(node)
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/pythonparser/algorithm.py", line 27, in generic_visit
    self.visit(getattr(node, field_name))
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/pythonparser/algorithm.py", line 41, in visit
    return self._visit_one(obj)
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/pythonparser/algorithm.py", line 32, in _visit_one
    return getattr(self, visit_attr)(node)
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/artiq/compiler/transforms/iodelay_estimator.py", line 314, in visit_CallT
    node.arg_exprs = {
  File "/nix/store/b8a1f7j5l7c4qqcj2z0712n5f520ffiq-python3-3.10.12-env/lib/python3.10/site-packages/artiq/compiler/transforms/iodelay_estimator.py", line 315, in <dictcomp>
    arg: self.evaluate(args[arg], abort=abort,
KeyError: 'duration'

Your System (omit irrelevant parts)

  • Operating System:
  • ARTIQ version: ARTIQ v8.8463+e90cd31.beta
@fsagbuya fsagbuya changed the title Compiler: Type hint with default value not working in delay_mu Compiler: Arguments with default value not working in delay_mu Sep 25, 2023
@fsagbuya fsagbuya changed the title Compiler: Arguments with default value not working in delay_mu compiler: arguments with default value not working in delay_mu Sep 25, 2023
@dnadlinger
Copy link
Collaborator

dnadlinger commented Sep 28, 2023

We should just strip out any remaining special handling of delays from the compiler; this has long been unused. delay_mu should just be handled the same as any other runtime intrinsic.

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

No branches or pull requests

2 participants