Reuse graph node results within one GraphEvaluator evaluation - #274
Merged
Merged
Conversation
When a node's __call__ calls one of its declared dependencies again, return the result already computed for that graph node instead of evaluating it again, independent of cacheable. Results are released when the evaluation finishes, and calls that are not graph nodes are not retained. Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #274 +/- ##
==========================================
+ Coverage 93.78% 93.79% +0.01%
==========================================
Files 190 190
Lines 21499 21552 +53
Branches 1410 1413 +3
==========================================
+ Hits 20162 20215 +53
Misses 1062 1062
Partials 275 275 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ptomecek
reviewed
Sep 29, 2026
Volatile nodes are still evaluated in the graph pre-pass, but their results are not stored, so each consumer that calls them recomputes. Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
Collaborator
|
Follow-up, not blocking: worth doing the same for |
ptomecek
approved these changes
Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GraphEvaluatorevaluates each node of the dependency graph once, in topological order. A node's__call__usually calls its declared dependencies again to use their results, though, and those nested calls go back through the evaluator stack. Without a caching evaluator withcacheable=True, every nested call runs the dependency again. A chainsource <- universe <- taskwhere each__call__calls its dependency runssourcethree times anduniversetwice in a single evaluation.Turning caching on isn't always possible. Long graphs that make many non-graph calls (for example, thousands of per-item HTTP requests inside one node) disable caching to bound memory, which leaves declared dependencies running repeatedly.
This change keeps each graph node's result for the duration of one graph evaluation:
finallyblock when the evaluation ends, so nothing is shared across evaluations andcacheablesemantics are unchanged.Tests cover a diamond whose nodes call their dependencies (each node runs once per evaluation with
cacheable=False, and again on the next evaluation) and a model that calls a non-dependency twice (runs twice). The cache how-to and the built-in models reference describe the behavior.