-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from unittest.mock import Mock | ||
|
||
import pytest | ||
|
||
from pytorch_lightning.accelerators import TPUAccelerator | ||
from pytorch_lightning.plugins import SingleTPUPlugin, DDPPlugin, PrecisionPlugin | ||
from pytorch_lightning.plugins.precision import MixedPrecisionPlugin | ||
from pytorch_lightning.utilities.exceptions import MisconfigurationException | ||
|
||
|
||
def test_unsupported_precision_plugins(): | ||
""" Test error messages are raised for unsupported precision plugins with TPU. """ | ||
trainer = Mock() | ||
model = Mock() | ||
accelerator = TPUAccelerator( | ||
training_type_plugin=SingleTPUPlugin(device=Mock()), | ||
precision_plugin=MixedPrecisionPlugin(), | ||
) | ||
with pytest.raises(MisconfigurationException, match=r"amp \+ tpu is not supported."): | ||
accelerator.setup(trainer=trainer, model=model) | ||
|
||
|
||
def test_unsupported_training_type_plugins(): | ||
""" Test error messages are raised for unsupported training type with TPU. """ | ||
trainer = Mock() | ||
model = Mock() | ||
accelerator = TPUAccelerator( | ||
training_type_plugin=DDPPlugin(), | ||
precision_plugin=PrecisionPlugin(), | ||
) | ||
with pytest.raises(MisconfigurationException, match="TPUs only support a single tpu core or tpu spawn training"): | ||
accelerator.setup(trainer=trainer, model=model) |