Skip to content

offered a fix for rechunking with zero-size-chunks - #8703

Merged
jcrist merged 5 commits into
dask:mainfrom
ParticularMiner:Issue_5661
Feb 23, 2022
Merged

jcrist merged 5 commits into
dask:mainfrom
ParticularMiner:Issue_5661

Conversation

@ParticularMiner

@ParticularMiner ParticularMiner commented Feb 10, 2022 •

Copy link
Copy Markdown
Contributor

@TomAugspurger
I copied your tests (with a few modifications) which you recommended in #5661 to this PR. These proved very useful in bringing about this fix.

@TAdeJong, may I invite you to test whether this PR fixes your problem with diagonal(A, k) or not.
To clarify: as you've mentioned already, diag(A, k) of #8689 does not depend on diagonal(A, k). Nevertheless, since diagonal(A, k) depends on how dask handles zero-size-chunks, it would be prudent to check that diagonal(A, k) works under this PR.

@github-actions github-actions Bot added the array label Feb 10, 2022
@ParticularMiner

Copy link
Copy Markdown
Contributor Author

The currently failing CI's seem to be unrelated to this PR.

@ParticularMiner

Copy link
Copy Markdown
Contributor Author

I have also checked diagonal(A, k) myself and found it to be working under this PR. That is, the following code no longer breaks:

x = da.ones((8,8), chunks=(4,4))
dd = da.ones((8,8), chunks=(4,4))
d = da.diagonal(dd)
print(d.compute())  # works
print((d+d).compute())  # also works
A = (d + x)
A.compute() # no longer breaks.

and gives the right result, as far as I can see.

@jcrist jcrist left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ParticularMiner, this looks pretty good to me.

I do agree with the comment here though (#5661 (comment)) that avoiding generating 0 size chunks in the first place would be a good fix. These are still bound to come up periodically, but they only represent extra bookkeeping for the scheduler, as their outputs will always be size 0. Was the fix for that included in your other diagonal PR (#8689)?

Comment thread dask/array/rechunk.py Resolved
@ParticularMiner

Copy link
Copy Markdown
Contributor Author

Hi @jcrist

Yes, in the diagonal PR #8689, I indeed completely avoided zero-size-chunks, but only for those routines: diag() and diagonal(). Elsewhere in dask, of course, is a different story. But I'm hoping that this PR will at least help ease the handling of zero-size-chunks everywhere else in dask that they may appear. For example, they appear quite naturally during the dask array-indexing routines and disappear again.

I'm not sure if we'll always be able to avoid zero-size-chunks throughout dask though, as doing so often seems to involve some clever chunk re-indexing schemes that are not always easy to come by.

My feeling (though don't quote me on this) is that there might exist a simple mathematical theory that clarifies and guides the the treatment of zero-size-chunks. But I'm yet to explore this.

@ParticularMiner

Copy link
Copy Markdown
Contributor Author

Hi @jcrist

Please examine the new diffs to see if the comments I've added are helpful or not. 😄

@pavithraes
pavithraes requested a review from jcrist February 23, 2022 17:13

@jcrist jcrist left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcrist
jcrist merged commit 9b21543 into dask:main Feb 23, 2022
phobson pushed a commit to phobson/dask that referenced this pull request Feb 28, 2022
* offered a fix for rechunking with zero-size-chunks dask#5661

* added and catered for more test cases of zero-sized chunks

* added new test-case of rechunking with zero-size-array

* catered for yet another test-case of rechunking with zero-size-array

* added helpful comments as per @jcrist's advice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

da.diagonal is broken

2 participants