We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 09a5ddf + cdffc9b commit 8d89292Copy full SHA for 8d89292
1 file changed
torchrl/modules/tensordict_module/rnn.py
@@ -2461,10 +2461,17 @@ def __init__(self):
2461
)
2462
2463
def get_mode(self) -> bool | None:
2464
+ # Dynamo can't trace ContextVar.get; fall back to the parent's plain
2465
+ # attribute under torch.compile. set_mode keeps both in sync so this
2466
+ # stays correct (compile traces a single thread).
2467
+ if is_compiling():
2468
+ return self._mode
2469
return self._context_mode.get()
2470
2471
def set_mode(self, mode: bool | None) -> None:
- self._context_mode.set(mode)
2472
+ self._mode = mode
2473
+ if not is_compiling():
2474
+ self._context_mode.set(mode)
2475
2476
2477
recurrent_mode_state_manager = _RecurrentModeContextManager()
0 commit comments