Repository navigation
Add tracked tasks and per-occurrence events to MDP2 #9323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d21b326
1bb2dc7
75922bf
cbb5b50
ad129e6
1cd2ef3
888b0c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| * Added ``tracked`` to :class:`~isaaclab_experimental.mdp2.TaskCfg` and :class:`~isaaclab_experimental.mdp2.Milestone`. | ||
| A tracked subtask keeps its own progress, such as how often an object drops, but stays out of its parent's | ||
| completion and score, so watching an event does not change what counts as success. | ||
| * Added :meth:`~isaaclab_experimental.envs.MDP2RLEnv.episode_events`, which returns, with an episode budget and | ||
| ``record_episode_events``, a row per time each repeating task was done, with its world, episode, and step, such as | ||
| each time an object dropped. | ||
| * Added ``repeat`` and ``tracked`` to :func:`~isaaclab_experimental.mdp2.sequence`, for an event of several steps, | ||
| such as a lift then a drop. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -393,6 +393,9 @@ class TaskCfg: | |
| require: int | None = None # Together: the subtasks that must be done, None for all of those with a completion | ||
| worlds: dict[str, int] | None = None # Split: the worlds of each subtask, None for even shares | ||
| weights: dict[str, float] | None = None # Choice: the relative chance of each subtask, None for even chances | ||
| # Keep the task's progress out of its parent's completion and score, for an event to watch rather than a goal, such | ||
| # as drops of an object. Only a subtask of a task that runs its subtasks together can be tracked | ||
| tracked: bool = False | ||
|
|
||
|
|
||
| @dataclass(init=False) | ||
|
|
@@ -406,10 +409,11 @@ def __init__( | |
| score: float = 1.0, | ||
| final: bool | None = None, | ||
| repeat: bool = False, | ||
| tracked: bool = False, | ||
| **fields: Any, | ||
| ) -> None: | ||
| # The other fields are those of a task, as ``dataclasses.replace`` passes them. | ||
| super().__init__(done=done, hold=hold, score=score, final=final, repeat=repeat, **fields) | ||
| super().__init__(done=done, hold=hold, score=score, final=final, repeat=repeat, tracked=tracked, **fields) | ||
|
|
||
|
|
||
| PROGRESS_FIELDS = ("done", "holding", "active", "score", "done_at", "started_at", "stage", "count") | ||
|
|
@@ -485,7 +489,7 @@ def merge(path: tuple[str, ...], target: dict, uses: dict, index: int) -> None: | |
| elif cores: | ||
| core = cores[0] | ||
| composed.done, composed.hold, composed.score, composed.final = core.done, core.hold, core.score, core.final | ||
| composed.repeat = core.repeat | ||
| composed.repeat, composed.tracked = core.repeat, core.tracked | ||
| composed.subtasks, composed.mode = dict(core.subtasks), core.mode | ||
| composed.require, composed.worlds, composed.weights = core.require, core.worlds, core.weights | ||
| if subtasks: | ||
|
|
@@ -525,10 +529,13 @@ def _renamed(value: Any, entities: dict[str, str]) -> Any: | |
| return value | ||
|
|
||
|
|
||
| def sequence(**subtasks: TaskCfg) -> TaskCfg: | ||
| def sequence(*, repeat: bool = False, tracked: bool = False, **subtasks: TaskCfg) -> TaskCfg: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Warning · Compatibility — Preserve sequence subtask names Previously valid subtasks named repeat or tracked now bind to flags and disappear from the sequence. Keep TaskCfg-valued keywords as subtasks and configure these flags outside that namespace.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping the keywords: avoiding |
||
| """Run subtasks one after another, in the same worlds. A subtask starts at the step after the previous one is | ||
| done, and the task is done once the last one is, which keeps running until the episode ends.""" | ||
| return TaskCfg(subtasks=dict(subtasks), mode=TaskMode.SEQUENCE) | ||
| done, and the task is done once the last one is, which keeps running until the episode ends. ``repeat`` and | ||
| ``tracked`` are those of :class:`TaskCfg`, such as for an event of several steps to count beside the task.""" | ||
| if not isinstance(repeat, bool) or not isinstance(tracked, bool): | ||
| raise TypeError("'repeat' and 'tracked' are flags of the sequence and cannot name its subtasks") | ||
| return TaskCfg(subtasks=dict(subtasks), mode=TaskMode.SEQUENCE, repeat=repeat, tracked=tracked) | ||
|
|
||
|
|
||
| def choice(weights: dict[str, float] | None = None, **subtasks: TaskCfg) -> TaskCfg: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allocates worst-case rows for every repeating task, tracked or not, even when
episode_events()is never called (~1.2 GB per task for 1000-step episodes, like Go2 flat, with a 100k budget). Could event recording be opt-in?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, made it opt-in in 1cd2ef3:
MDP2RLEnvCfg.record_episode_events(defaultFalse). Off, nothing is allocated andepisode_events()raises asking for the flag. On, the buffer is still worst-case (budget × time-limit steps × 12 bytes per repeating task), so that cost is now documented on the field, and it raises at construction without a time limit.