Skip to content

Failing CuPy tests #7324

Closed
Closed

Description

@pentschev

Since the introduction of #6738, a few CuPy tests have broken.

We're discussing and trying to allocate GPUs for Dask PRs in the near future, so I'll probably wait for that to work on fixing the tests above.

Activity

  1. jrbourbeau commented on Mar 5, 2021

    @jrbourbeau
    Member

    Thanks for tracking this @pentschev!

  2. hristog commented on Mar 12, 2021

    @hristog
    Contributor

    For reference - I've documented some affected by #7183 behavior under dask/dask-ml#803 as well.

  3. TomAugspurger commented on Mar 14, 2021

    @TomAugspurger
    Member

    cc @thomasjpfan, in case you have a chance to look at the bincount issue from #7183.

  4. GenevieveBuckley commented on Mar 15, 2021

    @GenevieveBuckley
    Contributor

    @pentschev can you try this and see if it fixes the cupy tests for bincount? #7391

  5. pentschev commented on Mar 15, 2021

    @pentschev
    MemberAuthor

    @GenevieveBuckley thanks for pinging me, but unfortunately I still see the same failure with #7391 :

    ======================================================= FAILURES =======================================================
    ____________________________________________________ test_bincount _____________________________________________________
    
        @pytest.mark.skipif(
            not IS_NEP18_ACTIVE or cupy.__version__ < LooseVersion("6.4.0"),
            reason="NEP-18 support is not available in NumPy or CuPy older than "
            "6.4.0 (requires https://github.com/cupy/cupy/pull/2418)",
        )
        def test_bincount():
            x = cupy.array([2, 1, 5, 2, 1])
            d = da.from_array(x, chunks=2, asarray=False)
            e = da.bincount(d, minlength=6)
    >       assert_eq(e, np.bincount(x, minlength=6))
    
    dask/array/tests/test_cupy.py:934:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
    a = array([0, 2, 2, 0, 0, 1]), b = array([0, 2, 2, 0, 0, 1]), check_shape = True, check_graph = True, check_meta = True
    check_chunks = True, kwargs = {}
    a_original = dask.array<_bincount_agg-aggregate, shape=(6,), dtype=int64, chunksize=(6,), chunktype=numpy.ndarray>
    b_original = array([0, 2, 2, 0, 0, 1]), adt = dtype('int64'), a_meta = array([], dtype=int64)
    a_computed = array([0, 2, 2, 0, 0, 1]), bdt = dtype('int64'), b_meta = None
    
        def assert_eq(
            a,
            b,
            check_shape=True,
            check_graph=True,
            check_meta=True,
            check_chunks=True,
            **kwargs,
        ):
            a_original = a
            b_original = b
    
            a, adt, a_meta, a_computed = _get_dt_meta_computed(
                a, check_shape=check_shape, check_graph=check_graph, check_chunks=check_chunks
            )
            b, bdt, b_meta, b_computed = _get_dt_meta_computed(
                b, check_shape=check_shape, check_graph=check_graph, check_chunks=check_chunks
            )
    
            if str(adt) != str(bdt):
                # Ignore check for matching length of flexible dtypes, since Array._meta
                # can't encode that information
                if adt.type == bdt.type and not (adt.type == np.bytes_ or adt.type == np.str_):
                    diff = difflib.ndiff(str(adt).splitlines(), str(bdt).splitlines())
                    raise AssertionError(
                        "string repr are different" + os.linesep + os.linesep.join(diff)
                    )
    
            try:
                assert (
                    a.shape == b.shape
                ), f"a and b have different shapes (a: {a.shape}, b: {b.shape})"
                if check_meta:
                    if hasattr(a, "_meta") and hasattr(b, "_meta"):
                        assert_eq(a._meta, b._meta)
                    if hasattr(a_original, "_meta"):
                        msg = (
                            f"compute()-ing 'a' changes its number of dimensions "
                            f"(before: {a_original._meta.ndim}, after: {a.ndim})"
                        )
                        assert a_original._meta.ndim == a.ndim, msg
                        if a_meta is not None:
                            msg = (
                                f"compute()-ing 'a' changes its type "
                                f"(before: {type(a_original._meta)}, after: {type(a_meta)})"
                            )
                            assert type(a_original._meta) == type(a_meta), msg
                            if not (np.isscalar(a_meta) or np.isscalar(a_computed)):
                                msg = (
                                    f"compute()-ing 'a' results in a different type than implied by its metadata "
                                    f"(meta: {type(a_meta)}, computed: {type(a_computed)})"
                                )
    >                           assert type(a_meta) == type(a_computed), msg
    E                           AssertionError: compute()-ing 'a' results in a different type than implied by its metadata (meta: <class 'numpy.ndarray'>, computed: <class 'cupy.core.core.ndarray'>)
    E                           assert <class 'numpy.ndarray'> == <class 'cupy....core.ndarray'>
    E                             +<class 'numpy.ndarray'>
    E                             -<class 'cupy.core.core.ndarray'>
    
    dask/array/utils.py:320: AssertionError
  6. GenevieveBuckley commented on Mar 15, 2021

    @GenevieveBuckley
    Contributor

    Thanks Peter, I might take more of a look at it today

  7. GenevieveBuckley commented on Mar 15, 2021

    @GenevieveBuckley
    Contributor

    It seems .meta is always being made a numpy array (rather than updating to whatever the array type actually is). Let me see if I can change that

  8. GenevieveBuckley commented on Mar 16, 2021

    @GenevieveBuckley
    Contributor

    Thanks Peter! Fixed in this commit: 6bf5340

    I have cupy version 9.0.0b3 installed on my machine locally, and the cupy test_bincount passes with this change.

    pytest dask/array/tests/test_cupy.py::test_bincount
    

    As you say, the other tests related to #6997 are still failing. PR #7391 doesn't address those.

  9. GenevieveBuckley commented on Mar 16, 2021

    @GenevieveBuckley
    Contributor

    Hmm, it seems that the like kwarg for numpy array creation was only introduced in numpy version 1.20

    This means my fix works if you have a recent version of numpy, but is now breaking the dask CI tests because the minimum numpy dependency allowed is version 1.15.1 See dask/community#136

    Not sure what's the best way to handle it.

  10. pentschev commented on Mar 16, 2021

    @pentschev
    MemberAuthor

    I added #7391 (comment) on the PR, using array_safe should resolve issues with older NumPy versions. 😄

    Thanks @GenevieveBuckley for working on that!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions