Repository navigation
Conversation
Arena's tracked events record when something happens, such as a drop, without changing what counts as success. MDP2 already counts such events with repeat=True, but every subtask with a completion counted towards its parent, so composing a drop counter beside the task made success require a drop and diluted the score, as logged in Progress/task and recorded in progress/score. tracked=True keeps a subtask's own progress (done, done_at, count, and its log and record columns) and drops it from TaskTree.counted, which drives the parent's completion, holding, final checks, and score in both backends. Only subtasks that run together can be tracked: a sequence, choice, or split needs each subtask to complete or run in turn.
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Compatibility and deprecation (4), Implementation (2), Style consistency (2), Test quality (1). Other reviewed categories look good.
- PR description: The title matches; correct non-breaking and time-limit claims, and substantiate “within noise” with baseline/candidate revisions, command, hardware, backend, environment count, budget, warmup, and latency spread; retain useful usage and validation sections.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: No over-engineering issues.
- API: API changes look good.
- Compatibility and deprecation: Breaking changes: sequence consumes existing repeat/tracked subtask names, TaskCfg and TaskNode shift positional fields, and untimed repeating-task budgets fail construction; preserve these contracts before introducing the new behavior.
- Implementation: Zero-initializing occurrence capacity writes storage never read before recording; allocate the event buffer with torch.empty.
- Style consistency: The new event-condition comment restates the predicate without explaining a constraint; delete it and retain the episode-index correction rationale.
- Test quality: The occurrence test transfers the entire step column inside each episode iteration; materialize it once outside the loop while retaining reset, budget-mask, and backend coverage.
Significant concerns. Posted 9 inline findings.
Automated review; human maintainers own approval decisions.
| *restarted, | ||
| ) | ||
| if self.cfg.episode_budget is not None and self._event_paths: | ||
| # A task that repeats occurred in an episode of the budget where its count rose since the last step. |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Remove predicate narration
This comment restates the active-world and count-rise condition immediately below it without explaining a constraint. Remove it; retain the episode-index correction comment.
There was a problem hiding this comment.
Removed; the env now reads a single occurred flag, so the condition is self-explanatory.
|
|
||
| def episode_events(self) -> dict[str, dict[str, torch.Tensor]]: | ||
| """Return, for each task that repeats, a row per time it was done in an episode of the budget, as columns by | ||
| name: ``world``, ``episode`` and ``step``, which join the rows of :meth:`episode_records` on ``world`` and |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Qualify the record join
The docstring says occurrence rows join episode_records(), but also includes running episodes, which have no record yet. Limit the join claim to completed episodes.
There was a problem hiding this comment.
Done: the docstring now says only completed episodes join, and that running episodes have rows but no record yet.
| self._recorded += [self.state.arrays[mdp2.progress_field(path, "count")].torch for path in repeats] | ||
| self._record_columns += [f"progress/{path or 'task'}/count" for path in repeats] | ||
| # A task that repeats is done at most once per step, so its rows fit the steps of the budget. | ||
| if repeats and not math.isfinite(self.max_episode_length): |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Keep untimed episode budgets functional
A budgeted repeating task without a time limit now fails construction, even if callers only use count records. Keep the existing budget path functional; require a limit only for bounded occurrence recording.
There was a problem hiding this comment.
Fixed: a budget without a time limit builds and records counts as before; only episode_events() raises when called.
| raise ValueError("An episode budget needs a time limit to record the times that repeating tasks are done.") | ||
| capacity = budget * int(self.max_episode_length) if repeats else 0 | ||
| self._event_paths = repeats | ||
| self._events = torch.zeros(len(repeats), capacity, 3, dtype=torch.int32, device=device) |
There was a problem hiding this comment.
🟡 Warning · Implementation — Do not clear unread event rows
Only rows below _num_events are returned, and recording writes each row. Zeroing the potentially large capacity buffer adds initialization cost; allocate it with torch.empty.
| repeat: bool = False | ||
| # 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 |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Preserve TaskCfg positional arguments
Inserting tracked before subtasks shifts the generated constructor’s existing positional fields; a positional subtasks mapping binds to tracked. Make the new field keyword-only.
There was a problem hiding this comment.
Moved tracked to the last field of TaskCfg, so positional fields keep their meaning.
|
|
||
|
|
||
| def sequence(**subtasks: TaskCfg) -> TaskCfg: | ||
| def sequence(*, repeat: bool = False, tracked: bool = False, **subtasks: TaskCfg) -> TaskCfg: |
There was a problem hiding this comment.
🟡 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.
There was a problem hiding this comment.
Keeping the keywords: avoiding dataclasses.replace for a repeating event is the point, and choice(weights=...) already shares its namespace with subtasks the same way. To keep it from failing silently, sequence now raises a TypeError when a task is passed as repeat or tracked, with a test.
| # ancestors repeats | ||
| staged: bool | ||
| repeat: bool = False | ||
| tracked: bool = False # Kept out of its parent's completion and score |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Preserve TaskNode positional arguments
Inserting tracked before weights shifts TaskNode’s existing positional weights and stream arguments. Make tracked keyword-only so direct construction retains its meaning.
There was a problem hiding this comment.
Moved tracked to the last field of TaskNode.
| return tuple(self.node(child) for child in node.children if child in self.completes) | ||
| """Return the subtasks of a task that count towards its completion: those that have one and are not tracked.""" | ||
| return tuple( | ||
| self.node(child) for child in node.children if child in self.completes and not self.node(child).tracked |
There was a problem hiding this comment.
🟡 Warning · Implementation — Look up each child once
The tracked filter calls the linear self.node lookup twice for every retained child; the previous path called it once. Bind each child node before filtering.
There was a problem hiding this comment.
Fixed, one lookup per child.
| occurred = list(zip(events["world"].tolist(), events["episode"].tolist())) | ||
| assert set(occurred) == set(episodes) | ||
| for k, episode in enumerate(episodes): | ||
| steps = [s for o, s in zip(occurred, events["step"].tolist()) if o == episode] |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Read event steps once
Calling events["step"].tolist() inside the episode loop transfers the full device column for every episode. Materialize it once before the loop.
There was a problem hiding this comment.
Fixed, each column is read once per task.
Confidence Score: 4/5
[Medium impact] The changes affect MDP2 task success and event results for opted-in workflows. Fix the missing nested event records before merging. Findings
SummaryAdds tracked subtasks and per-occurrence episode records to MDP2.
Reviews (1) · Last reviewed commit: "Let MDP2 sequences repeat and be tracked..." · Reviewed by Greptile |
| count = argument(self.state.arrays[mdp2.progress_field(path, "count")], wp.array(dtype=wp.int32)) | ||
| lines += [ | ||
| f"if ({ended}[world] or {active}[world]) and {count}[world] > {last}[{k}, world]:", |
There was a problem hiding this comment.
episode_events() misses a repeating child's completion when its parent restarts on the same step. For example, a repeating compose can contain a goal and a tracked repeating event. After the goal completes, its condition can fall on the same step the event fires. Both backends increment the event's count, then the parent's restart clears it before this logger reads it. The comparison sees no rise and silently drops the occurrence.
Record completions before parent restarts clear them, or keep a separate counter that survives those restarts.
There was a problem hiding this comment.
Good catch, fixed in ad129e6. Each repeating task now sets an occurred flag in _repeat (both backends), which ancestor restarts don't clear, and the env records rows from that flag instead of a rise in count. The env test now covers an event inside a repeating task, done in the step its parent restarts; letting the restart clear the flag turns it red.
… findings Repeating tasks set an occurred flag that restarts keep, so the env records a nested event done in the step its parent restarts. Budgets without a time limit build again; only episode_events needs one. tracked moves to the end of TaskCfg and TaskNode so positional fields keep their meaning, and sequence rejects subtasks passed as its flags.
Description
Ports Arena's tracked events to MDP2. A tracked event records when something of interest happens, such as an object being dropped, without changing what counts as success.
An event is built from the same pieces as success (
Milestone,hold,sequence), plus two flags:repeat=Truetracked=TrueUsage
1. Define the event beside the task
2. Read it during training
Tracked events are logged like any other task, and they don't change
Progress/task:The live state is in
mdp2.progress.dropped_object.{count, done_at, ...}, for observations, rewards, or terminations.3. Get per-episode results and the full timeline
With an episode budget,
episode_records()gives one row per episode, and the newepisode_events()gives one row per occurrence:To get Arena's per-episode list of
{name, step}, join the event rows to the records on(world, episode).How it works
tracked: a tracked subtask keeps all of its own progress, butTaskTree.countedfilters it out.countedis the single place that drives a parent's completion and score in both backends. Only subtasks that run together (compose) can be tracked. Tracking a subtask of a sequence, choice, or split, or the root, is a builder error.episode_events(): each repeating task sets an internaloccurredflag in the step it is done, in both backends. A parent's restart doesn't clear the flag, so an event inside a repeating task is recorded even when the parent restarts in the same step. The env's existing fused per-world log kernel, inside the captured step, writes a row wherever the flag is set. There are no new kernel launches and no host syncs.episode_budget × max_episode_lengthrows per repeating task. A task repeats at most once per step, so this always fits, and there is no capacity setting.Performance
Event recording adds no measurable cost:
episode_budget=100_000. Each run: 50 warm-up steps, then 1000 timed steps.ad129e6fa, with and without the recording block in_bind_logs. Runs alternated.Limitations
place=above). That prefixes its use names, progress paths, and observation names, for examplegoalbecomesplace.goal. Observation slices and widths don't change, so policies and checkpoints still load.episode_events(). Without a time limit, the env still builds and records counts, butepisode_events()raises an error, because the buffer can't be sized.sequenceflags.sequencenow takesrepeatandtrackedas keyword arguments, so a subtask can no longer be namedrepeatortracked. Passing a task under those names raises aTypeErrorrather than dropping it. All other changes are additive:trackedis the last field ofTaskCfg, so positional arguments keep their meaning.Type of change
Validation
test_mdp2.py(both backends, eager and captured):test_mdp2_env.py:Progress/taskandprogress/scoreat 1.count, and the first row's step matchesdone_at.countedfilter turns the tracked-task tests red.occurredflag (the bug that greptile found) also turns it red.test/mdp2andtest/envs/test_mdp2_env.pypass locally.uv run isaaclab --formatand the changelog check pass.Checklist
pre-commitchecks withuv run isaaclab --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bump package versions — CI handles that)CONTRIBUTORS.mdor my name already exists there