Skip to content

mysterious rechunking error #7859

Closed

Description

@d-v-b

on dask==2021.6.2:

import dask.array as da

# this matters -- (1185, 241, 1060) and (1185, 241, 1058) run fine
shape = (1185, 241, 1059) 
final_chunks = (64,64,64)

coarsened = da.coarsen(da.mean, da.zeros(shape, chunks=(1,-1,-1)), {0: 2, 1: 2, 2: 2}, trim_excess=True)
rechunked_a = coarsened.rechunk(*final_chunks)
rechunked_b = coarsened.rechunk(final_chunks)

assert rechunked_a.chunks == rechunked_b.chunks

a = rechunked_a.compute()
b = rechunked_b.compute()

rechunked_a runs fine, but rechunked_b errors with a traceback that ends here:

~/miniconda3/lib/python3.8/site-packages/dask/core.py in _execute_task(arg, cache, dsk)
    119         # temporaries by their reference count and can execute certain
    120         # operations in-place.
--> 121         return func(*(_execute_task(a, cache) for a in args))
    122     elif not ishashable(arg):
    123         return arg

TypeError: tuple indices must be integers or slices, not tuple

I will keep digging into it, but this has to be some kind of weird bug in the rechunking code.

Activity

  1. d-v-b commented on Jul 2, 2021

    @d-v-b
    MemberAuthor

    more mysteries:

    # this works
    rechunked_b[:272].compute()
    # this errors
    rechunked_b[:273].compute()
  2. jrbourbeau commented on Jul 2, 2021

    @jrbourbeau
    Member

    Thanks for reporting @d-v-b. git bisect points to #6580 has the point at which your example started to fail (cc @dcherian for visibility)

  3. dcherian commented on Jul 2, 2021

    @dcherian
    Collaborator

    oh hmm.. my code in that PR was totally rewritten by @d-v-b in #7127 but somehow the cause of this error stayed?

  4. ncclementi commented on Aug 5, 2021

    @ncclementi
    Member

    Dask 2021.07.2 (and main) still have the problem reported by @d-v-b in the minimal reproducible example.

    It seems this might have been introduced in #7127 . @d-v-b would you mind taking a look at the changes on your PR and see if we can shine some light on this?

  5. dcherian commented on Aug 5, 2021

    @dcherian
    Collaborator

    Fundamentally all that code just creates a new chunks tuple that is passed to .rechunk in coarsen. So I think we could minimize this code example by figuring out how coarsen is rechunking the input array.

    The following is plain weird. The chunks are equal but rechunked_b.compute() fails ...

    rechunked_a = coarsened.rechunk(*final_chunks)
    rechunked_b = coarsened.rechunk(final_chunks)
    
    assert rechunked_a.chunks == rechunked_b.chunks

    This error looks like a bad task graph key that isn't being replaced by an array at compute time.

    TypeError: tuple indices must be integers or slices, not tuple

  6. phofl commented on Aug 7, 2024

    @phofl
    Collaborator

    Looks like this was fixed a while ago, we should probably add a test though

  7. added
    tests
    on Aug 7, 2024
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

    arraytests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions