Skip to content

Fix DelayBuffer state mutation on invalid lag - #7893

Merged
ooctipus merged 6 commits into
isaac-sim:developfrom
Xalzeroph:fix/delay-buffer-transactional-lag
Sep 22, 2026
Merged

ooctipus merged 6 commits into
isaac-sim:developfrom
Xalzeroph:fix/delay-buffer-transactional-lag

Conversation

@Xalzeroph

@Xalzeroph Xalzeroph commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #7793

DelayBuffer.set_time_lag currently writes the requested lag into the live tensor before validating the resulting range. If validation raises, the invalid value remains in the buffer and later compute() calls use it.

This validates the requested scalar or tensor delays before assigning them to the live tensor. Invalid inputs raise immediately without changing the lag tensor or its cached bounds. Valid updates retain the existing tensor identity, without cloning the full buffer state.

Type of change

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

Checklist

  • I have run the pre-commit checks
  • I have added regression coverage for the rejected scalar and tensor updates
  • I have added a changelog fragment

Validation: all 7 tests in test_delay_buffer.py passed. The added early-validation regression failed against the previous clone-based implementation and passed with this change. Additional CPU and CUDA checks covered valid full/subset updates, empty selections, rejected inputs, tensor identity, cached bounds, and subsequent delayed output. Full pre-commit checks and git diff --check passed.

Add test for invalid time lag handling in delay buffer.

Signed-off-by: Xu Zihan <[email protected]>
Fixes an issue with DelayBuffer that caused invalid delays to remain in the buffer after validation failure.

Signed-off-by: Xu Zihan <[email protected]>
@Xalzeroph
Xalzeroph requested a review from a team September 19, 2026 01:44
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Sep 19, 2026

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isaac Lab Review Bot

The change makes DelayBuffer.set_time_lag transactional: updates are staged, validated as a complete candidate state, and committed only after validation succeeds. Rejected scalar and tensor lags therefore leave the live lag tensor and cached extrema unchanged.

  • Design and architecture: State remains owned by DelayBuffer, with the committed lag tensor and cached minimum/maximum updated together. Using copy_() preserves the existing tensor identity, while compute() continues to consume the same _time_lags object.
  • API: Accepted inputs, validation errors, device conversion, and successful update semantics remain unchanged. The observable behavior on failed validation is corrected without renaming or removing public APIs, and the package includes an appropriate past-tense changelog fragment.
  • Implementation: Both scalar and tensor updates now target a clone before range validation, and the live state is committed only on success. Regression coverage checks rejected negative and over-limit updates. The added clone introduces a small per-update allocation, and the new test still warrants execution in the project environment because it was not run by the author, but neither issue requires a pre-merge correction based on the supplied patch.

No blocking issues. No inline issue met the actionable-evidence threshold; the assessment above records the review feedback.

Automated review; human maintainers own approval decisions.

@greptile-apps

greptile-apps Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The implementation appears safe to merge; the only concern is a non-blocking gap in regression coverage for retained time_lags tensor identity.

Findings

  1. P2 Tensor identity remains untested ▶

Summary

This PR makes DelayBuffer.set_time_lag transactional by staging lag updates in a cloned tensor, validating the complete candidate, and committing it in place only when valid.

  • Prevents rejected scalar and tensor updates from mutating live buffer state or cached extrema.
  • Preserves the identity of the publicly exposed time_lags tensor through an in-place commit.
  • Adds regression coverage for negative, oversized, and mixed-validity partial updates, though the identity guarantee itself remains unasserted.
  • Adds a matching bug-fix changelog fragment.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Requested lag update] --> B[Clone current time_lags]
  B --> C[Apply update to candidate]
  C --> D[Compute and validate candidate extrema]
  D -->|Invalid| E[Raise error<br/>live state unchanged]
  D -->|Valid| F[copy_ candidate into live tensor]
  F --> G[Commit cached min and max]
Loading

Reviews (1) · Last reviewed commit: "Add changelog for invalid lag state fix"

Comment on lines +108 to +113
expected_lags = delay_buffer.time_lags.clone()

with pytest.raises(ValueError):
delay_buffer.set_time_lag(time_lag, batch_ids)

assert torch.equal(delay_buffer.time_lags, expected_lags)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Tensor identity remains untested

This regression test verifies only the tensor values and cached extrema, while the implementation explicitly preserves time_lags identity for callers that retain a reference. Retain the pre-call tensor and assert that it remains the same object after the rejected update. Otherwise, a future change from copy_() to tensor reassignment could break that compatibility guarantee while this test continues to pass.

Suggested change
expected_lags = delay_buffer.time_lags.clone()
with pytest.raises(ValueError):
delay_buffer.set_time_lag(time_lag, batch_ids)
assert torch.equal(delay_buffer.time_lags, expected_lags)
expected_lags = delay_buffer.time_lags
expected_values = expected_lags.clone()
with pytest.raises(ValueError):
delay_buffer.set_time_lag(time_lag, batch_ids)
assert delay_buffer.time_lags is expected_lags
assert torch.equal(delay_buffer.time_lags, expected_values)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@ooctipus ooctipus self-assigned this Sep 21, 2026
@ooctipus ooctipus moved this to Done in Isaac Lab Sep 21, 2026
@ooctipus ooctipus moved this from Done to Ready to merge in Isaac Lab Sep 21, 2026
@ooctipus ooctipus added this to the Isaac Lab 3.0 GA milestone Sep 21, 2026
@ooctipus ooctipus added the ci:run-docker Trigger the on-demand Docker and GPU CI workflow label Sep 21, 2026
@ooctipus

Copy link
Copy Markdown
Collaborator

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Sep 22, 2026
@ooctipus ooctipus added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Sep 22, 2026
@ooctipus
ooctipus merged commit 22fcd71 into isaac-sim:develop Sep 22, 2026
113 of 115 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Isaac Lab Sep 22, 2026
ooctipus pushed a commit to ooctipus/IsaacLab that referenced this pull request Sep 23, 2026
Fixes isaac-sim#7793

DelayBuffer.set_time_lag currently writes the requested lag into the
live tensor before validating the resulting range. If validation raises,
the invalid value remains in the buffer and later compute() calls use
it.

This validates the requested scalar or tensor delays before assigning
them to the live tensor. Invalid inputs raise immediately without
changing the lag tensor or its cached bounds. Valid updates retain the
existing tensor identity, without cloning the full buffer state.

- [x] Bug fix (non-breaking change which fixes an existing issue)

- [x] I have run the pre-commit checks
- [x] I have added regression coverage for the rejected scalar and
tensor updates
- [x] I have added a changelog fragment

Validation: all 7 tests in test_delay_buffer.py passed. The added
early-validation regression failed against the previous clone-based
implementation and passed with this change. Additional CPU and CUDA
checks covered valid full/subset updates, empty selections, rejected
inputs, tensor identity, cached bounds, and subsequent delayed output.
Full pre-commit checks and git diff --check passed.

---------

Signed-off-by: Xu Zihan <[email protected]>
Co-authored-by: Octi Zhang <[email protected]>

(cherry picked from commit 22fcd71)
ooctipus added a commit that referenced this pull request Sep 24, 2026
…ng docs (#7957)

Backports the three changes from the September 20–23 `develop` audit
that are missing from `release/3.0.0`, alongside the existing
cloning-guide backport:

- #7722 (`4cf439dfeb`): reject a second `SimulationContext` construction
instead of silently discarding its configuration. Includes the original
fixture cleanup and regression coverage.
- #7893 (`22fcd71bc4`): validate DelayBuffer lag values before mutating
its live configuration.
- #7947 (`6e9ef17f59`): make `v3.0.0-EA` the default documentation
version in deployment and local multi-version builds.
- #7129 (`354168560f`): clarify that `replicate_physics=False` skips the
active physics context while other declared replication contexts still
run.

**Compatibility:** repeated `SimulationContext(...)` calls now raise.
Retrieve the live context with `SimulationContext.instance()`, or call
`clear_instance()` before constructing a replacement. The original major
changelog fragment includes this migration.

The runtime and test files match current `develop`. The docs-default
backport adapts the release branch's existing redirect template,
validates the target page, and preserves explicit overrides. The
cloning-guide backport preserves the current release APIs; its obsolete
sections were already removed.

## Release audit

Checked all **35 PRs** merged into `develop` from **2026-09-20 16:43:18
UTC** through `cff81e8473` (September 23), against release head
`5d3e0b695e`. **32 are already covered; the remaining three are included
here.** Git history, patch equivalence, GitHub's merged PR list, and
remaining file differences were checked. Branch-specific
version/changelog compilation and existing release-only changes are
preserved.

<details>
<summary>Already covered PRs</summary>

26 have an equivalent patch in release: #7919, #7922, #7923, #7924,
#7925, #6758, #7928, #7902, #7927, #7891, #7931, #7691, #7861, #7929,
#7916, #7939, #4609, #7942, #7940, #7948, #7937, #7955, #7960, #7961,
#7970, #7958.

Six were squash-merged or adapted: #7530 and #7899 in #7926; #7637 in
#7933; #7860 in #7936; #7954 and #7950 in #7964. Their implementation
differences were checked against the current release tree.

</details>

## Validation

- **276 tests passed**: SimulationContext (51, including CPU/CUDA),
headless context construction (15), nine schema/fragment suites (165),
four manager suites (38), and DelayBuffer (7).
- Both backported regressions reproduce with the original release
implementations.
- Docs redirect recipe: local/deployment EA defaults, explicit override,
and missing-target rejection passed with a stubbed Sphinx builder.
- All 22 changed files match the intended backport scope; `uv run
isaaclab -f` and `git diff --check` passed.
- Fresh Sphinx validation (`-b dummy -W --keep-going`): passed without
warnings, excluding static assets as the HTML builder does. Full HTML
documentation CI is running.

Local runtime validation used PyTorch 2.12.0, CUDA 13.0, Isaac Sim
6.0.1.0, and an RTX 5090. Existing runtime/deprecation warnings
occurred; the CI jobs validate the pinned environments.

The previous [docs CI
failure](https://github.com/isaac-sim/IsaacLab/actions/runs/35795116307/job/106972539281)
was an external connection reset fetching the Omniverse intersphinx
inventory, producing one warning under `-W`. That URL returned HTTP 200
when rechecked. This update starts a fresh docs build.

---------

Co-authored-by: hujc <[email protected]>
Co-authored-by: Zihan Xu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug Report] DelayBuffer.set_time_lag leaves invalid state after raising ValueError

2 participants