Repository navigation
Conversation
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.
Summary
Prevent
torch.inference_mode()contexts (used by RL runners such as RSL-RL during rollout collection andepisode_length_bufupdates) from tainting internal environment, device-layer, task-layer, andTorchWrappersimulator buffers:TorchTensor.__init__withwith torch.inference_mode(False):so lazily cachedsim.model/sim.dataviews (e.g.sim.data.ctrlorsim.data.time) are never permanently markedis_inference=Trueon first access insidetorch.inference_mode().Environment,DeviceLayer,TaskLayer,Simulator,Clock, andflat_scene.build_*entrypoints (plusDeviceLayer._output_buffersallocation) withtorch.inference_mode(False)so internal state tensors remain mutable across transitions out oftorch.inference_mode().self._last_timestep.observationandself._last_timestep.step_typein place insideEnvironment._resetandEnvironment.stepso previously returnedTimeSteptensors are not overwritten by subsequent steps or resets.Testing
EnvironmentInferenceModeTest(Impl.WARP&Impl.CPP, dict & single-tensor observations, constructed inside and outsidetorch.inference_mode()) covering rollouts with auto-reset andsim.data.timewrites insidetorch.inference_mode()followed bystep(), partialreset_with_options(), and fullreset()outsidetorch.inference_mode(), as well asTimeSteptensor immutability.pyink --check,isort --check,pyrefly check, andpytest reaf/simulation/torch/_src/core/ reaf/simulation/torch/_src/builders/flat_scene/build_test.py(210 passed).