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

Use class to organize distributed tests in modules #3069

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions ignite/engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _prepare_batch(
def supervised_training_step(
model: torch.nn.Module,
optimizer: torch.optim.Optimizer,
loss_fn: Union[Callable, torch.nn.Module],
loss_fn: Union[Callable[[Any, Any], torch.Tensor], torch.nn.Module],
device: Optional[Union[str, torch.device]] = None,
non_blocking: bool = False,
prepare_batch: Callable = _prepare_batch,
Expand All @@ -57,7 +57,7 @@ def supervised_training_step(
Args:
model: the model to train.
optimizer: the optimizer to use.
loss_fn: the loss function to use.
loss_fn: the loss function that receives `y_pred` and `y`, and returns the loss as a tensor.
device: device type specification (default: None).
Applies to batches after starting the engine. Model *will not* be moved.
Device can be CPU, GPU.
Expand Down Expand Up @@ -120,7 +120,7 @@ def update(engine: Engine, batch: Sequence[torch.Tensor]) -> Union[Any, Tuple[to
def supervised_training_step_amp(
model: torch.nn.Module,
optimizer: torch.optim.Optimizer,
loss_fn: Union[Callable, torch.nn.Module],
loss_fn: Union[Callable[[Any, Any], torch.Tensor], torch.nn.Module],
device: Optional[Union[str, torch.device]] = None,
non_blocking: bool = False,
prepare_batch: Callable = _prepare_batch,
Expand All @@ -134,7 +134,7 @@ def supervised_training_step_amp(
Args:
model: the model to train.
optimizer: the optimizer to use.
loss_fn: the loss function to use.
loss_fn: the loss function that receives `y_pred` and `y`, and returns the loss as a tensor.
device: device type specification (default: None).
Applies to batches after starting the engine. Model *will not* be moved.
Device can be CPU, GPU.
Expand Down Expand Up @@ -212,7 +212,7 @@ def update(engine: Engine, batch: Sequence[torch.Tensor]) -> Union[Any, Tuple[to
def supervised_training_step_apex(
model: torch.nn.Module,
optimizer: torch.optim.Optimizer,
loss_fn: Union[Callable, torch.nn.Module],
loss_fn: Union[Callable[[Any, Any], torch.Tensor], torch.nn.Module],
device: Optional[Union[str, torch.device]] = None,
non_blocking: bool = False,
prepare_batch: Callable = _prepare_batch,
Expand All @@ -225,7 +225,7 @@ def supervised_training_step_apex(
Args:
model: the model to train.
optimizer: the optimizer to use.
loss_fn: the loss function to use.
loss_fn: the loss function that receives `y_pred` and `y`, and returns the loss as a tensor.
device: device type specification (default: None).
Applies to batches after starting the engine. Model *will not* be moved.
Device can be CPU, GPU.
Expand Down Expand Up @@ -295,7 +295,7 @@ def update(engine: Engine, batch: Sequence[torch.Tensor]) -> Union[Any, Tuple[to
def supervised_training_step_tpu(
model: torch.nn.Module,
optimizer: torch.optim.Optimizer,
loss_fn: Union[Callable, torch.nn.Module],
loss_fn: Union[Callable[[Any, Any], torch.Tensor], torch.nn.Module],
device: Optional[Union[str, torch.device]] = None,
non_blocking: bool = False,
prepare_batch: Callable = _prepare_batch,
Expand All @@ -308,7 +308,7 @@ def supervised_training_step_tpu(
Args:
model: the model to train.
optimizer: the optimizer to use.
loss_fn: the loss function to use.
loss_fn: the loss function that receives `y_pred` and `y`, and returns the loss as a tensor.
device: device type specification (default: None).
Applies to batches after starting the engine. Model *will not* be moved.
Device can be CPU, TPU.
Expand Down Expand Up @@ -404,7 +404,7 @@ def _check_arg(
def create_supervised_trainer(
model: torch.nn.Module,
optimizer: torch.optim.Optimizer,
loss_fn: Union[Callable, torch.nn.Module],
loss_fn: Union[Callable[[Any, Any], torch.Tensor], torch.nn.Module],
device: Optional[Union[str, torch.device]] = None,
non_blocking: bool = False,
prepare_batch: Callable = _prepare_batch,
Expand All @@ -420,7 +420,7 @@ def create_supervised_trainer(
Args:
model: the model to train.
optimizer: the optimizer to use.
loss_fn: the loss function to use.
loss_fn: the loss function that receives `y_pred` and `y`, and returns the loss as a tensor.
device: device type specification (default: None).
Applies to batches after starting the engine. Model *will not* be moved.
Device can be CPU, GPU or TPU.
Expand Down
1 change: 1 addition & 0 deletions tests/ignite/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ def gloo_hvd_executor():
],
),
],
scope="class",
)
def distributed(request, local_rank, world_size):
if request.param in ("nccl", "gloo_cpu", "gloo"):
Expand Down