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

[BUG] std does not compute when using rolling window #2757

Closed
raykallen opened this issue Sep 8, 2019 · 3 comments
Closed

[BUG] std does not compute when using rolling window #2757

raykallen opened this issue Sep 8, 2019 · 3 comments
Assignees
Labels
feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. Python Affects Python cuDF API.

Comments

@raykallen
Copy link

Describe the bug
cannot compute std over a rolling window in cuDF
NotImplementedError: <class 'cudf.dataframe.string.StringColumn'>

Steps/Code to reproduce bug

df = cudf.Series([1,1,1,8,8,8])
df.rolling(3).mean()    # <--- this works correctly
df.rolling(3).std()     # <--- this produces an error

Expected behavior
returns standard deviation over the rolling window

0 null
1 null
2 0
3 4.041452
4 4.041452
5 0

Environment overview (please complete the following information)

  • Environment location: Docker
  • Method of cuDF install: conda

Environment details
cudf version 0.9.0

@raykallen raykallen added Needs Triage Need team to review and classify bug Something isn't working labels Sep 8, 2019
@kkraus14 kkraus14 added Python Affects Python cuDF API. feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. and removed Needs Triage Need team to review and classify bug Something isn't working labels Sep 16, 2019
@kkraus14
Copy link
Collaborator

This is still an issue as of the 0.14 release.

@kkraus14
Copy link
Collaborator

@shwina kicking over to you since I think you're the most familiar with rolling. We should more gracefully error, here's the current stacktrace I get with the above:

In [4]: df.rolling(3).std()
---------------------------------------------------------------------------
TypingError                               Traceback (most recent call last)
<ipython-input-4-30688c2fbe32> in <module>
----> 1 df.rolling(3).std()

~/git/cudf/python/cudf/cudf/core/window/rolling.py in __getattr__(self, key)
    178         if key == "obj":
    179             raise AttributeError()
--> 180         return self.obj[key].rolling(
    181             window=self.window,
    182             min_periods=self.min_periods,

~/git/cudf/python/cudf/cudf/core/series.py in __getitem__(self, arg)
    755             return self.iloc[arg]
    756         else:
--> 757             return self.loc[arg]
    758
    759     def __setitem__(self, key, value):

~/git/cudf/python/cudf/cudf/core/indexing.py in __getitem__(self, arg)
     92     def __getitem__(self, arg):
     93         try:
---> 94             arg = self._loc_to_iloc(arg)
     95         except (TypeError, KeyError, IndexError, ValueError):
     96             raise IndexError("Failed to convert index to appropirate row")

~/git/cudf/python/cudf/cudf/core/indexing.py in _loc_to_iloc(self, arg)
    109             try:
    110                 found_index = self._sr.index._values.find_first_value(
--> 111                     arg, closest=False
    112                 )
    113                 return found_index

~/git/cudf/python/cudf/cudf/core/column/numerical.py in find_first_value(self, value, closest)
    326         found = 0
    327         if len(self):
--> 328             found = cudautils.find_first(self.data_array_view, value)
    329         if found == -1 and self.is_monotonic and closest:
    330             if value < self.min():

~/git/cudf/python/cudf/cudf/utils/cudautils.py in find_first(arr, val, compare)
    200             else:
    201                 gpu_mark_found_int.forall(found.size)(
--> 202                     arr, val, found, arr.size
    203                 )
    204     from cudf.core.column import as_column

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/cuda/compiler.py in __call__(self, *args)
    265
    266         if isinstance(self.kernel, AutoJitCUDAKernel):
--> 267             kernel = self.kernel.specialize(*args)
    268         else:
    269             kernel = self.kernel

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/cuda/compiler.py in specialize(self, *args)
    767         argtypes = tuple(
    768             [self.typingctx.resolve_argument_type(a) for a in args])
--> 769         kernel = self.compile(argtypes)
    770         return kernel
    771

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/cuda/compiler.py in compile(self, sig)
    783                 self.targetoptions['link'] = ()
    784             kernel = compile_kernel(self.py_func, argtypes,
--> 785                                     **self.targetoptions)
    786             self.definitions[(cc, argtypes)] = kernel
    787             if self.bind:

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
     30         def _acquire_compile_lock(*args, **kwargs):
     31             with self:
---> 32                 return func(*args, **kwargs)
     33         return _acquire_compile_lock
     34

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/cuda/compiler.py in compile_kernel(pyfunc, args, link, debug, inline, fastmath, extensions, max_registers)
     55 def compile_kernel(pyfunc, args, link, debug=False, inline=False,
     56                    fastmath=False, extensions=[], max_registers=None):
---> 57     cres = compile_cuda(pyfunc, types.void, args, debug=debug, inline=inline)
     58     fname = cres.fndesc.llvm_func_name
     59     lib, kernel = cres.target_context.prepare_cuda_kernel(cres.library, fname,

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
     30         def _acquire_compile_lock(*args, **kwargs):
     31             with self:
---> 32                 return func(*args, **kwargs)
     33         return _acquire_compile_lock
     34

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/cuda/compiler.py in compile_cuda(pyfunc, return_type, args, debug, inline)
     44                                   return_type=return_type,
     45                                   flags=flags,
---> 46                                   locals={})
     47
     48     library = cres.library

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/compiler.py in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library, pipeline_class)
    566     pipeline = pipeline_class(typingctx, targetctx, library,
    567                               args, return_type, flags, locals)
--> 568     return pipeline.compile_extra(func)
    569
    570

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/compiler.py in compile_extra(self, func)
    337         self.state.lifted = ()
    338         self.state.lifted_from = None
--> 339         return self._compile_bytecode()
    340
    341     def compile_ir(self, func_ir, lifted=(), lifted_from=None):

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/compiler.py in _compile_bytecode(self)
    399         """
    400         assert self.state.func_ir is None
--> 401         return self._compile_core()
    402
    403     def _compile_ir(self):

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/compiler.py in _compile_core(self)
    379                 self.state.status.fail_reason = e
    380                 if is_final_pipeline:
--> 381                     raise e
    382         else:
    383             raise CompilerError("All available pipelines exhausted")

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/compiler.py in _compile_core(self)
    370             res = None
    371             try:
--> 372                 pm.run(self.state)
    373                 if self.state.cr is not None:
    374                     break

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/compiler_machinery.py in run(self, state)
    339                     (self.pipeline_name, pass_desc)
    340                 patched_exception = self._patch_error(msg, e)
--> 341                 raise patched_exception
    342
    343     def dependency_analysis(self):

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/compiler_machinery.py in run(self, state)
    330                 pass_inst = _pass_registry.get(pss).pass_inst
    331                 if isinstance(pass_inst, CompilerPass):
--> 332                     self._runPass(idx, pass_inst, state)
    333                 else:
    334                     raise BaseException("Legacy pass in use")

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
     30         def _acquire_compile_lock(*args, **kwargs):
     31             with self:
---> 32                 return func(*args, **kwargs)
     33         return _acquire_compile_lock
     34

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/compiler_machinery.py in _runPass(self, index, pss, internal_state)
    289             mutated |= check(pss.run_initialization, internal_state)
    290         with SimpleTimer() as pass_time:
--> 291             mutated |= check(pss.run_pass, internal_state)
    292         with SimpleTimer() as finalize_time:
    293             mutated |= check(pss.run_finalizer, internal_state)

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/compiler_machinery.py in check(func, compiler_state)
    262
    263         def check(func, compiler_state):
--> 264             mangled = func(compiler_state)
    265             if mangled not in (True, False):
    266                 msg = ("CompilerPass implementations should return True/False. "

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/typed_passes.py in run_pass(self, state)
     96                 state.return_type,
     97                 state.locals,
---> 98                 raise_errors=self._raise_errors)
     99             state.typemap = typemap
    100             if self._raise_errors:

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/typed_passes.py in type_inference_stage(typingctx, interp, args, return_type, locals, raise_errors)
     68
     69         infer.build_constraint()
---> 70         infer.propagate(raise_errors=raise_errors)
     71         typemap, restype, calltypes = infer.unify(raise_errors=raise_errors)
     72

~/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/typeinfer.py in propagate(self, raise_errors)
    984                                   if isinstance(e, ForceLiteralArg)]
    985                 if not force_lit_args:
--> 986                     raise errors[0]
    987                 else:
    988                     raise reduce(operator.or_, force_lit_args)

TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<numba.cuda.compiler.DeviceFunctionTemplate object at 0x7f3d7b8e3908>) with argument(s) of type(s): (int64, unicode_type)
 * parameterized
In definition 0:
    LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)
No definition for lowering <built-in method eq_impl of _dynfunc._Closure object at 0x7f3d380aa458>(int64, unicode_type) -> bool

File "../git/cudf/python/cudf/cudf/utils/utils.py", line 57:
def check_equals_int(a, b):
    return a == b
    ^

[1] During: lowering "$0.3 = a == b" at /home/nfs/kkraus/git/cudf/python/cudf/cudf/utils/utils.py (57)
    raised from /home/nfs/kkraus/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/utils.py:81
In definition 1:
    LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)
No definition for lowering <built-in method eq_impl of _dynfunc._Closure object at 0x7f3d380aa458>(int64, unicode_type) -> bool

File "../git/cudf/python/cudf/cudf/utils/utils.py", line 57:
def check_equals_int(a, b):
    return a == b
    ^

[1] During: lowering "$0.3 = a == b" at /home/nfs/kkraus/git/cudf/python/cudf/cudf/utils/utils.py (57)
    raised from /home/nfs/kkraus/miniconda3/envs/cudf_dev/lib/python3.6/site-packages/numba/core/utils.py:81
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: Function(<numba.cuda.compiler.DeviceFunctionTemplate object at 0x7f3d7b8e3908>)
[2] During: typing of call at /home/nfs/kkraus/git/cudf/python/cudf/cudf/utils/cudautils.py (141)


File "../git/cudf/python/cudf/cudf/utils/cudautils.py", line 141:
def gpu_mark_found_int(arr, val, out, not_found):
    <source elided>
    if i < arr.size:
        if check_equals_int(arr[i], val):
        ^

@beckernick
Copy link
Member

This is the original issue requesting rolling standard deviation. This request is now covered by #8695 which includes additional context and information, and will be closed by #8809 . I'm going to close this issue in favor of #8695 to consolidate further discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. Python Affects Python cuDF API.
Projects
None yet
Development

No branches or pull requests

4 participants