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

Errors and deprecation warnings from numba 0.58 #14160

Closed
bdice opened this issue Sep 21, 2023 · 8 comments · Fixed by #14616
Closed

Errors and deprecation warnings from numba 0.58 #14160

bdice opened this issue Sep 21, 2023 · 8 comments · Fixed by #14616
Assignees
Labels
bug Something isn't working Python Affects Python cuDF API.

Comments

@bdice
Copy link
Contributor

bdice commented Sep 21, 2023

The release of numba 0.58 has surfaced several errors and deprecation warnings. Below is an example:

numba.core.errors.TypingError: Internal error at resolving type of attribute "sum" of "group".
...
numba.core.errors.NumbaPendingDeprecationWarning: Failed in cuda mode pipeline (step: nopython frontend)
Code using Numba extension API maybe depending on 'old_style' error-capturing, which is deprecated and will be replaced by 'new_style' in a future release. See details at https://numba.readthedocs.io/en/latest/reference/deprecation.html#deprecation-of-old-style-numba-captured-errors

See details for a full log.

Details

____________________ test_groupby_apply_return_df[<lambda>] ____________________
[gw0] linux -- Python 3.10.13 /pyenv/versions/3.10.13/bin/python

typingctx = <numba.cuda.target.CUDATypingContext object at 0x7f72be9a3340>
targetctx = <numba.cuda.target.CUDATargetContext object at 0x7f7152cdb100>
interp = <numba.core.ir.FunctionIR object at 0x7f7152b50a60>
args = (Record([('a', {'type': Group(int64, int64), 'offset': 0, 'alignment': None, 'title': None, }), ('b', {'type': Group(int64, int64), 'offset': 24, 'alignment': None, 'title': None, })], 48, True),)
return_type = None, locals = {}, raise_errors = True

    def type_inference_stage(typingctx, targetctx, interp, args, return_type,
                             locals={}, raise_errors=True):
        if len(args) != interp.arg_count:
            raise TypeError("Mismatch number of argument types")
        warnings = errors.WarningsFixer(errors.NumbaWarning)
    
        infer = typeinfer.TypeInferer(typingctx, interp, warnings)
        callstack_ctx = typingctx.callstack.register(targetctx.target, infer,
                                                     interp.func_id, args)
        # Setup two contexts: 1) callstack setup/teardown 2) flush warnings
        with callstack_ctx, warnings:
            # Seed argument types
            for index, (name, ty) in enumerate(zip(interp.arg_names, args)):
                infer.seed_argument(name, index, ty)
    
            # Seed return type
            if return_type is not None:
                infer.seed_return(return_type)
    
            # Seed local types
            for k, v in locals.items():
                infer.seed_type(k, v)
    
            infer.build_constraint()
            # return errors in case of partial typing
>           errs = infer.propagate(raise_errors=raise_errors)

/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/typed_passes.py:91: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <numba.core.typeinfer.TypeInferer object at 0x7f7153827d60>
raise_errors = True

    def propagate(self, raise_errors=True):
        newtoken = self.get_state_token()
        oldtoken = None
        # Since the number of types are finite, the typesets will eventually
        # stop growing.
    
        while newtoken != oldtoken:
            self.debug.propagate_started()
            oldtoken = newtoken
            # Errors can appear when the type set is incomplete; only
            # raise them when there is no progress anymore.
            errors = self.constraints.propagate(self)
            newtoken = self.get_state_token()
            self.debug.propagate_finished()
        if errors:
            if raise_errors:
                force_lit_args = [e for e in errors
                                  if isinstance(e, ForceLiteralArg)]
                if not force_lit_args:
>                   raise errors[0]
E                   numba.core.errors.TypingError: Internal error at resolving type of attribute "sum" of "group".
E                   'sum'
E                   During: typing of get attribute at /__w/cudf/cudf/python/cudf/cudf/tests/test_groupby.py (678)
E                   Enable logging at debug level for details.
E                   
E                   File "python/cudf/cudf/tests/test_groupby.py", line 678:
E                       def func(df):
E                           <source elided>
E                   
E                   @pytest.mark.parametrize("func", [lambda group: group.sum()])
E                   ^

/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/typeinfer.py:1086: TypingError

During handling of the above exception, another exception occurred:

func = <function <lambda> at 0x7f718596d750>

    @pytest.mark.parametrize("func", [lambda group: group.sum()])
    def test_groupby_apply_return_df(func):
        # tests a UDF that reduces over a dataframe
        # and produces a series with the original column names
        # as its index, such as lambda group: group.sum() + group.min()
        df = cudf.DataFrame({"a": [1, 1, 2, 2], "b": [1, 2, 3, 4]})
        pdf = df.to_pandas()
    
        expect = pdf.groupby("a").apply(func)
>       got = df.groupby("a").apply(func)

python/cudf/cudf/tests/test_groupby.py:687: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/pyenv/versions/3.10.13/lib/python3.10/site-packages/nvtx/nvtx.py:115: in inner
    result = func(*args, **kwargs)
/pyenv/versions/3.10.13/lib/python3.10/site-packages/cudf/core/groupby/groupby.py:1420: in apply
    if (not grouped_values._has_nulls) and _can_be_jitted(
/pyenv/versions/3.10.13/lib/python3.10/site-packages/cudf/core/udf/groupby_utils.py:226: in _can_be_jitted
    _get_udf_return_type(dataframe_group_type, func, args)
/pyenv/versions/3.10.13/lib/python3.10/site-packages/nvtx/nvtx.py:115: in inner
    result = func(*args, **kwargs)
/pyenv/versions/3.10.13/lib/python3.10/site-packages/cudf/core/udf/utils.py:88: in _get_udf_return_type
    ptx, output_type = cudautils.compile_udf(func, compile_sig)
/pyenv/versions/3.10.13/lib/python3.10/site-packages/cudf/utils/cudautils.py:126: in compile_udf
    ptx_code, return_type = cuda.compile_ptx_for_current_device(
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/cuda/compiler.py:283: in compile_ptx_for_current_device
    return compile_ptx(pyfunc, sig, debug=debug, lineinfo=lineinfo,
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/compiler_lock.py:35: in _acquire_compile_lock
    return func(*args, **kwargs)
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/cuda/compiler.py:253: in compile_ptx
    cres = compile_cuda(pyfunc, return_type, args, debug=debug,
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/compiler_lock.py:35: in _acquire_compile_lock
    return func(*args, **kwargs)
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/cuda/compiler.py:194: in compile_cuda
    cres = compiler.compile_extra(typingctx=typingctx,
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/compiler.py:770: in compile_extra
    return pipeline.compile_extra(func)
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/compiler.py:461: in compile_extra
    return self._compile_bytecode()
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/compiler.py:529: in _compile_bytecode
    return self._compile_core()
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/compiler.py:508: in _compile_core
    raise e
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/compiler.py:495: in _compile_core
    pm.run(self.state)
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/compiler_machinery.py:368: in run
    raise patched_exception
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/compiler_machinery.py:356: in run
    self._runPass(idx, pass_inst, state)
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/compiler_lock.py:35: in _acquire_compile_lock
    return func(*args, **kwargs)
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/compiler_machinery.py:311: in _runPass
    mutated |= check(pss.run_pass, internal_state)
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/compiler_machinery.py:273: in check
    mangled = func(compiler_state)
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/typed_passes.py:110: in run_pass
    typemap, return_type, calltypes, errs = type_inference_stage(
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/typed_passes.py:76: in type_inference_stage
    with callstack_ctx, warnings:
/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/errors.py:512: in __exit__
    self.flush()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <numba.core.errors.WarningsFixer object at 0x7f71720e0af0>

    def flush(self):
        """
        Emit all stored warnings.
        """
        def key(arg):
            # It is possible through codegen to create entirely identical
            # warnings, this leads to comparing types when sorting which breaks
            # on Python 3. Key as str() and if the worse happens then `id`
            # creates some uniqueness
            return str(arg) + str(id(arg))
    
        for (filename, lineno, category), messages in sorted(
                self._warnings.items(), key=key):
            for msg in sorted(messages):
>               warnings.warn_explicit(msg, category, filename, lineno)
E               numba.core.errors.NumbaPendingDeprecationWarning: Failed in cuda mode pipeline (step: nopython frontend)
E               Code using Numba extension API maybe depending on 'old_style' error-capturing, which is deprecated and will be replaced by 'new_style' in a future release. See details at https://numba.readthedocs.io/en/latest/reference/deprecation.html#deprecation-of-old-style-numba-captured-errors
E               Exception origin:
E                 File "/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/types/npytypes.py", line 189, in typeof
E                   return self.fields[key].type

/pyenv/versions/3.10.13/lib/python3.10/site-packages/numba/core/errors.py:505: NumbaPendingDeprecationWarning

https://github.com/rapidsai/cudf/actions/runs/6264918730/job/17013087530?pr=14156#step:9:1773

@bdice bdice added bug Something isn't working Python Affects Python cuDF API. labels Sep 21, 2023
@bdice
Copy link
Contributor Author

bdice commented Sep 21, 2023

cc: @gmarkall @brandon-b-miller

@brandon-b-miller
Copy link
Contributor

Taking a look at this 👍

@brandon-b-miller brandon-b-miller self-assigned this Sep 21, 2023
rapids-bot bot pushed a commit that referenced this issue Sep 21, 2023
…ings-as-errors. (#14156)

Closes #14155.

Related: #14160.

(Will newer numpy support be backported to pandas 1.x? edit: no, see below)

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - Vyas Ramasubramani (https://github.com/vyasr)
  - Benjamin Zaitlen (https://github.com/quasiben)
  - Ray Douglass (https://github.com/raydouglass)
  - GALI PREM SAGAR (https://github.com/galipremsagar)

URL: #14156
@brandon-b-miller
Copy link
Contributor

Having poked around a bit I believe some of the changes needed to fix this overlap/are related to changes in #13854. I think it might fix some of these things outright, or at the very least it centralizes the kinds of numba errors we raise in such a way that we could probably fix things in fewer places.

@bdice
Copy link
Contributor Author

bdice commented Nov 30, 2023

@brandon-b-miller Is #13854 ready to merge? It would need to retarget 24.02. I'd like to unpin numba<0.58 for the 24.02 release so ironing out any known issues would be good.

@brandon-b-miller
Copy link
Contributor

Thanks for bumping this. Will investigate and see what if anything still needs to be done here.

@brandon-b-miller
Copy link
Contributor

The addition of this configuration option in #13854 seems to have resolved this.

@bdice
Copy link
Contributor Author

bdice commented Dec 12, 2023

@brandon-b-miller Can this issue be closed, then? Or should it be closed by #14616?

@brandon-b-miller
Copy link
Contributor

brandon-b-miller commented Dec 12, 2023

I think it should be closed by #14616. Will update

rapids-bot bot pushed a commit that referenced this issue Dec 18, 2023
This PR removes the constraint for numba 0.58 in our dependencies. 

Closes #14160

Authors:
  - https://github.com/brandon-b-miller

Approvers:
  - Bradley Dice (https://github.com/bdice)
  - GALI PREM SAGAR (https://github.com/galipremsagar)
  - Ray Douglass (https://github.com/raydouglass)

URL: #14616
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants