You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If necessary, you can also access data in Azure Data Lake Storage Gen1 by using URIs staring with
437
+
If necessary, you can also access data in Azure Data Lake Storage Gen1 by using URIs staring with
438
438
``adl://`` and ``abfs://``, as described in `README of adlfs repo <https://github.com/fsspec/adlfs/blob/main/README.md>`_
439
439
440
440
Accessing Azure ML Datastores with ``fsspec`` DataPipes
@@ -446,11 +446,11 @@ An Azure ML datastore is a *reference* to an existing storage account on Azure.
446
446
- Authentication is automatically handled - both *credential-based* access (service principal/SAS/key) and *identity-based* access (Azure Active Directory/managed identity) are supported. When using credential-based authentication, you do not need to expose secrets in your code.
447
447
448
448
This requires the installation of the library ``azureml-fsspec``
StatefulDataLoader is a drop-in replacement for `torch.utils.data.DataLoader <https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader>`_ which offers ``state_dict`` / ``load_state_dict`` methods for handling mid-epoch checkpointing which operate on the previous/next iterator requested from the dataloader (resp.).
9
+
10
+
By default, the state includes the number of batches yielded and uses this to naively fast-forward the sampler (map-style) or the dataset (iterable-style). However if the sampler and/or dataset include ``state_dict`` / ``load_state_dict`` methods, then it will call them during its own ``state_dict`` / ``load_state_dict`` calls. Under the hood, :class:`StatefulDataLoader` handles aggregation and distribution of state across multiprocess workers (but not across ranks).
Copy file name to clipboardExpand all lines: torchdata/stateful_dataloader/stateful_dataloader.py
+10-9Lines changed: 10 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -92,13 +92,12 @@
92
92
93
93
classStatefulDataLoader(DataLoader[_T_co]):
94
94
r"""
95
-
This is a drop in replacement for :class:`~torch.utils.data.DataLoader`
95
+
This is a drop in replacement for ``torch.utils.data.DataLoader``
96
96
that implements state_dict and load_state_dict methods, enabling mid-epoch
97
97
checkpointing.
98
98
99
-
All arguments are identical to :class:`~torch.utils.data.DataLoader`, with
100
-
a new kwarg: `snapshot_every_n_steps: Optional[int] = `.
101
-
See :py:mod:`torch.utils.data` documentation page for more details.
99
+
All arguments are identical to ``torch.utils.data.DataLoader``, with
100
+
a new kwarg: ``snapshot_every_n_steps``.
102
101
103
102
Args:
104
103
dataset (Dataset): dataset from which to load the data.
@@ -148,11 +147,13 @@ class StatefulDataLoader(DataLoader[_T_co]):
148
147
maintain the workers `Dataset` instances alive. (default: ``False``)
149
148
pin_memory_device (str, optional): the device to :attr:`pin_memory` to if ``pin_memory`` is
150
149
``True``.
150
+
snapshot_every_n_steps (int, optional): Defines how often the state is
151
+
transferred from the dataloader workers to the dataloader. By default, it is set to ``1``, i.e., state is transferred every step. If the state is large, this value can be increased (and ideally set to the frequency of training checkpointing) to reduce the overhead of transferring state every step.
151
152
152
153
153
154
.. warning:: If the ``spawn`` start method is used, :attr:`worker_init_fn`
154
155
cannot be an unpicklable object, e.g., a lambda function. See
155
-
:ref:`multiprocessing-best-practices` on more details related
156
+
`multiprocessing-best-practices <https://pytorch.org/docs/stable/notes/multiprocessing.html#multiprocessing-best-practices>`_ on more details related
156
157
to multiprocessing in PyTorch.
157
158
158
159
.. warning:: ``len(dataloader)`` heuristic is based on the length of the sampler used.
@@ -169,12 +170,12 @@ class StatefulDataLoader(DataLoader[_T_co]):
169
170
dropped when :attr:`drop_last` is set. Unfortunately, PyTorch can not detect such
170
171
cases in general.
171
172
172
-
See `Dataset Types`_ for more details on these two types of datasets and how
173
+
See `Dataset Types <https://pytorch.org/docs/stable/data.html>`_ for more details on these two types of datasets and how
173
174
:class:`~torch.utils.data.IterableDataset` interacts with
174
-
`Multi-process data loading`_.
175
+
`Multi-process data loading <https://pytorch.org/docs/stable/data.html#multi-process-data-loading>`_.
175
176
176
-
.. warning:: See :ref:`reproducibility`, and :ref:`dataloader-workers-random-seed`, and
177
-
:ref:`data-loading-randomness` notes for random seed related questions.
177
+
.. warning:: See `Reproducibility <https://pytorch.org/docs/stable/notes/randomness.html#reproducibility>`_, and `Dataloader-workers-random-seed <https://pytorch.org/docs/stable/notes/faq.html#dataloader-workers-random-seed>`_, and
178
+
`Data-loading-randomness <https://pytorch.org/docs/stable/data.html#data-loading-randomness>`_ notes for random seed related questions.
0 commit comments