Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid a couple of InexactErrors in the IdDict code. #48116

Merged
merged 1 commit into from
Jan 5, 2023

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Jan 4, 2023

Fixes #48097 (working around the issue).

On 1.9, kwarg calls use Base._tuple_unique_fieldtypes, which relies on IdDict. Normally that doesn't matter, because the method is marked @total_meta so the optimizer is free to use concrete evaluation to evaluate the function at compile time. However, with our GPU back-ends, Core.throw_inexacterror is replaced with an overlay method that does GPU-compatible exception reporting. That currently disables concrete evaluation, resulting in run-time calls to Base._tuple_unique_fieldtypes (and a whole lot of dynamic code following it).

To get things working in time for 1.9, just avoid throwing InexactErrors as part of IdDict operations. That results in the optimizer being able to concrete evaluate Base._tuple_unique_fieldtypes even in GPU compilation mode.

For 1.10, we probably need a better way of overriding methods without disabling concrete evaluation. Some GPU overrides should not disable these optimizations, e.g., if we override Base.sin with a version that uses hardware intrinsics we should still get to benefit from concrete evaluation (albeit using the original method). In other cases, like the Core.throw_inexacterror overlay here, it's not so clear what needs to happen.

@maleadt maleadt added the gpu Affects running Julia on a GPU label Jan 4, 2023
@maleadt maleadt requested a review from aviatesk January 4, 2023 11:58
@maleadt maleadt mentioned this pull request Jan 4, 2023
6 tasks
@maleadt maleadt added the backport 1.9 Change should be backported to release-1.9 label Jan 5, 2023
@maleadt
Copy link
Member Author

maleadt commented Jan 5, 2023

CI failures unrelated.

@maleadt maleadt merged commit 321c5f5 into master Jan 5, 2023
@maleadt maleadt deleted the tb/iddict_inexacterror branch January 5, 2023 15:59
maleadt added a commit that referenced this pull request Jan 5, 2023
@maleadt maleadt mentioned this pull request Jan 5, 2023
41 tasks
@maleadt maleadt removed the backport 1.9 Change should be backported to release-1.9 label Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gpu Affects running Julia on a GPU
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overlay of Core.throw_inexacterror results in bad codegen of kwarg call
1 participant