Skip to content

Fixes suction cup status tensor shape in terminations.py#4507

Merged
kellyguo11 merged 4 commits intoisaac-sim:mainfrom
808brick:main
Feb 17, 2026
Merged

Fixes suction cup status tensor shape in terminations.py#4507
kellyguo11 merged 4 commits intoisaac-sim:mainfrom
808brick:main

Conversation

@808brick
Copy link
Copy Markdown
Contributor

@808brick 808brick commented Feb 1, 2026

The termination_manager expects a tensor of [1] but the previous view setup was creating a tensor of [1,1] causing the IsaacLab sim/task to crash

Description

Changed the view shape in line 63 of terminations.py from

suction_cup_status = surface_gripper.state.view(-1, 1) 

to

suction_cup_status = surface_gripper.state.view(-1) 

Which provided the correct tensor shape expected by termination_manager.py

Fixes # 4506

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Screenshots

Before

Screenshot from 2026-01-31 19-25-22

After

Screenshot from 2026-01-31 19-22-44

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation [Not Needed, should return normal functionality]
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works [Open To Feedback Here]
  • 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 [Not Needed]

The termination_manager expects a tensor of [1] but the previous view setup was creating a tensor of [1,1] causing the IsaacLab sim/task to crash

Signed-off-by: Raymond Andrade <raymond808state1@gmail.com>
Fix suction cup status tensor shape in terminations.py
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 1, 2026

Greptile Overview

Greptile Summary

Changed surface_gripper.state.view(-1, 1) to surface_gripper.state.view(-1) in the cubes_stacked termination function to fix a tensor shape mismatch.

Key Changes:

  • Fixed tensor reshape from [num_envs, 1] to [num_envs] on line 63
  • The TerminationManager expects termination functions to return boolean tensors of shape [num_envs] (1D), not [num_envs, 1] (2D)
  • This resolves the crash when the termination manager tries to store the result in _term_dones[:, i]

Additional Notes:

  • The same pattern exists in place/mdp/terminations.py at lines 53 and 101, which may need the same fix
  • The observation functions in stack/mdp/observations.py correctly use .view(-1, 1) since observations have different shape requirements

Confidence Score: 4/5

  • Safe to merge - fixes a clear shape mismatch bug with minimal risk
  • The fix is correct and addresses a real bug. The change is minimal (removing one dimension from tensor reshape) and directly resolves the shape mismatch between what the termination function returns and what TerminationManager expects. However, there appear to be similar issues in other files that may need attention.
  • Check place/mdp/terminations.py for similar shape issues at lines 53 and 101

Important Files Changed

Filename Overview
source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/stack/mdp/terminations.py Fixed tensor shape from [num_envs, 1] to [num_envs] to match TerminationManager requirements

Sequence Diagram

sequenceDiagram
    participant Env as ManagerBasedRLEnv
    participant TM as TerminationManager
    participant CT as cubes_stacked()
    participant SG as SurfaceGripper
    
    Env->>TM: compute()
    TM->>CT: call termination function
    CT->>SG: surface_gripper.state
    SG-->>CT: raw state tensor
    CT->>CT: view(-1) reshape to [num_envs]
    CT->>CT: compare with -1 (open state)
    CT->>CT: logical_and with stacked condition
    CT-->>TM: boolean tensor [num_envs]
    TM->>TM: store in _term_dones[:, i]
    TM-->>Env: combined termination signal [num_envs]
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@AntoineRichard
Copy link
Copy Markdown
Collaborator

AntoineRichard commented Feb 4, 2026

Hi @808brick. Thanks for reporting this! That looks like a bug indeed! Could you follow Greptiles suggestion and update place/mdp/terminations.py ? Thanks! @kellyguo11 for viz. We may want to get that in both main and develop.

@kellyguo11 kellyguo11 changed the title Fix suction cup status tensor shape in terminations.py Fixes suction cup status tensor shape in terminations.py Feb 4, 2026
@808brick
Copy link
Copy Markdown
Contributor Author

808brick commented Feb 6, 2026 via email

@808brick
Copy link
Copy Markdown
Contributor Author

Hey @AntoineRichard, apologies for the delay on this fix. I've gone ahead and made the change requested by greptile.

It is worth noting that the average user would never run into the tensor shape mismatch error since the two tasks in the place env [Isaac-Place-Toy2Box-Agibot-Right-Arm-RmpFlow-v0, Isaac-Place-Mug-Agibot-Left-Arm-RmpFlow-v0] do not utilize surface grippers. Thus the if statement which encompass the "buggy" lines never gets triggered.

But I was able to reproduce the tensor shape mismatch error by importing a suction gripper into the environment/task:

 File "/home/ray/Workspaces/IsaacLab/source/isaaclab/isaaclab/envs/manager_based_rl_env.py", line 204, in step
    self.reset_buf = self.termination_manager.compute()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ray/Workspaces/IsaacLab/source/isaaclab/isaaclab/managers/termination_manager.py", line 173, in compute
    self._terminated_buf |= value
RuntimeError: output with shape [1] doesn't match the broadcast shape [1, 1]

Which was remedied by changing the shape from (-1, 1) to surface_gripper.state.view(-1).

So for the sake of modularity, I indeed agree with changes proposed by greptile and do not recommend removing these code blocks as it is still needed for users who may want to complete the place task with a custom suction based robot.

Let me know if there are any other additional changes which should be made for this particular issue.

@AntoineRichard
Copy link
Copy Markdown
Collaborator

No worries! Thanks for making the changes! @rebeccazhang0707 could you take a look?

@kellyguo11 kellyguo11 merged commit e10c302 into isaac-sim:main Feb 17, 2026
8 of 12 checks passed
0iui0 pushed a commit to 0iui0/IsaacLab that referenced this pull request Apr 22, 2026
)

The termination_manager expects a tensor of [1] but the previous view
setup was creating a tensor of [1,1] causing the IsaacLab sim/task to
crash

# Description

<!--
Thank you for your interest in sending a pull request. Please make sure
to check the contribution guidelines.

Link:
https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html

💡 Please try to keep PRs small and focused. Large PRs are harder to
review and merge.
-->

Changed the view shape in line 63 of `terminations.py` from 
```python
suction_cup_status = surface_gripper.state.view(-1, 1) 
```
to
```python
suction_cup_status = surface_gripper.state.view(-1) 
```
Which provided the correct tensor shape expected by
`termination_manager.py`

Fixes # [4506](isaac-sim#4506)


## Type of change

<!-- As you go through the list, delete the ones that are not
applicable. -->

- Bug fix (non-breaking change which fixes an issue)

## Screenshots

### Before 

<img width="1029" height="441" alt="Screenshot from 2026-01-31 19-25-22"
src="https://github.com/user-attachments/assets/8c8c20eb-6fa7-4d1f-bc98-b93c773dcc74"
/>

### After 
<img width="1684" height="917" alt="Screenshot from 2026-01-31 19-22-44"
src="https://github.com/user-attachments/assets/6e1bf676-37d6-4d8e-bc83-6b5e8464aa62"
/>


<!--
Example:

| Before | After |
| ------ | ----- |
| _gif/png before_ |<img width="1684" height="917" alt="Screenshot from
2026-01-31 19-22-44"
src="https://github.com/user-attachments/assets/6e1bf676-37d6-4d8e-bc83-6b5e8464aa62"
/>|

To upload images to a PR -- simply drag and drop an image while in edit
mode and it should upload the image directly. You can then paste that
source into the above before/after sections.
-->

## Checklist

- [X] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [X] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation _[Not
Needed, should return normal functionality]_
- [X] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works _[Open To Feedback Here]_
- [ ] 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 _[Not Needed]_

---------

Signed-off-by: Raymond Andrade <raymond808state1@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants