-
Notifications
You must be signed in to change notification settings - Fork 11
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
Repeated freezes cause repeated computation #102
Comments
Some other things to keep in mind:
Slightly related to arraycontext: |
Agree with all three of your points. Thinking about it more has convinced me that this actually is an arraycontext issue, and pytato probably shouldn't contribute to its solution. In particular, pytato nodes shouldn't hold references to their values (because, as you point out, they're target-specific). A few more thoughts on this:
Your third point is already covered AFAICT: |
(Maybe this is an
arraycontext
issue? Not sure.)Suppose a moderately complex expression is built and evaluated. Then it is evaluated again. Repeated codegen (most likely cached, though see inducer/pytato#163) and repeated evaluation ensues. This isn't ideal. Possibly, a symbolic array, once evaluated, should hold on to its value, to avoid reevaluation. If we don't deal with this somehow, then pytato's arrays can't be meaningfully memoized (e.g. with
@memoize
/@memoize_method
from pytools), as, sure, they memoize the expression, but the actual evaluation is done again and again.A simple approach to this would be simply stuff the evaluated value into a hidden attribute (
_evaluated
?) on the expression nodes. I'm aware that this introduces mutation into otherwise immutable objects... but it's the cache-y kind of mutability, and it doesn't change the semantics of the object in the slightest. So I suspect it's OK.Another possible concern is the lifetime of the evaluated value (i.e. it might outstay its welcome). I don't think that'll be a big concern because
Generally, codegen should stop at already-evaluated notes (and treat them as
DataWrapper
s).@MTCam is hitting this with cache retrievals upon freeze when exercising lazy evaluation for chemistry in https://github.com/illinois-ceesd/mirgecom.
cc @kaushikcfd
The text was updated successfully, but these errors were encountered: