Repository navigation
fix(training): reset NaN-guard device latches under inference mode - #2600
Merged
TATP-233 merged 1 commit intoNov 9, 2026
Merged
Conversation
rsl_rl wraps the whole PPO rollout in torch.inference_mode(). With deferred finite validation (the new default) the guard's device latches are typically first allocated inside that context, so they are inference tensors; poll sites such as the cycle boundary and close() run outside it, and the in-place zero_() in reset_verdict() then raises "Inplace update to inference tensor outside InferenceMode is not allowed". Run the latch reset under torch.inference_mode() explicitly. The reset touches no autograd bookkeeping, so behavior is unchanged for plain tensors, and inference tensors reset cleanly at every poll site. Discovered by the downstream perceptive navigation port: the first full PPO train smoke against current main crashed in close(). Commands: uv run pytest tests/training/test_tensor_diagnostics.py -q (11 passed; new test fails without the fix) Co-authored-by: Cursor <cursoragent@cursor.com>
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
torch.inference_mode(). With deferred finite validation (the default since Follow-up: clean up remaining contract-less defensive code patterns #2591'sdefer_finite_validationdefault flip), the NaN guard's device latches (_device_bad_rows,_device_verdict) are typically first allocated inside that context and are therefore inference tensors.close()→poll_finite_validation()— run outside inference mode, soreset_verdict()'s in-placezero_()raisesRuntimeError: Inplace update to inference tensor outside InferenceMode is not allowedat teardown of every deferred-validation PPO run.torch.inference_mode()explicitly. The reset touches no autograd bookkeeping, so behavior is unchanged for plain tensors, and inference tensors reset cleanly at every poll site.Discovered by the downstream perceptive navigation port (
Motphys/Perceptive-UniLabstaging): the first full PPO train smoke against currentmaincrashed inclose()after one successful iteration.Linked Work
mainValidation
make test-all: in progress separately; see commands belowCommands actually run:
Remote CI route:
main: will run on this PR's head.Impact
Artifacts
Checklist
test_reset_verdict_allows_inference_tensor_latchesfails without the fix)Made with Cursor