Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DataLoader2 seed = 0 bug and clean up unused codes #1098

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions torchdata/dataloader2/dataloader2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import warnings

from dataclasses import dataclass
from typing import Any, Dict, Generic, Iterable, Iterator, Optional, TypeVar, Union

from torchdata.dataloader2.adapter import Adapter
Expand All @@ -22,14 +21,6 @@
READING_SERVICE_STATE_KEY_NAME = "reading_service_state"


@dataclass
class ConcurrencySpec:
num_workers: int
timeout: Optional[int] = None
prefetch_factor: int = 2
persistent_workers: bool = False


class DataLoader2Iterator(Iterator[T_co]):
r"""
An iterator wrapper returned by ``DataLoader2``'s ``__iter__` method. It delegates method/attribute calls
Expand Down Expand Up @@ -200,7 +191,7 @@ def __iter__(self) -> DataLoader2Iterator[T_co]:
raise RuntimeError("Cannot iterate over the DataLoader as it has already been shut down")

if self._reset_iter:
if self._seed:
if self._seed is not None:
if self._reset_seed:
self._seed_generator.seed(self._seed)
self._reset_seed = False
Expand Down
4 changes: 1 addition & 3 deletions torchdata/dataloader2/reading_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ def initialize(self, datapipe: DataPipe) -> DataPipe:
self._end_datapipe = datapipe
return datapipe

graph = traverse_dps(datapipe)

ctx = mp.get_context(self.multiprocessing_context)

# Launch dispatching process for the lowest common ancestor of non-replicable DataPipes
Expand Down Expand Up @@ -359,7 +357,7 @@ def clean_me(process, req_queue, res_queue):
pass

# Clean up dispatching process
if self._dispatch_process:
if self._dispatch_process is not None:
try:
# Send TerminateRequest to all loops to make sure `zip_longest` exits
for req_queue in self._dispatch_process[1]:
Expand Down