Skip to content

upgrade 'unevaluated array as argument' warning to error #305

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

Merged
merged 15 commits into from
Mar 26, 2025

Conversation

matthiasdiener
Copy link
Collaborator

@matthiasdiener matthiasdiener commented Mar 18, 2025

Please squash

logger.warning does not deduplicate, in contrast to warnings.warn
@matthiasdiener matthiasdiener requested a review from inducer March 18, 2025 22:16
@matthiasdiener matthiasdiener self-assigned this Mar 18, 2025
@inducer
Copy link
Owner

inducer commented Mar 18, 2025

Could you explain the context here? I'd imagine that this will be awfully noisy, for (IMO) not much gain. Ultimately, one should fix these warnings until they're all gone.

@matthiasdiener
Copy link
Collaborator Author

matthiasdiener commented Mar 19, 2025

Could you explain the context here? I'd imagine that this will be awfully noisy, for (IMO) not much gain. Ultimately, one should fix these warnings until they're all gone.

My thought here was that in contrast to most (almost all?) other warnings, this type of warning can have serious performance implications. I was surprised to see this warning appear in the shock1d driver, and they appeared at a point during the execution where many other warnings are displayed, and thus this kind of warning tends to "disappear". I'll set this back to draft, I think we should probably also show the name of the compiled function.

@matthiasdiener matthiasdiener marked this pull request as draft March 19, 2025 00:07
@matthiasdiener matthiasdiener changed the title upgrade unevaluated array as argument warning upgrade 'unevaluated array as argument' warning Mar 19, 2025
@matthiasdiener matthiasdiener marked this pull request as ready for review March 19, 2025 19:14
@alexfikl
Copy link
Collaborator

logger.warning does not deduplicate, in contrast to warnings.warn

You can set warnings.filterwarnings("always") to remove deduplication from warnings (can probably even be targeted at this particular warning). Would that not be the same?

My thought here was that in contrast to most (almost all?) other warnings, this type of warning can have serious performance implications.

If that's the case, wouldn't it be better to disable all warnings on a "production run"?

@matthiasdiener
Copy link
Collaborator Author

logger.warning does not deduplicate, in contrast to warnings.warn

You can set warnings.filterwarnings("always") to remove deduplication from warnings (can probably even be targeted at this particular warning). Would that not be the same?

TIL, thanks. The interface is a bit clumsy, but it seems to work.

My thought here was that in contrast to most (almost all?) other warnings, this type of warning can have serious performance implications.

If that's the case, wouldn't it be better to disable all warnings on a "production run"?

Sorry, my text probably wasn't very clear here. What I meant is that the issue pointed out by the warnings could have serious implications.

@alexfikl
Copy link
Collaborator

alexfikl commented Mar 19, 2025

TIL, thanks. The interface is a bit clumsy, but it seems to work.

Oops, sorry, I wasn't clear there.. I meant that you can just filter warnings in your top-level driver, not here. I agree that it looks very clumsy as is :(

Sorry, my text probably wasn't very clear here. What I meant is that the issue pointed out by the warnings could have serious implications.

Ah, so the issue is that the warning is not loud enough? I would still argue that this is better done on the application side with filterwarnings (perhaps even filterwarnings("error", ...)), but don't feel very strongly about it..

"considerable expense. This is deprecated and will stop "
"working in 2023. To avoid this warning, force evaluation "
"of all arguments via freeze/thaw.",
stacklevel=4)
Copy link
Owner

Choose a reason for hiding this comment

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

I think it'd be useful to create a special warning class for this:

class UnevaluatedCompiledFuncArgWarning(UserWarning):
    pass

(and then pass the appropriate argument to warn) This makes precise filtering from the application side possible. I don't know that I want to install a warning filter on the user's behalf. (We could, in the actx constructor, on an opt-out basis? But that still feels overbearing.)

Alternatively, we could just make this an error, given that it has been deprecated with a deadline that has passed.

Copy link
Owner

Choose a reason for hiding this comment

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

I'm starting to like the "make it an error" idea, I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm starting to like the "make it an error" idea, I think.

Same here :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done in 5535398

@matthiasdiener matthiasdiener changed the title upgrade 'unevaluated array as argument' warning upgrade 'unevaluated array as argument' warning to error Mar 19, 2025
@inducer
Copy link
Owner

inducer commented Mar 20, 2025

inducer/grudge#376 should address the grudge failures.

Copy link
Owner

@inducer inducer left a comment

Choose a reason for hiding this comment

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

LGTM, just one question, hopefully quick.

@@ -642,8 +631,10 @@ def __call__(self, arg_id_to_arg) -> ArrayContainer:
from .utils import get_cl_axes_from_pt_axes
from arraycontext.impl.pyopencl.taggable_cl_array import to_tagged_cl_array

fn_name = self.pytato_program.program.entrypoint
Copy link
Owner

Choose a reason for hiding this comment

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

This and the fn_names below appear to be inconsistent. Is there a specific reason for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, this is hopefully fixed in b1c3a73. Part of the challenge here is that CompiledPyOpenCLFunctionReturningArray appears to be unused.

@matthiasdiener matthiasdiener requested a review from inducer March 24, 2025 21:34
@inducer inducer merged commit 4aeaed4 into main Mar 26, 2025
12 checks passed
@inducer
Copy link
Owner

inducer commented Mar 26, 2025

Thx!

@inducer inducer deleted the upgrade-warn-unevaluated-arg branch March 26, 2025 16:30
@majosm
Copy link
Collaborator

majosm commented Mar 27, 2025

FYI @inducer @matthiasdiener, this change appears to break the non-compiled time integrators in grudge/mirgecom. (Looks like grudge downstream CI here doesn't run the examples, so it missed that.)

@inducer
Copy link
Owner

inducer commented Mar 27, 2025

This change appears to break the non-compiled time integrators in grudge/mirgecom.

As well it should! I'll get grudge fixed up.

@inducer
Copy link
Owner

inducer commented Mar 27, 2025

See inducer/grudge#377 and #307.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants