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

debugging when JIT a compiled function is derived from string exec #7370

Open
chaoming0625 opened this issue Sep 5, 2021 · 5 comments
Open

Comments

@chaoming0625
Copy link


Feature request

Currently, Numba does not have a good mode to debug a jitted function without source code. For example, when I have the following compiled code:

import numba

code = '''
def f(a, b):
  a[0] = b
'''

scope = {}
exec(compile(code, '', 'exec'), scope)
f = numba.njit(scope['f'])

After I jit the compiled function and run it,

f(1, 2)

the code has an error, and the numba reports:

numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
No implementation of function Function(<built-in function setitem>) found for signature:
 
 >>> setitem(int64, Literal[int](0), int64)
 
There are 16 candidate implementations:
  - Of which 16 did not match due to:
  Overload of function 'setitem': File: <numerous>: Line N/A.
    With argument(s): '(int64, int64, int64)':
   No match.

During: typing of staticsetitem at  (3)

File "D:\codes\Projects\BrainPy\develop\test\numba", line 3:
<source missing, REPL/exec in use?>

Numba cannot report where the error is raised, because <source missing, REPL/exec in use?>

When the compiled function is a large program, such debugging is very very difficult!!!

Can we support the error debugging for such compiled function in a more nice way? For example, when I jit the compiled function, I can provide the souce code:

f = numba.njit(scope['f'], source_code=code)

Thank you very much!

@gmarkall
Copy link
Member

gmarkall commented Sep 6, 2021

This is an interesting idea - we'll discuss it at the triage meeting today.

@chaoming0625
Copy link
Author

@gmarkall Thank you very much.

Currently, I intensely use this kind of way to jit compiled functions. After I recursively jit nested compiled functions, debugging is very very difficult!

@stuartarchibald stuartarchibald changed the title debug when JIT a compiled function debugging when JIT a compiled function is derived from string exec Sep 6, 2021
@stuartarchibald
Copy link
Contributor

Thanks for the request. Have updated the title to reflect the need to link string source to debug output. Another option might be to patch the code objects and inject into linecache.

@github-actions
Copy link

github-actions bot commented Oct 7, 2021

This issue is marked as stale as it has had no activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with any updates and confirm that this issue still needs to be addressed.

@github-actions github-actions bot added the stale Marker label for stale issues. label Oct 7, 2021
@gmarkall gmarkall removed needtriage stale Marker label for stale issues. labels Oct 7, 2021
@gmarkall
Copy link
Member

gmarkall commented Oct 7, 2021

I've removed needtriage so this won't go stale again.

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

3 participants