Skip to content

[Feature] timeit.mark_start/mark_end for non-context-manager timing#3756

Closed
vmoens wants to merge 1 commit into
gh/vmoens/272/basefrom
gh/vmoens/272/head
Closed

[Feature] timeit.mark_start/mark_end for non-context-manager timing#3756
vmoens wants to merge 1 commit into
gh/vmoens/272/basefrom
gh/vmoens/272/head

Conversation

@vmoens
Copy link
Copy Markdown
Collaborator

@vmoens vmoens commented May 15, 2026

Stack from ghstack (oldest at bottom):

The collector worker loop needs to time spans that begin in one branch
of a control-flow path and end in another — picking up the next
continue command, then ending after the env step. with timeit(...)
can't bridge that.

Refactor __exit__ through a new _record(name, elapsed) classmethod
so the recording side is callable independently. Add timeit.mark_start
/ timeit.mark_end (and mark_env alias) on top: they push and pop
into a class-level _MARKS dict and feed _record on end. The
context-manager path is unchanged.

Unit tests cover: round-trip into _REG, mark cleanup on end, alias
identity for mark_env, and that with timeit(...) still records.

[ghstack-poisoned]
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 15, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3756

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 4 New Failures, 14 Pending

As of commit 457d247 with merge base 0a01ee8 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Comment thread torchrl/_utils.py
Comment on lines +322 to +325
@classmethod
def mark_env(cls, name: str) -> None:
"""Alias for :meth:`mark_end`."""
cls.mark_end(name)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

remove this

@vmoens vmoens closed this May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant