Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
vmoens committed Jul 3, 2024
1 parent ba6897d commit dcd825c
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/m1_script.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 6 additions & 6 deletions torchrl/collectors/collectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
13 changes: 1 addition & 12 deletions torchrl/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 1 addition & 8 deletions torchrl/envs/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions torchrl/modules/distributions/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
15 changes: 6 additions & 9 deletions torchrl/modules/tensordict_module/actors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.0
0.5.0

0 comments on commit dcd825c

Please sign in to comment.