Fix CircularBuffer backfill broadcast for >2D data#1046
Merged
Conversation
The first-push backfill in CircularBuffer.append hard-coded a 3-D broadcast (is_first_push[None, :, None] and data[None, :, :]), which only lines up when the buffer is exactly (max_len, batch, feature). DcMotorActuator with a variable delay lag range stacks position, velocity, and effort targets into a 3-D tensor (num_envs, num_targets, 3), making the buffer 4-D. The hard-coded condition then misaligns the batch axis with the num_targets axis and raises a broadcast error whenever num_envs != num_targets. The fix derives the broadcast shape from data.ndim so it works for tensors of any rank. Supersedes #1045. Co-authored-by: ZzzzzzS <ZhouZishun@mail.zzshub.cn>
99a0754 to
1c2b483
Compare
rdeits-bd
approved these changes
Jun 4, 2026
rdeits-bd
left a comment
Collaborator
There was a problem hiding this comment.
Ah sorry about that and thanks for the fix. I don't see any new CUDA sync issues after this change.
Qingxiaoming
pushed a commit
to Qingxiaoming/mjlab
that referenced
this pull request
Jun 18, 2026
The first-push backfill in CircularBuffer.append hard-coded a 3-D broadcast (is_first_push[None, :, None] and data[None, :, :]), which only lines up when the buffer is exactly (max_len, batch, feature). DcMotorActuator with a variable delay lag range stacks position, velocity, and effort targets into a 3-D tensor (num_envs, num_targets, 3), making the buffer 4-D. The hard-coded condition then misaligns the batch axis with the num_targets axis and raises a broadcast error whenever num_envs != num_targets. The fix derives the broadcast shape from data.ndim so it works for tensors of any rank. Supersedes mujocolab#1045. Co-authored-by: ZzzzzzS <ZhouZishun@mail.zzshub.cn>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CircularBuffer.appendcrashed with a broadcast mismatch when the buffered data had more than two dimensions. The first-push backfill hard-coded a 3-D broadcast, which misaligns the batch axis with the trailing axis onceDcMotorActuator's variable delay stacks targets into a 3-D tensor. It now derives the broadcast shape fromdata.ndimso backfill works for any rank. The regression came from #1031, which swapped the dimension-agnostic mask for a sync-freetorch.wherebut baked in 3-D views.Supersedes #1045 by @ZzzzzzS, who diagnosed the bug and wrote an equivalent fix (credited as co-author).