Skip to content

BUG: Relax dtype identity check in reductions#20729

Merged
mattip merged 1 commit intonumpy:mainfrom
seberg:relax-reduce-dtype-identity-check
Jan 6, 2022
Merged

BUG: Relax dtype identity check in reductions#20729
mattip merged 1 commit intonumpy:mainfrom
seberg:relax-reduce-dtype-identity-check

Conversation

@seberg
Copy link
Member

@seberg seberg commented Jan 4, 2022

In some cases, e.g. ensure-native-byte-order will return not the
default, but a copy of the descriptor.

This (and maybe metadata) makes it somewhat annoying to ensure
exact identity between descriptors for reduce "operands" as
returned by the resolve-descirptors method of the ArrayMethod.

To avoid this problem, we check for no-casting (which implies
viewable with offset == 0) rather than strict identity.

Unfortunately, this means that descriptor resolution must be slightly
more careful, but in general this should all be perfectly well
defined.

Closes gh-20699

Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

This looks good, but also definitely needs a test case so that it doesn't recur!

* be identical. The second argument can be different for reductions,
* but is checked to be identical for accumulate and reduceat.
* Ideally, the type-resolver ensures that all are identical, but we do
* not enforce this here strictly.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add "strictly, since on windows this seems not to be guaranteed; see gh-20699"

@seberg
Copy link
Member Author

seberg commented Jan 5, 2022

I ran into an caching(?) issue during testing :/ will have to dig into that as well.

In some cases, e.g. ensure-native-byte-order will return not the
default, but a copy of the descriptor.

This (and maybe metadata) makes it somewhat annoying to ensure
exact identity between descriptors for reduce "operands" as
returned by the resolve-descirptors method of the ArrayMethod.

To avoid this problem, we check for no-casting (which implies
viewable with `offset == 0`) rather than strict identity.

Unfortunately, this means that descriptor resolution must be slightly
more careful, but in general this should all be perfectly well
defined.

Closes numpygh-20699
@seberg seberg force-pushed the relax-reduce-dtype-identity-check branch from 7e1b9bc to 975a946 Compare January 5, 2022 17:53
@seberg
Copy link
Member Author

seberg commented Jan 5, 2022

Well, that other issue is just that: another issue.

I added the test, arguably it is a bit of an indirect test, but at least it tests the most relevant and interesting error-path.

Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

Looks all good to me. Thanks, @seberg!

@mattip mattip merged commit e967f51 into numpy:main Jan 6, 2022
@mattip
Copy link
Member

mattip commented Jan 6, 2022

Thanks @seberg

@mattip
Copy link
Member

mattip commented Jan 6, 2022

After merging this to main, the debug test runs started segfaulting. @seberg any ideas?

https://github.com/numpy/numpy/actions/workflows/build_test.yml

@seberg
Copy link
Member Author

seberg commented Jan 6, 2022

Hummm, how come CI didn't notice that ahead of time? It is an abort, so maybe likely be an assert gone wrong.

@seberg
Copy link
Member Author

seberg commented Jan 6, 2022

@charris, this one needs to be backported together with gh-20754 unfortunately.

@mhvk
Copy link
Contributor

mhvk commented Jan 10, 2022

Just to note that this fixes another astropy issue, astropy/astropy#12706. This one is in considerably more common code - @charris: would it be possible to do a relatively quick 1.22.1??

@seberg
Copy link
Member Author

seberg commented Jan 10, 2022

I think that would be fine, but there are one or two other issues and I was too distracted to make progress. I was hoping I can fix both this week so we would be ready for a 1.22.1 at the end of the week or next.

But if it is much the same for Chuck, we can also just aim for a 1.22.2 soon after. IIRC the other issue was not found by anyone (but could be important!), and I don't really think we need to scramble about breaking numba (they just got 1.21 support recently).

@charris
Copy link
Member

charris commented Jan 10, 2022

@mhvk I was planning on a rapid release. I'd like to see #20696 fixed, as well as several that @seberg is looking at, but we could push things a bit if they don't get fixed in a couple of days.

@mhvk
Copy link
Contributor

mhvk commented Jan 10, 2022

OK, sounds good! It definitely doesn't hang on a week.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: possible problem with np.add.accumulate on 32-bit windows

4 participants