inducer / inducer/arraycontext
Repeated freezes cause repeated computation
- 主要言語
- Python
- スター
- 9
- フォーク
- 11
- 平均マージ
- 17時間 12分
- マージ済み PR(30日)
- 2
説明
(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
- somebody held on to the symbolic value, demonstrating that there's at least potential interest in reevaluating.
- if it becomes an issue, we could make an interface to free the stored value, enabling the memory to be freed.
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
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
まず、issue に記載されているシンボリック配列の評価と codegen のエントリポイントを追跡し、次に freeze またはキャッシュからの取得後に評価を繰り返す状況を再現します。評価済みのノートがどのように表現され、codegen がそれらをどのように処理するかを確認します。評価を繰り返してもシンボリックセマンティクスを変更せずに保存された値が再利用され、かつその値を適切に解放する方法があれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100