More profiler counters and warnings for recomputation (or lack thereof) - #9368
Open
abadams wants to merge 4 commits into
Open
More profiler counters and warnings for recomputation (or lack thereof)#9368abadams wants to merge 4 commits into
abadams wants to merge 4 commits into
Conversation
Restores the per-Func counters that describe where recompute happens and whether a Func could be scheduled more tightly: - realizations, productions - points_required_at_realization, points_required_at_production - points_required_inwards, productions_if_inwards These are emitted via three markers (declare_box_required_at_realization / _at_production / _inwards) that ScheduleFunctions places at the realize, produce, and one-level-further-in loop sites, consumed in Profiling.cpp, stored on halide_profiler_func_stats, and dumped to JSON. They drive the could_compute_further_inside warning and let high_recompute attribute the recompute to its dominant cause (root->realization, realization->production sliding-window failure, or production->computed split factors). The inwards marker asks bounds inference to compute a Func's box as if it were produced one loop level further in. That needs a localized box at a scope where the Func isn't actually produced, so BoundsInference's bounds_needed rule no longer cancels a Func whose bounds are wanted because it's inwards-marked (in_pipeline is now overridden by inner_productions). validate_schedule computes the one-level-inwards LoopLevel and locks it so the injector can inspect it; unset levels stay unlocked and are skipped. Adds check_tiled_stencil_modest_recompute, check_sliding_window_counters, check_sliding_window_failure_counters, and check_inwards_counter to the profiler_instances test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The recompute factorizes into three independent stages whose product is the total: root->realization (redundant realizations), realization->production (sliding-window failure), and production->computed (tail strategy / split factors). The message used to force-pick one and always append a realization-vs-production sentence, which printed a meaningless "1.00x ... split factors" clause whenever a single stage dominated. Now each stage is named independently when it contributes more than ~10%, so the advice points only at causes that are actually present. Denominators are guarded so a missing stage reads as 1x. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #9368 +/- ##
==========================================
+ Coverage 70.08% 70.11% +0.03%
==========================================
Files 259 259
Lines 79158 79207 +49
Branches 19293 19312 +19
==========================================
+ Hits 55477 55537 +60
+ Misses 17886 17869 -17
- Partials 5795 5801 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
alexreinking
self-requested a review
August 20, 2026 19:40
alexreinking
approved these changes
Aug 20, 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.
This PR does two things. It adds new counters so that the recompute warning can be more granular. It also adds a warning if you're pointlessly compute_ating something too far out, and computing it further in is both legal and also wouldn't incur recompute. E.g. why compute a pointwise op at scanlines? This one is interesting because it requires another counterfactual in bounds inference - what would the bounds required have been if I had computed this at a different loop nest? The legality check exploits the existing enumeration of legal compute_at sites.
These are duals. Recompute warnings tell you if you've computing something too far in, and the inwards warnings tell you if you've computed it too far out. The inwards warnings only check the loop one further in, so it provides a gradient, not the optimum compute_at location. If you're computing something way too far out, it'll just keep telling you to move it one more in until you reach the minimum. Some examples of it in action, courtesy of claude:
Could compute further inwards
A pointwise Func computed (and allocated) a whole row at a time, when it
could be computed one loop level further in — at
out'sxloop — forfree, avoiding the allocation.
Redundant realizations —
store_at/compute_attoo far inProducer with a 5-tap vertical stencil, computed in 2-row strips with no
store_at, so the halo is re-realized for every strip.b. Sliding-window failure —
productionexceedsrealizationstore_atouter /compute_atinner, but the consumer indexes theproducer at a runtime
stride, so the monotonicity check fails andsliding can't peel off the leading edge; each iteration re-produces the
full footprint.
c. Tail / split over-compute —
computedexceedsproductionProducer computed per 4-wide production tile, but its own split uses
RoundUpto a factor of 16, so it writes 4x the points required.