Skip to content

Add LLVM STATISTIC tracking for cached and recomputed values#2749

Open
brucechanglongxu wants to merge 1 commit intoEnzymeAD:mainfrom
brucechanglongxu:add-cache-recompute-statistics
Open

Add LLVM STATISTIC tracking for cached and recomputed values#2749
brucechanglongxu wants to merge 1 commit intoEnzymeAD:mainfrom
brucechanglongxu:add-cache-recompute-statistics

Conversation

@brucechanglongxu
Copy link
Copy Markdown

@brucechanglongxu brucechanglongxu commented Mar 18, 2026

Adds LLVM STATISTIC macros to GradientUtils.cpp to track how many values get cached vs recomputed in the reverse pass. The counters are incremented in computeMinCache() at both decision points — when a value must be cached due to single-use needs, and when the min-cut classifies intermediates.

Viewable via opt -stats.

Partial fix for #962 (covers cached/recomputed tracking; GPU gradient accumulation, allocation merging, etc. could follow separately).

Track the number of values cached vs recomputed in the reverse pass
using LLVM's STATISTIC macro. Statistics are incremented in
computeMinCache() where the min-cut analysis decides which intermediate
values must be cached and which can be safely recomputed.

Addresses EnzymeAD#962.
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.

1 participant