Skip to content

[FIX BUG]: Weld constraint in multi-env #1386

Closed
LeonLiu4 wants to merge 13 commits intoGenesis-Embodied-AI:mainfrom
LeonLiu4:fix/weld-multi-env
Closed

[FIX BUG]: Weld constraint in multi-env #1386
LeonLiu4 wants to merge 13 commits intoGenesis-Embodied-AI:mainfrom
LeonLiu4:fix/weld-multi-env

Conversation

@LeonLiu4
Copy link
Contributor

If envs_idx contains multiple environments but link1_idx/link2_idx are length-1, we now np.repeat those indices so their length matches envs_idx. This prevents silent out-of-bounds reads that dropped welds in all but the first environment.

Addresses: #1383

_, link2_idx, envs_idx = self._sanitize_1D_io_variables(
None, link2_idx, self.n_links, envs_idx, idx_name="links_idx", skip_allocation=True, unsafe=unsafe
)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not cast from torch to numpy, this is irrelevant.


if envs_idx is not None and envs_idx.shape[0] > 1:
if link1_idx.shape[0] == 1:
link1_idx = np.repeat(link1_idx, envs_idx.shape[0])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use torch.repeat

Copy link
Collaborator

@duburcqa duburcqa Jul 10, 2025

Choose a reason for hiding this comment

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

By the way, no need to check if it is a tensor. It has been sanitized as torch tensor already.

@duburcqa
Copy link
Collaborator

Why the sanitize helper was not able to catch this dimensionality issue ? This is basically the whole point of this method.

@duburcqa
Copy link
Collaborator

Superseded by #1390

@duburcqa duburcqa closed this Jul 10, 2025
@LeonLiu4 LeonLiu4 deleted the fix/weld-multi-env branch July 10, 2025 17:22
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.

2 participants