Skip to content

Commit bbb86c8

Browse files
antoinebrlVincent Moens
authored and
Vincent Moens
committed
[BE] Fix some typos (#2811)
(cherry picked from commit 0ae1405)
1 parent 5ea59de commit bbb86c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+156
-154
lines changed

docs/source/reference/collectors.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ will work:
155155
>>> collector = SyncDataCollector(env, policy, frames_per_batch=N, total_frames=-1)
156156
>>> for data in collector:
157157
... memory.extend(data)
158-
>>> # MultiSyncDataCollector + regular env: behaves like a ParallelEnv iif cat_results="stack"
158+
>>> # MultiSyncDataCollector + regular env: behaves like a ParallelEnv if cat_results="stack"
159159
>>> memory = ReplayBuffer(
160160
... storage=LazyTensorStorage(N, ndim=2),
161161
... sampler=SliceSampler(num_slices=4, trajectory_key=("collector", "traj_ids"))

docs/source/reference/data.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ It is important that your environment specs match the input and output that it s
930930
:class:`~torchrl.envs.ParallelEnv` will create buffers from these specs to communicate with the spawn processes.
931931
Check the :func:`torchrl.envs.utils.check_env_specs` method for a sanity check.
932932

933-
If needed, specs can be automatially generated from data using the :func:`~torchrl.envs.utils.make_composite_from_td`
933+
If needed, specs can be automatically generated from data using the :func:`~torchrl.envs.utils.make_composite_from_td`
934934
function.
935935

936936
Specs fall in two main categories, numerical and categorical.
@@ -1073,7 +1073,7 @@ Then, a second storage keeps track of the actions and results associated with th
10731073
>>> next_data = forest.data_map[index]
10741074

10751075
The ``next_data`` entry can have any shape, but it will usually match the shape of ``index`` (since at each index
1076-
corresponds one action). Once ``next_data`` is obtrained, it can be put together with ``data`` to form a set of nodes,
1076+
corresponds one action). Once ``next_data`` is obtained, it can be put together with ``data`` to form a set of nodes,
10771077
and the tree can be expanded for each of these. The following figure shows how this is done.
10781078

10791079
.. figure:: /_static/img/collector-copy.png

docs/source/reference/envs.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ The ``"_reset"`` key has two distinct functionalities:
226226
Designing an environment that behaves according to ``"_reset"`` inputs is the
227227
developer's responsibility, as TorchRL has no control over the inner logic
228228
of :meth:`~.EnvBase._reset`. Nevertheless, the following point should be
229-
kept in mind when desiging that method.
229+
kept in mind when designing that method.
230230

231231
2. After a call to :meth:`~.EnvBase._reset`, the output will be masked with the
232232
``"_reset"`` entries and the output of the previous :meth:`~.EnvBase.step`
@@ -254,7 +254,7 @@ designing reset functionalities:
254254
whether the ``"_reset"`` at the root level corresponds to an ``all()``, ``any()``
255255
or custom call to the nested ``"done"`` entries cannot be known in advance,
256256
and it is explicitly assumed that the ``"_reset"`` at the root was placed
257-
there to superseed the nested values (for an example, have a look at
257+
there to supersede the nested values (for an example, have a look at
258258
:class:`~.PettingZooWrapper` implementation where each group has one or more
259259
``"done"`` entries associated which is aggregated at the root level with a
260260
``any`` or ``all`` logic depending on the task).
@@ -978,7 +978,7 @@ to always know what the latest available actions are. You can do this like so:
978978
>>> )
979979
980980
.. note::
981-
In case you are using a parallel environment it is important to add the transform to the parallel enviornment itself
981+
In case you are using a parallel environment it is important to add the transform to the parallel environment itself
982982
and not to its sub-environments.
983983

984984

docs/source/reference/trainers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The trainer package provides utilities to write re-usable training scripts. The
99
trainer that implements a nested loop, where the outer loop runs the data collection steps and the inner
1010
loop the optimization steps. We believe this fits multiple RL training schemes, such as
1111
on-policy, off-policy, model-based and model-free solutions, offline RL and others.
12-
More particular cases, such as meta-RL algorithms may have training schemes that differ substentially.
12+
More particular cases, such as meta-RL algorithms may have training schemes that differ substantially.
1313

1414
The ``trainer.train()`` method can be sketched as follows:
1515

examples/distributed/replay_buffers/distributed_replay_buffer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
===========================
44
55
This example illustrates how a skeleton reinforcement learning algorithm can be implemented in a distributed fashion with communication between nodes/workers handled using `torch.rpc`.
6-
It focusses on how to set up a replay buffer worker that accepts remote operation requests efficiently, and so omits any learning component such as parameter updates that may be required for a complete distributed reinforcement learning algorithm implementation.
6+
It focuses on how to set up a replay buffer worker that accepts remote operation requests efficiently, and so omits any learning component such as parameter updates that may be required for a complete distributed reinforcement learning algorithm implementation.
77
In this model, >= 1 data collectors workers are responsible for collecting experiences in an environment, the replay buffer worker receives all of these experiences and exposes them to a trainer that is responsible for making parameter updates to any required models.
88
"""
99

@@ -150,7 +150,7 @@ def _create_and_launch_data_collectors(self) -> None:
150150

151151
class ReplayBufferNode(RemoteTensorDictReplayBuffer):
152152
"""Experience replay buffer node that is capable of accepting remote connections. Being a `RemoteTensorDictReplayBuffer`
153-
means all of its public methods are remotely invokable using `torch.rpc`.
153+
means all of its public methods are remotely invocable using `torch.rpc`.
154154
Using a LazyMemmapStorage is highly advised in distributed settings with shared storage due to the lower serialization
155155
cost of MemoryMappedTensors as well as the ability to specify file storage locations which can improve ability to recover from node failures.
156156

knowledge_base/MUJOCO_INSTALLATION.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ issues when running `import mujoco_py` and some troubleshooting for each of them
189189
/path/to/conda/envs/mj_envs/lib/python3.8/site-packages/glfw/__init__.py:912: GLFWError: (65537) b'The GLFW library is not initialized'
190190
```
191191
192-
_Solution_: This can usually be sovled by setting EGL as your mujoco_gl backend: `MUJOCO_GL=egl python myscript.py`
192+
_Solution_: This can usually be solved by setting EGL as your mujoco_gl backend: `MUJOCO_GL=egl python myscript.py`
193193
194194
195195
@@ -208,7 +208,7 @@ RuntimeError: Failed to initialize OpenGL
208208
> Mujoco's EGL code indexes devices globally while CUDA_VISIBLE_DEVICES
209209
(when used with job schedulers like slurm) returns the local device ids.
210210
This can be worked around by setting the `GPUS` environment variable to the
211-
global device id. For slurm, it can be obtained using `SLURM_STEP_GPUS` enviroment variable.
211+
global device id. For slurm, it can be obtained using `SLURM_STEP_GPUS` environment variable.
212212
213213
8. Rendered images are completely black.
214214

knowledge_base/PRO-TIPS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Errors to look for that may be related to this misconception are the following:
7676
than the number of environments you're working with (twice as much for instance). This
7777
is also and especially true for environments that are rendered (even if they are rendered on GPU).
7878
- The speed of training depends upon several factors and there is not a one-fits-all
79-
solution to every problem. The common bottlnecks are:
79+
solution to every problem. The common bottlenecks are:
8080
- **data collection**: the simulator speed may affect performance, as can the data
8181
transformation that follows. Speeding up environment interactions is usually
8282
done via vectorization (if the simulators enables it, e.g. Brax and other Jax-based
@@ -93,7 +93,7 @@ Errors to look for that may be related to this misconception are the following:
9393
a computational bottleneck as these are usually coded using plain for loops.
9494
If profiling indicates that this operation is taking a considerable amount
9595
of time, consider using our fully vectorized solutions instead.
96-
- **Loss compuation**: The loss computation and the optimization
96+
- **Loss computation**: The loss computation and the optimization
9797
steps are frequently responsible of a significant share of the compute time.
9898
Some techniques can speed things up. For instance, if multiple target networks
9999
are being used, using vectorized maps and functional programming (through

knowledge_base/VERSIONING_ISSUES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ImportError: /usr/local/lib/python3.7/dist-packages/torchrl/_torchrl.so: undefin
77
```
88

99
### How to reproduce
10-
1. Create an Colab Notebook (at 24/11/2022 Colab enviroment has Python 3.7 and Pytorch 1.12 installed by default).
10+
1. Create an Colab Notebook (at 24/11/2022 Colab environment has Python 3.7 and Pytorch 1.12 installed by default).
1111
2. ``` !pip install torchrl ```
1212
3. ``` import torchrl ```
1313

@@ -20,4 +20,4 @@ before the ```!pip install torchrl``` command. This will install the latest pyto
2020
### Workarounds
2121
There are two workarounds to this issue
2222
1. Install/upgrade to the latest pytorch release before installing torchrl.
23-
2. If you need to use a previous pytorch relase: Install functorch version related to your torch distribution: e.g. ``` pip install functorch==0.2.0 ``` and install library from source ``` pip install git+https://github.com/pytorch/rl@<lib_version_here> ```.
23+
2. If you need to use a previous pytorch release: Install functorch version related to your torch distribution: e.g. ``` pip install functorch==0.2.0 ``` and install library from source ``` pip install git+https://github.com/pytorch/rl@<lib_version_here> ```.

sota-implementations/decision_transformer/lamb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def step(self, closure=None):
8585
grad = p.grad
8686
if grad.is_sparse:
8787
raise RuntimeError(
88-
"Lamb does not support sparse gradients, consider SparseAdam instad."
88+
"Lamb does not support sparse gradients, consider SparseAdam instead."
8989
)
9090
global_grad_norm.add_(grad.pow(2).sum())
9191

sota-implementations/redq/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
def correct_for_frame_skip(cfg: "DictConfig") -> "DictConfig": # noqa: F821
109109
"""Correct the arguments for the input frame_skip, by dividing all the arguments that reflect a count of frames by the frame_skip.
110110
111-
This is aimed at avoiding unknowingly over-sampling from the environment, i.e. targetting a total number of frames
111+
This is aimed at avoiding unknowingly over-sampling from the environment, i.e. targeting a total number of frames
112112
of 1M but actually collecting frame_skip * 1M frames.
113113
114114
Args:
@@ -578,7 +578,7 @@ def transformed_env_constructor(
578578
stats (dict, optional): a dictionary containing the :obj:`loc` and :obj:`scale` for the `ObservationNorm` transform
579579
norm_obs_only (bool, optional): If `True` and `VecNorm` is used, the reward won't be normalized online.
580580
Default is `False`.
581-
use_env_creator (bool, optional): wheter the `EnvCreator` class should be used. By using `EnvCreator`,
581+
use_env_creator (bool, optional): whether the `EnvCreator` class should be used. By using `EnvCreator`,
582582
one can make sure that running statistics will be put in shared memory and accessible for all workers
583583
when using a `VecNorm` transform. Default is `True`.
584584
custom_env_maker (callable, optional): if your env maker is not part
@@ -644,7 +644,7 @@ def make_transformed_env(**kwargs) -> TransformedEnv:
644644
elif custom_env_maker is None and custom_env is not None:
645645
env = custom_env
646646
else:
647-
raise RuntimeError("cannot provive both custom_env and custom_env_maker")
647+
raise RuntimeError("cannot provide both custom_env and custom_env_maker")
648648

649649
if cfg.env.noops and custom_env is None:
650650
# this is a bit hacky: if custom_env is not None, it is probably a ParallelEnv
@@ -699,7 +699,7 @@ def initialize_observation_norm_transforms(
699699
700700
Args:
701701
proof_environment (EnvBase instance, optional): if provided, this env will
702-
be used ot execute the rollouts. If not, it will be created using
702+
be used to execute the rollouts. If not, it will be created using
703703
the cfg object.
704704
num_iter (int): Number of iterations used for initializing the :obj:`ObservationNorms`
705705
key (str, optional): if provided, the stats of this key will be gathered.

test/_utils_internal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ class LSTMNet(nn.Module):
592592
TensorDict of size [batch x time_steps].
593593
594594
If a 2D tensor is provided as input, it is assumed that it is a batch of data
595-
with only one time step. This means that we explicitely assume that users will
595+
with only one time step. This means that we explicitly assume that users will
596596
unsqueeze inputs of a single batch with multiple time steps.
597597
598598
Args:

test/mocking_classes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -882,15 +882,15 @@ def _get_in_obs(self, tensordict):
882882

883883

884884
class DummyModelBasedEnvBase(ModelBasedEnvBase):
885-
"""Dummy environnement for Model Based RL sota-implementations.
885+
"""Dummy environment for Model Based RL sota-implementations.
886886
887-
This class is meant to be used to test the model based environnement.
887+
This class is meant to be used to test the model based environment.
888888
889889
Args:
890-
world_model (WorldModel): the world model to use for the environnement.
891-
device (str or torch.device, optional): the device to use for the environnement.
892-
dtype (torch.dtype, optional): the dtype to use for the environnement.
893-
batch_size (sequence of int, optional): the batch size to use for the environnement.
890+
world_model (WorldModel): the world model to use for the environment.
891+
device (str or torch.device, optional): the device to use for the environment.
892+
dtype (torch.dtype, optional): the dtype to use for the environment.
893+
batch_size (sequence of int, optional): the batch size to use for the environment.
894894
"""
895895

896896
def __init__(

test/test_collector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ def test_env_that_errors(self, ctype):
862862
"collector_cls", ["MultiSyncDataCollector", "MultiaSyncDataCollector"]
863863
)
864864
def test_env_that_waits(self, to, collector_cls):
865-
# Tests that the collector fails if the MAX_IDLE_COUNT<waiting time, but succeeeds otherwise
865+
# Tests that the collector fails if the MAX_IDLE_COUNT<waiting time, but succeeds otherwise
866866
# We run this in a subprocess to control the env variable.
867867
script = f"""import os
868868

test/test_env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ def test_parallel_env(
13001300
td_reset = TensorDict(source=rand_reset(env_parallel), batch_size=[N])
13011301
env_parallel.reset(tensordict=td_reset)
13021302

1303-
# check that interruption occured because of max_steps or done
1303+
# check that interruption occurred because of max_steps or done
13041304
td = env_parallel.rollout(policy=None, max_steps=T)
13051305
assert (
13061306
td.shape == torch.Size([N, T]) or td.get(("next", "done")).sum(1).any()

test/test_loggers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,14 @@ def test_log_video(self, steps, video_format, tmpdir):
187187
sleep(0.01) # wait until events are registered
188188

189189
# check that the logged videos are the same as the initial video
190-
extention = (
190+
extension = (
191191
".pt"
192192
if video_format == "pt"
193193
else ".memmap"
194194
if video_format == "memmap"
195195
else ".mp4"
196196
)
197-
video_file_name = "foo_" + ("0" if not steps else str(steps[0])) + extention
197+
video_file_name = "foo_" + ("0" if not steps else str(steps[0])) + extension
198198
path = os.path.join(tmpdir, exp_name, "videos", video_file_name)
199199
if video_format == "pt":
200200
logged_video = torch.load(path)

test/test_rb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2871,7 +2871,7 @@ def test_slice_sampler_prioritized(self, ndim, strict_length, circ, at_capacity)
28712871
assert (samples["traj"] != 0).all(), samples["traj"].unique()
28722872
else:
28732873
assert (samples["traj"] == 0).any()
2874-
# Check that all samples of the first traj contain all elements (since it's too short to fullfill 10 elts)
2874+
# Check that all samples of the first traj contain all elements (since it's too short to fulfill 10 elts)
28752875
sc = samples[samples["traj"] == 0]["step_count"]
28762876
assert (sc == 1).sum() == (sc == 2).sum()
28772877
assert (sc == 1).sum() == (sc == 4).sum()
@@ -3393,7 +3393,7 @@ def test_rb(
33933393
error_catcher = (
33943394
pytest.raises(
33953395
ValueError,
3396-
match="Samplers with drop_last=True must work with a predictible batch-size",
3396+
match="Samplers with drop_last=True must work with a predictable batch-size",
33973397
)
33983398
if batch_size is None
33993399
and issubclass(sampler_type, SamplerWithoutReplacement)

test/test_storage_map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,15 @@ def __call__(self):
274274
gen_id = IDGen()
275275
gen_hash = lambda: hash(torch.rand(1).item())
276276

277-
def dummy_node_stack(obervations):
277+
def dummy_node_stack(observations):
278278
return TensorDict.lazy_stack(
279279
[
280280
Tree(
281281
node_data=TensorDict({"obs": torch.tensor(obs)}),
282282
hash=gen_hash(),
283283
node_id=gen_id(),
284284
)
285-
for obs in obervations
285+
for obs in observations
286286
]
287287
)
288288

test/test_transforms.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,9 @@ def test_transform_env(self, device):
526526
low=torch.randn(2),
527527
high=None,
528528
)
529-
with pytest.raises(ValueError, match="`low` must be stricly lower than `high`"):
529+
with pytest.raises(
530+
ValueError, match="`low` must be strictly lower than `high`"
531+
):
530532
ClipTransform(
531533
in_keys=["observation", "reward"],
532534
in_keys_inv=["observation_orig"],

torchrl/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def get_func_name(cls, fn):
375375
elif fn_str[0].startswith("<function "):
376376
first = fn_str[0][len("<function ") :]
377377
else:
378-
raise RuntimeError(f"Unkown func representation {fn}")
378+
raise RuntimeError(f"Unknown func representation {fn}")
379379
last = fn_str[1:]
380380
if last:
381381
first = [first]

torchrl/collectors/collectors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ def __init__(
663663
self.closed = False
664664

665665
if not reset_when_done:
666-
raise ValueError("reset_when_done is deprectated.")
666+
raise ValueError("reset_when_done is deprecated.")
667667
self.reset_when_done = reset_when_done
668668
self.n_env = self.env.batch_size.numel()
669669

@@ -2541,7 +2541,7 @@ class MultiaSyncDataCollector(_MultiDataCollector):
25412541
25422542
Environment types can be identical or different.
25432543
2544-
The collection keeps on occuring on all processes even between the time
2544+
The collection keeps on occurring on all processes even between the time
25452545
the batch of rollouts is collected and the next call to the iterator.
25462546
This class can be safely used with offline RL sota-implementations.
25472547
@@ -3130,7 +3130,7 @@ def _main_async_collector(
31303130
"the shared device (aka storing_device) is set to CPU."
31313131
)
31323132
if collected_tensordict.device is not None:
3133-
# placehoder in case we need different behaviors
3133+
# placeholder in case we need different behaviors
31343134
if collected_tensordict.device.type in ("cpu",):
31353135
collected_tensordict.share_memory_()
31363136
elif collected_tensordict.device.type in ("mps",):

torchrl/collectors/distributed/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def __init__(
463463
self.max_weight_update_interval = max_weight_update_interval
464464
if self.update_after_each_batch and self.max_weight_update_interval > -1:
465465
raise RuntimeError(
466-
"Got conflicting udpate instructions: `update_after_each_batch` "
466+
"Got conflicting update instructions: `update_after_each_batch` "
467467
"`max_weight_update_interval` are incompatible."
468468
)
469469
self.launcher = launcher

0 commit comments

Comments
 (0)