From dcd825c4340f8c31ae02ba072ad4398c96f486bb Mon Sep 17 00:00:00 2001 From: Vincent Moens Date: Wed, 3 Jul 2024 11:05:23 +0100 Subject: [PATCH] init --- .github/scripts/m1_script.sh | 2 +- .github/workflows/wheels.yml | 4 ++-- setup.py | 2 +- torchrl/collectors/collectors.py | 12 ++++++------ torchrl/envs/common.py | 13 +------------ torchrl/envs/transforms/transforms.py | 9 +-------- torchrl/modules/distributions/continuous.py | 5 +++-- torchrl/modules/tensordict_module/actors.py | 15 ++++++--------- version.txt | 2 +- 9 files changed, 22 insertions(+), 42 deletions(-) diff --git a/.github/scripts/m1_script.sh b/.github/scripts/m1_script.sh index 6552d8e4622..6da1cad5d79 100644 --- a/.github/scripts/m1_script.sh +++ b/.github/scripts/m1_script.sh @@ -1,5 +1,5 @@ #!/bin/bash -export TORCHRL_BUILD_VERSION=0.4.0 +export TORCHRL_BUILD_VERSION=0.5.0 ${CONDA_RUN} pip install git+https://github.com/pytorch/tensordict.git -U diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 9b2e57db531..7f89ef08635 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -32,7 +32,7 @@ jobs: run: | export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH" python3 -mpip install wheel - TORCHRL_BUILD_VERSION=0.4.0 python3 setup.py bdist_wheel + TORCHRL_BUILD_VERSION=0.5.0 python3 setup.py bdist_wheel # NB: wheels have the linux_x86_64 tag so we rename to manylinux1 # find . -name 'dist/*whl' -exec bash -c ' mv $0 ${0/linux/manylinux1}' {} \; # pytorch/pytorch binaries are also manylinux_2_17 compliant but they @@ -72,7 +72,7 @@ jobs: shell: bash run: | python3 -mpip install wheel - TORCHRL_BUILD_VERSION=0.4.0 python3 setup.py bdist_wheel + TORCHRL_BUILD_VERSION=0.5.0 python3 setup.py bdist_wheel - name: Upload wheel for the test-wheel job uses: actions/upload-artifact@v2 with: diff --git a/setup.py b/setup.py index 0196cb4a8f4..95dc0802a4f 100644 --- a/setup.py +++ b/setup.py @@ -172,7 +172,7 @@ def _main(argv): if is_nightly: tensordict_dep = "tensordict-nightly" else: - tensordict_dep = "tensordict>=0.4.0" + tensordict_dep = "tensordict>=0.5.0" if is_nightly: version = get_nightly_version() diff --git a/torchrl/collectors/collectors.py b/torchrl/collectors/collectors.py index 50e3dd5cc49..32294a25edd 100644 --- a/torchrl/collectors/collectors.py +++ b/torchrl/collectors/collectors.py @@ -2065,18 +2065,18 @@ def _queue_len(self) -> int: def iterator(self) -> Iterator[TensorDictBase]: cat_results = self.cat_results if cat_results is None: - cat_results = 0 + cat_results = "stack" warnings.warn( f"`cat_results` was not specified in the constructor of {type(self).__name__}. " f"For MultiSyncDataCollector, `cat_results` indicates how the data should " - f"be packed: the preferred option is `cat_results='stack'` which provides " - f"the best interoperability across torchrl components. " + f"be packed: the preferred option and current default is `cat_results='stack'` " + f"which provides the best interoperability across torchrl components. " f"Other accepted values are `cat_results=0` (previous behaviour) and " f"`cat_results=-1` (cat along time dimension). Among these two, the latter " f"should be preferred for consistency across environment configurations. " - f"Currently, the default value is `0` (using torch.cat along first dimension)." - f"From v0.5 onward, this will default to `'stack'`. " - f"To suppress this warning, set stack_results to the desired value.", + f"Currently, the default value is `'stack'`." + f"From v0.6 onward, this warning will be removed. " + f"To suppress this warning, set `cat_results` to the desired value.", category=DeprecationWarning, ) diff --git a/torchrl/envs/common.py b/torchrl/envs/common.py index c965e7dedf3..e30de3534d9 100644 --- a/torchrl/envs/common.py +++ b/torchrl/envs/common.py @@ -15,7 +15,6 @@ import torch import torch.nn as nn from tensordict import LazyStackedTensorDict, TensorDictBase, unravel_key -from tensordict.base import NO_DEFAULT from tensordict.utils import NestedKey from torchrl._utils import ( _ends_with, @@ -3020,21 +3019,11 @@ class _EnvWrapper(EnvBase): def __init__( self, *args, - device: DEVICE_TYPING = NO_DEFAULT, + device: DEVICE_TYPING = None, batch_size: Optional[torch.Size] = None, allow_done_after_reset: bool = False, **kwargs, ): - if device is NO_DEFAULT: - warnings.warn( - "Your wrapper was not given a device. Currently, this " - "value will default to 'cpu'. From v0.5 it will " - "default to `None`. With a device of None, no device casting " - "is performed and the resulting tensordicts are deviceless. " - "Please set your device accordingly.", - category=DeprecationWarning, - ) - device = torch.device("cpu") super().__init__( device=device, batch_size=batch_size, diff --git a/torchrl/envs/transforms/transforms.py b/torchrl/envs/transforms/transforms.py index bec76c603e6..5900326c3ca 100644 --- a/torchrl/envs/transforms/transforms.py +++ b/torchrl/envs/transforms/transforms.py @@ -3411,14 +3411,7 @@ def __init__( out_keys_inv: Sequence[NestedKey] | None = None, ): if in_keys is not None and in_keys_inv is None: - warnings.warn( - "in_keys have been provided but not in_keys_inv. From v0.5, " - "this will result in in_keys_inv being an empty list whereas " - "now the input keys are retrieved automatically. " - "To silence this warning, pass the (possibly empty) " - "list of in_keys_inv.", - category=DeprecationWarning, - ) + in_keys_inv = [] self.dtype_in = dtype_in self.dtype_out = dtype_out diff --git a/torchrl/modules/distributions/continuous.py b/torchrl/modules/distributions/continuous.py index 087cabe4186..38d8d1dfd02 100644 --- a/torchrl/modules/distributions/continuous.py +++ b/torchrl/modules/distributions/continuous.py @@ -481,9 +481,10 @@ def root_dist(self): @property def mode(self): warnings.warn( - "This computation of the mode is based on the first-order Taylor expansion " - "of the transform around the normal mean value, which can be inaccurate. " + "This computation of the mode is based on an inaccurate estimation of the mode " + "given the base_dist mode. " "To use a more stable implementation of the mode, use dist.get_mode() method instead. " + "To silence this warning, consider using the DETERMINISTIC exploration_type." "This implementation will be removed in v0.6.", category=DeprecationWarning, ) diff --git a/torchrl/modules/tensordict_module/actors.py b/torchrl/modules/tensordict_module/actors.py index 17b1ea77ee4..83b6a8d1fb3 100644 --- a/torchrl/modules/tensordict_module/actors.py +++ b/torchrl/modules/tensordict_module/actors.py @@ -4,7 +4,6 @@ # LICENSE file in the root directory of this source tree. from __future__ import annotations -import warnings from typing import Dict, List, Optional, Sequence, Tuple, Union import torch @@ -922,10 +921,9 @@ def __init__( out_keys: Optional[Sequence[NestedKey]] = None, ): if isinstance(action_space, TensorSpec): - warnings.warn( - "Using specs in action_space will be deprecated in v0.4.0," - " please use the 'spec' argument if you want to provide an action spec", - category=DeprecationWarning, + raise RuntimeError( + "Using specs in action_space is deprecated. " + "Please use the 'spec' argument if you want to provide an action spec" ) action_space, _ = _process_action_space_spec(action_space, None) @@ -1136,10 +1134,9 @@ def __init__( action_mask_key: Optional[NestedKey] = None, ): if isinstance(action_space, TensorSpec): - warnings.warn( - "Using specs in action_space will be deprecated v0.4.0," - " please use the 'spec' argument if you want to provide an action spec", - category=DeprecationWarning, + raise RuntimeError( + "Using specs in action_space is deprecated." + "Please use the 'spec' argument if you want to provide an action spec" ) action_space, spec = _process_action_space_spec(action_space, spec) diff --git a/version.txt b/version.txt index 1d0ba9ea182..8f0916f768f 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.4.0 +0.5.0