Skip to content

Add average_all_summaries context manager#1829

Open
QuantuMope wants to merge 2 commits intopytorchfrom
PR/andrew/average-all-summaries
Open

Add average_all_summaries context manager#1829
QuantuMope wants to merge 2 commits intopytorchfrom
PR/andrew/average-all-summaries

Conversation

@QuantuMope
Copy link
Contributor

A useful context manager for computing summary averages over an interval.

Nice to have because several alf algorithms have averaging off as default.
If using these summaries with a small mini-batch-size, we can selectively control which nested summaries get averaged without having to overwrite the source code.

@QuantuMope QuantuMope requested a review from emailweixu March 13, 2026 19:20
Comment on lines +144 to +145
alf.summary.record_if = _disabled_record_if
alf.summary.should_record_summaries = lambda: True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do these two need to be changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

record_if must be changed so that the recording interval set by the user is actually used.

should_record_summaries actually shouldn't be overridden as doing so is redundant. I've removed this check. Unit test still passes successfully.

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.

2 participants