From c3b6baf52fc4eddaefde30850156ee4a7974f523 Mon Sep 17 00:00:00 2001 From: vmoens Date: Mon, 22 Sep 2025 09:07:16 +0100 Subject: [PATCH] Update [ghstack-poisoned] --- torchrl/envs/batched_envs.py | 2 +- torchrl/envs/common.py | 2 +- torchrl/modules/llm/policies/transformers_wrapper.py | 2 +- torchrl/objectives/a2c.py | 6 +++--- torchrl/objectives/cql.py | 4 ++-- torchrl/objectives/crossq.py | 4 ++-- torchrl/objectives/ddpg.py | 2 +- torchrl/objectives/decision_transformer.py | 4 ++-- torchrl/objectives/deprecated.py | 4 ++-- torchrl/objectives/dqn.py | 8 ++++---- torchrl/objectives/gail.py | 2 +- torchrl/objectives/iql.py | 8 ++++---- torchrl/objectives/multiagent/qmixer.py | 2 +- torchrl/objectives/redq.py | 4 ++-- torchrl/objectives/reinforce.py | 6 +++--- torchrl/objectives/sac.py | 10 +++++----- torchrl/objectives/td3.py | 4 ++-- torchrl/objectives/td3_bc.py | 4 ++-- torchrl/record/loggers/wandb.py | 6 +++--- 19 files changed, 42 insertions(+), 42 deletions(-) diff --git a/torchrl/envs/batched_envs.py b/torchrl/envs/batched_envs.py index f38a1805be6..2baa465b74b 100644 --- a/torchrl/envs/batched_envs.py +++ b/torchrl/envs/batched_envs.py @@ -308,7 +308,7 @@ def __init__( num_sub_threads: int = 1, serial_for_single: bool = False, non_blocking: bool = False, - mp_start_method: str = None, + mp_start_method: str | None = None, use_buffers: bool | None = None, consolidate: bool = True, ): diff --git a/torchrl/envs/common.py b/torchrl/envs/common.py index ee02dcf0e39..0bf2d4bc34b 100644 --- a/torchrl/envs/common.py +++ b/torchrl/envs/common.py @@ -2267,7 +2267,7 @@ def register_gym( entry_point: Callable | None = None, transform: Transform | None = None, # noqa: F821 info_keys: list[NestedKey] | None = None, - backend: str = None, + backend: str | None = None, to_numpy: bool = False, reward_threshold: float | None = None, nondeterministic: bool = False, diff --git a/torchrl/modules/llm/policies/transformers_wrapper.py b/torchrl/modules/llm/policies/transformers_wrapper.py index d1b7e209f79..e03eaceea7c 100644 --- a/torchrl/modules/llm/policies/transformers_wrapper.py +++ b/torchrl/modules/llm/policies/transformers_wrapper.py @@ -2460,7 +2460,7 @@ def __init__( model, max_concurrency: int = 16, validate_model: bool = True, - actor_name: str = None, + actor_name: str | None = None, num_gpus: int = 1, num_cpus: int = 1, **kwargs, diff --git a/torchrl/objectives/a2c.py b/torchrl/objectives/a2c.py index 922df246aff..3c56199dffe 100644 --- a/torchrl/objectives/a2c.py +++ b/torchrl/objectives/a2c.py @@ -282,12 +282,12 @@ def __init__( loss_critic_type: str = "smooth_l1", gamma: float | None = None, separate_losses: bool = False, - advantage_key: str = None, - value_target_key: str = None, + advantage_key: str | None = None, + value_target_key: str | None = None, functional: bool = True, actor: ProbabilisticTensorDictSequential = None, critic: ProbabilisticTensorDictSequential = None, - reduction: str = None, + reduction: str | None = None, clip_value: float | None = None, **kwargs, ): diff --git a/torchrl/objectives/cql.py b/torchrl/objectives/cql.py index 580bd40415d..5493887d577 100644 --- a/torchrl/objectives/cql.py +++ b/torchrl/objectives/cql.py @@ -291,7 +291,7 @@ def __init__( num_random: int = 10, with_lagrange: bool = False, lagrange_thresh: float = 0.0, - reduction: str = None, + reduction: str | None = None, deactivate_vmap: bool = False, ) -> None: self._out_keys = None @@ -1100,7 +1100,7 @@ def __init__( delay_value: bool = True, gamma: float | None = None, action_space=None, - reduction: str = None, + reduction: str | None = None, ) -> None: self._in_keys = None if reduction is None: diff --git a/torchrl/objectives/crossq.py b/torchrl/objectives/crossq.py index d370d5f5921..68c7881c6dc 100644 --- a/torchrl/objectives/crossq.py +++ b/torchrl/objectives/crossq.py @@ -266,9 +266,9 @@ def __init__( action_spec=None, fixed_alpha: bool = False, target_entropy: str | float = "auto", - priority_key: str = None, + priority_key: str | None = None, separate_losses: bool = False, - reduction: str = None, + reduction: str | None = None, deactivate_vmap: bool = False, ) -> None: self._in_keys = None diff --git a/torchrl/objectives/ddpg.py b/torchrl/objectives/ddpg.py index f55adaa78f1..e22cf565f72 100644 --- a/torchrl/objectives/ddpg.py +++ b/torchrl/objectives/ddpg.py @@ -201,7 +201,7 @@ def __init__( delay_value: bool = True, gamma: float | None = None, separate_losses: bool = False, - reduction: str = None, + reduction: str | None = None, ) -> None: self._in_keys = None if reduction is None: diff --git a/torchrl/objectives/decision_transformer.py b/torchrl/objectives/decision_transformer.py index 47135113f32..9d234c694d9 100644 --- a/torchrl/objectives/decision_transformer.py +++ b/torchrl/objectives/decision_transformer.py @@ -85,7 +85,7 @@ def __init__( fixed_alpha: bool = False, target_entropy: str | float = "auto", samples_mc_entropy: int = 1, - reduction: str = None, + reduction: str | None = None, ) -> None: self._in_keys = None self._out_keys = None @@ -296,7 +296,7 @@ def __init__( actor_network: ProbabilisticActor, *, loss_function: str = "l2", - reduction: str = None, + reduction: str | None = None, device: torch.device | None = None, ) -> None: self._in_keys = None diff --git a/torchrl/objectives/deprecated.py b/torchrl/objectives/deprecated.py index 58b6a1121c4..08c6f7de57f 100644 --- a/torchrl/objectives/deprecated.py +++ b/torchrl/objectives/deprecated.py @@ -163,9 +163,9 @@ def __init__( delay_qvalue: bool = True, gSDE: bool = False, gamma: float | None = None, - priority_key: str = None, + priority_key: str | None = None, separate_losses: bool = False, - reduction: str = None, + reduction: str | None = None, deactivate_vmap: bool = False, ): self._in_keys = None diff --git a/torchrl/objectives/dqn.py b/torchrl/objectives/dqn.py index 27ff49def64..aeccf527108 100644 --- a/torchrl/objectives/dqn.py +++ b/torchrl/objectives/dqn.py @@ -179,8 +179,8 @@ def __init__( double_dqn: bool = False, gamma: float | None = None, action_space: str | TensorSpec = None, - priority_key: str = None, - reduction: str = None, + priority_key: str | None = None, + reduction: str | None = None, ) -> None: if reduction is None: reduction = "mean" @@ -455,8 +455,8 @@ def __init__( *, gamma: float, delay_value: bool = True, - priority_key: str = None, - reduction: str = None, + priority_key: str | None = None, + reduction: str | None = None, ): if reduction is None: reduction = "mean" diff --git a/torchrl/objectives/gail.py b/torchrl/objectives/gail.py index 7c11c048327..edace907339 100644 --- a/torchrl/objectives/gail.py +++ b/torchrl/objectives/gail.py @@ -78,7 +78,7 @@ def __init__( *, use_grad_penalty: bool = False, gp_lambda: float = 10, - reduction: str = None, + reduction: str | None = None, ) -> None: self._in_keys = None self._out_keys = None diff --git a/torchrl/objectives/iql.py b/torchrl/objectives/iql.py index 7ec5a961b09..4f8e53a30d2 100644 --- a/torchrl/objectives/iql.py +++ b/torchrl/objectives/iql.py @@ -266,9 +266,9 @@ def __init__( temperature: float = 1.0, expectile: float = 0.5, gamma: float | None = None, - priority_key: str = None, + priority_key: str | None = None, separate_losses: bool = False, - reduction: str = None, + reduction: str | None = None, deactivate_vmap: bool = False, ) -> None: self._in_keys = None @@ -785,9 +785,9 @@ def __init__( temperature: float = 1.0, expectile: float = 0.5, gamma: float | None = None, - priority_key: str = None, + priority_key: str | None = None, separate_losses: bool = False, - reduction: str = None, + reduction: str | None = None, ) -> None: self._in_keys = None self._out_keys = None diff --git a/torchrl/objectives/multiagent/qmixer.py b/torchrl/objectives/multiagent/qmixer.py index 35897280f15..5056510bd06 100644 --- a/torchrl/objectives/multiagent/qmixer.py +++ b/torchrl/objectives/multiagent/qmixer.py @@ -195,7 +195,7 @@ def __init__( delay_value: bool = True, gamma: float | None = None, action_space: str | TensorSpec = None, - priority_key: str = None, + priority_key: str | None = None, ) -> None: super().__init__() self._in_keys = None diff --git a/torchrl/objectives/redq.py b/torchrl/objectives/redq.py index dd79aa37257..e4a5b0da209 100644 --- a/torchrl/objectives/redq.py +++ b/torchrl/objectives/redq.py @@ -279,9 +279,9 @@ def __init__( delay_qvalue: bool = True, gSDE: bool = False, gamma: float | None = None, - priority_key: str = None, + priority_key: str | None = None, separate_losses: bool = False, - reduction: str = None, + reduction: str | None = None, deactivate_vmap: bool = False, ): if reduction is None: diff --git a/torchrl/objectives/reinforce.py b/torchrl/objectives/reinforce.py index bada3bd95e1..84feca3e34f 100644 --- a/torchrl/objectives/reinforce.py +++ b/torchrl/objectives/reinforce.py @@ -249,13 +249,13 @@ def __init__( delay_value: bool = False, loss_critic_type: str = "smooth_l1", gamma: float | None = None, - advantage_key: str = None, - value_target_key: str = None, + advantage_key: str | None = None, + value_target_key: str | None = None, separate_losses: bool = False, functional: bool = True, actor: ProbabilisticTensorDictSequential = None, critic: ProbabilisticTensorDictSequential = None, - reduction: str = None, + reduction: str | None = None, clip_value: float | None = None, ) -> None: if actor is not None: diff --git a/torchrl/objectives/sac.py b/torchrl/objectives/sac.py index 7a5e83073ca..a3f9fe87560 100644 --- a/torchrl/objectives/sac.py +++ b/torchrl/objectives/sac.py @@ -325,16 +325,16 @@ def __init__( alpha_init: float = 1.0, min_alpha: float | None = None, max_alpha: float | None = None, - action_spec=None, + action_spec: TensorSpec | None = None, fixed_alpha: bool = False, target_entropy: str | float = "auto", delay_actor: bool = False, delay_qvalue: bool = True, delay_value: bool = True, gamma: float | None = None, - priority_key: str = None, + priority_key: str | None = None, separate_losses: bool = False, - reduction: str = None, + reduction: str | None = None, skip_done_states: bool = False, deactivate_vmap: bool = False, ) -> None: @@ -1195,9 +1195,9 @@ def __init__( target_entropy_weight: float = 0.98, target_entropy: str | Number = "auto", delay_qvalue: bool = True, - priority_key: str = None, + priority_key: str | None = None, separate_losses: bool = False, - reduction: str = None, + reduction: str | None = None, skip_done_states: bool = False, deactivate_vmap: bool = False, ): diff --git a/torchrl/objectives/td3.py b/torchrl/objectives/td3.py index b5623774d82..a201fe5a72c 100644 --- a/torchrl/objectives/td3.py +++ b/torchrl/objectives/td3.py @@ -236,9 +236,9 @@ def __init__( delay_actor: bool = True, delay_qvalue: bool = True, gamma: float | None = None, - priority_key: str = None, + priority_key: str | None = None, separate_losses: bool = False, - reduction: str = None, + reduction: str | None = None, deactivate_vmap: bool = False, ) -> None: if reduction is None: diff --git a/torchrl/objectives/td3_bc.py b/torchrl/objectives/td3_bc.py index 75dee812fed..796801c75d9 100644 --- a/torchrl/objectives/td3_bc.py +++ b/torchrl/objectives/td3_bc.py @@ -251,9 +251,9 @@ def __init__( loss_function: str = "smooth_l1", delay_actor: bool = True, delay_qvalue: bool = True, - priority_key: str = None, + priority_key: str | None = None, separate_losses: bool = False, - reduction: str = None, + reduction: str | None = None, deactivate_vmap: bool = False, ) -> None: if reduction is None: diff --git a/torchrl/record/loggers/wandb.py b/torchrl/record/loggers/wandb.py index 284cc4d497b..aa21978df3d 100644 --- a/torchrl/record/loggers/wandb.py +++ b/torchrl/record/loggers/wandb.py @@ -52,9 +52,9 @@ def __init__( self, exp_name: str, offline: bool = False, - save_dir: str = None, - id: str = None, - project: str = None, + save_dir: str | None = None, + id: str | None = None, + project: str | None = None, *, video_fps: int = 32, **kwargs,