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
RecursionError in parfor prelowering #9182
Comments
CC @DrTodd13 |
I have a minimized reproducer that does not use PyReason: import numba
from numba import prange
from numba.types import ListType, Tuple, intp
@numba.njit
def _sink(x):
pass
@numba.njit(cache=False, parallel=True)
def _ground_node_rule(
clauses,
nodes,
):
for piter in prange(len(nodes)):
for clause in clauses:
clause_type = clause[0]
clause_variables = clause[2]
if clause_type == 0:
clause_var_1 = clause_variables[0]
elif len(clause_variables) == 2:
clause_var_1, clause_var_2 = (
clause_variables[0],
clause_variables[1],
)
elif len(clause_variables) == 4:
pass
if clause_type == 1:
_sink(clause_var_1)
_sink(clause_var_2)
_ground_node_rule.compile(
(
ListType(Tuple([intp, intp, ListType(intp)])),
ListType(intp),
)
) |
@DrTodd13, I hacked around the problem with sklam@19296a8 but I don't know if there's a deeper problem that I am just patching over; e.g. there is no reduction here. |
@sklam Indeed, there is no reduction there. Right now, we look for reductions among the variables that cross the parfor boundary. These are the parfor params. In this case, in the Python source you don't see clause_var_1 outside the prange but Numba seems to be inserting clause_var_1 = null() in the IR before the parfor and so it is being treated as input to the parfor. I think this is the core of the problem. I'm not sure if this cyclic dependency can happen in a true reduction case so not sure your patch is useful. |
Hi @sklam . I've been thinking about this one and I had some ideas and explored them but in the end didn't like them. The solution you wrote here seems a reasonable workaround. Can you just make a PR out of your solution and ask for my review? |
PR opened at #9244 |
Reporting a bug
visible in the change log (https://github.com/numba/numba/blob/main/CHANGE_LOG).
i.e. it's possible to run as 'python bug.py'.
Original discourse thread: https://numba.discourse.group/t/maximum-recursion-depth-exceeded-while-using-prange/2107
Reproducer:
Get pyreason:
Use Numba: b96eab1
Run this script:
RecursionError is coming from
numba/numba/parfors/parfor.py
Lines 3830 to 3833 in b96eab1
defs
. Printingvar.name
inlookup()
shows:Source for
_ground_node_rule
is at https://github.com/lab-v2/pyreason/blob/80fac257a0981cd758927b8c0232f2c37451976d/pyreason/scripts/interpretation/interpretation_parallel.py#L720. The function is complicated and I suspect the problem requires such complicated function to appear.The text was updated successfully, but these errors were encountered: