Repository navigation
Improve observation manager for observation groups with history_length != None. - #1958
pculbertson-bdai wants to merge 4 commits into
Conversation
jtigue-bdai
left a comment
There was a problem hiding this comment.
Thanks @pculbertson-bdai. In general the fix and feature look good. I have a few comment/questions.
| 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 |
There was a problem hiding this comment.
I think we want to move "if not concatenate return group_term_dims" out of if flattened and unflattened: and have it run first.
| 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}" | ||
| ) |
There was a problem hiding this comment.
| 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." | |
| ) |
There was a problem hiding this comment.
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
| 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}" | ||
| ) |
There was a problem hiding this comment.
| 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." | |
| ) |
There was a problem hiding this comment.
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
| 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}" | ||
| ) |
There was a problem hiding this comment.
| 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." | |
| ) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
would have to increase the increments to handle the fill + 1.
| "concatenate_terms", | ||
| "history_length", | ||
| "flatten_history_dim", | ||
| ]: |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
I will not make this change
| cfg=mod_cfg, | ||
| data_dim=obs_dims, | ||
| device=self._env.device, | ||
| ) |
There was a problem hiding this comment.
I will not make this change
There was a problem hiding this comment.
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.
2ef7fc8 to
f3061a4
Compare
|
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:
It was picked up by the sweep because it targets 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. It is also the honest reason a lot of these older pull requests stopped applying: the code If this change is still relevant, please reopen this PR or open a fresh one against 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. |
Description
This PR makes some low-level changes to the
observation_manager, particularly w/r/t how it handlesObservationGroupswith non-zerohistory_length. It first changes how the observation group shapes are computed - which fixes a shape bug in theenv.observation_spacefor 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.Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there