Skip to content

cupy: __setitem__ with int array index fails when chunked #11730

Open

Description

@crusaderky

x.__setitem__(idx, ), where x is a dask array with cupy meta and idx is a dask array of integers, returns incorrect results when there are multiple chunks:

def test_setitem_1d():
    x = cupy.arange(10)
    idx = cupy.asarray([2, 3])
    dx = da.from_array(x.copy(), chunks=(5,))

    x[idx,] = -1
    dx[da.from_array(idx)] = -1

    assert_eq(x, dx)
AssertionError: found values in 'a' and 'b' which differ by more than the allowed amount
E           assert False
E            +  where False = allclose(array([ 0,  1, -1, -1,  4,  5,  6,  7,  8,  9]), array([ 0,  1, -1, -1,  4, -1,  6,  7,  8,  9]), equal_nan=True, **{})

the issue disappear if I set chunks=-1.

Note that this is both upstream and downstream of #11728.

Activity

  1. added
    needs triage
    on Feb 7, 2025
  2. crusaderky commented on Feb 7, 2025

    @crusaderky
    CollaboratorAuthor

    #11728 adds an XFAILed unit test for this

  3. added
    needs attention
    on Mar 17, 2025
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

    needs attentionneeds triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions