Skip to content

Improve observation manager for observation groups with history_length != None. - #1958

Closed
pculbertson-bdai wants to merge 4 commits into
isaac-sim:mainfrom
pculbertson-bdai:pculbertson/history_obs_bugfix
Closed

pculbertson-bdai wants to merge 4 commits into
isaac-sim:mainfrom
pculbertson-bdai:pculbertson/history_obs_bugfix

Conversation

@pculbertson-bdai

@pculbertson-bdai pculbertson-bdai commented Feb 27, 2025 •

Copy link
Copy Markdown

Description

This PR makes some low-level changes to the observation_manager, particularly w/r/t how it handles ObservationGroups with non-zero history_length. It first changes how the observation group shapes are computed - which fixes a shape bug in the env.observation_space for this group downstream.

It also changes the handling of flattened obs groups to construct tensors in a way that the history dimension is preserved.

Fixes #1957.

Type of change

Unsure if this is a bugfix or breaking change, since it would change the ordering of elements in observation groups with history_length != None. Policies trained with the old ordering would not work - but the proposed ordering seems more in line with the shapes described in the documentation.

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@jtigue-bdai jtigue-bdai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @pculbertson-bdai. In general the fix and feature look good. I have a few comment/questions.

Comment on lines +530 to +534
if self._group_obs_concatenate[group_name]:
# Observation shapes should not be mixed if concatenating - raise error.
raise RuntimeError(f"In group '{group_name}', mixed dimension formats encountered: {group_term_dims}")
else:
return group_term_dims

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we want to move "if not concatenate return group_term_dims" out of if flattened and unflattened: and have it run first.

Comment on lines +539 to +543
if not all(h == histories[0] for h in histories):
raise RuntimeError(
f"In group '{group_name}', not all observation terms have the same history dimension:"
f" {group_term_dims}"
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if not all(h == histories[0] for h in histories):
raise RuntimeError(
f"In group '{group_name}', not all observation terms have the same history dimension:"
f" {group_term_dims}"
)
if not all(h == histories[0] for h in histories):
raise RuntimeError(
f"In observation group '{group_name}', not all observation terms have the same history dimension:"
f" {group_term_dims}. These terms cannot be concatenated if not flattened."
)

@ooctipus ooctipus Sep 15, 2025 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am a bit confused about here:
original comment makes sense, assuming all unflattened term is caused by history dimension, it is checking the if the first dimension is the same.

the new suggestion I guess is assuming the unflattened term is not just limited to history dimension, maybe the term itself is returned as high dim, so we tell user you must flatten it.

Then the doc string above seems to suggest unflattened term is cause by history, wrote:

For unflattened terms (tuples of length >= 2), each dims is expected to be of the form:
            (H, d1, d2, ..., d_n)

we need to be more clear what is really happening there, it took me a long time to figure out where the comment is coming frome

Comment on lines +548 to +551
if not all(len(td) == trailing_rank for td in trailing_dims):
raise RuntimeError(
f"In group '{group_name}', observation terms have different trailing ranks: {group_term_dims}"
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if not all(len(td) == trailing_rank for td in trailing_dims):
raise RuntimeError(
f"In group '{group_name}', observation terms have different trailing ranks: {group_term_dims}"
)
if not all(len(td) == trailing_rank for td in trailing_dims):
raise RuntimeError(
f"In observation group '{group_name}', observation terms have different trailing ranks: {group_term_dims}. These terms cannot be concatenated if not flattened."
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the code is currently very difficult to parse I'd suggest put a example in the comment what this block checking, and if passed this block, what fact we can assume about the this unflattened group data

Comment on lines +558 to +561
if not all(td[:-1] == base for td in trailing_dims):
raise RuntimeError(
f"In group '{group_name}', trailing dimensions except last must be the same: {group_term_dims}"
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if not all(td[:-1] == base for td in trailing_dims):
raise RuntimeError(
f"In group '{group_name}', trailing dimensions except last must be the same: {group_term_dims}"
)
if not all(td[:-1] == base for td in trailing_dims):
raise RuntimeError(
f"In observation group '{group_name}', trailing dimensions except last must be the same: {group_term_dims}. These terms cannot be concatenated if not flattened."
)

@ooctipus ooctipus Sep 15, 2025 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't know if assuming concatenate trailing rank, or telling user if trailing rank doesn't match you must flatten is right move

say if you have a group that has two image terms, say
if history length == 5, image 1 has shape (5, 3, 32, 32) and image 2 has shape (5, 3, 32, 32):
-> we should be able to concatenate to (5, 6, 32, 32)

if history length == 5, image 1 has shape (5, 1, 32, 32) and image 2 has shape (5, 3, 32, 32):
-> we should be able to concatenate to (5, 4, 32, 32)

if history length == 5, image 1 has shape (5, 32, 32, 1) and image 2 has shape (5, 32, 32, 3):
-> we should be able to concatenate to (5, 32, 32, 4)

if history length == 5, image 1 has shape (5, 3, 32, 32) and image 2 has shape (5, 32, 32, 1):
-> we should Raise Error tell user that all term's shape must match except the dim to concatenate


# test that the history buffer holds previous data
for _ in range(GROUP_HISTORY_LENGTH):
for _ in range(GROUP_HISTORY_LENGTH - 1):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I believe we want to keep the GROUP_HISTORY_LENGTH so that we fill the buffer and take another step to make sure the history buffer handles filling and rolling.


# compute the increments that the freerange obs manager would add
# over the full history.
increments = torch.arange(GROUP_HISTORY_LENGTH, device=self.env.device).reshape(1, -1, 1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

would have to increase the increments to handle the fill + 1.

"concatenate_terms",
"history_length",
"flatten_history_dim",
]:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I will not make this change

max_len=term_cfg.history_length, batch_size=self._env.num_envs, device=self._env.device
max_len=term_cfg.history_length,
batch_size=self._env.num_envs,
device=self._env.device,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I will not make this change

cfg=mod_cfg,
data_dim=obs_dims,
device=self._env.device,
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I will not make this change

@ooctipus ooctipus left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR,
I agree how we are currently handles history + history concatenation is not the most helpful one, it lacks a lot of feature, and is too aggressive when comes to concatenation

This PR is making the right move to promising direction, but the concept of history + preserves dimension vs how to flatten is a very complex topic and we want to be careful and clear about each case and what move to make, ideally if the program has resolve the plan we log to user what concatenation plan has we resolve.

@Mayankm96
Mayankm96 force-pushed the main branch 2 times, most recently from 2ef7fc8 to f3061a4 Compare January 28, 2026 16:16
@AntoineRichard

AntoineRichard commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Hi @pculbertson-bdai — thank you so much for opening this PR, and for taking the time to contribute to Isaac Lab! 🙏

We're currently doing a big spring-clean of our pull request backlog, which had grown past 400 open PRs. Being honest: at that volume we stopped being able to give every contribution the attention it deserved, and this one is a case where we dropped the ball on getting back to you. That's on us, not on you.

Why this PR is being closed: Here is exactly what we found on this PR when we reviewed the backlog:

Opened 2025-02-27 (about a year ago)
Last commit on the branch 2025-02-27
Last activity from the author about a year ago
Target branch main — note that active development happens on develop; main only receives releases
Review status Changes were requested (jtigue-bdai, ooctipus), but the follow-up never landed
Merge status Conflicts with the base branch — it no longer applies cleanly
Size 4 commit(s), 2 file(s) changed, +226 / -56

It was picked up by the sweep because it targets main instead of develop, and it has been open for about a year. It was then put in the "close" bucket because the author has been silent for about a year — which is the signal we used to tell apart pull requests that are still being worked on from ones that have genuinely been set aside.

We deliberately did not close pull requests that were approved and ready to land, or that were small and clearly still fixing a live bug — there were 27 of those, and we are merging them rather than closing them.

To be completely clear — this is not a judgement on the quality or the value of your work. It's purely about getting the queue down to a size where we can actually review things properly and give contributors real, timely feedback.

One thing worth knowing first: Isaac Lab 3.0 has since shipped. develop is now at
3.0.0 while main is still at 2.3.2, and 3.0 restructured a fair amount — quaternion
conventions, actuator collections, data access, and the Isaac Sim extension imports all
changed. The migration guide
is the place to start if you rebase.

It is also the honest reason a lot of these older pull requests stopped applying: the code
they touched moved or was rewritten underneath them.

If this change is still relevant, please reopen this PR or open a fresh one against develop. With the backlog down to a reviewable size, it should get a response a lot sooner than this one did.

Thanks again for contributing to Isaac Lab, and sorry for the long silence! 💚


🤖 This comment was drafted with AI assistance as part of a maintainer-led sweep of the Isaac Lab pull request backlog. A maintainer is behind this cleanup — but if this closure looks wrong, it may well be, so please push back and we'll take another look.

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.

[Bug Report] Reshape + shape computation issues with observation manager

4 participants