Skip to content

Commit 8d4768f

Browse files
authored
Remove the Bagua integration (#19445)
1 parent 2ed7282 commit 8d4768f

File tree

6 files changed

+2
-35
lines changed

6 files changed

+2
-35
lines changed

.azure/gpu-tests-pytorch.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108
- bash: |
109109
pip install -q -r .actions/requirements.txt
110110
python .actions/assistant.py requirements_prune_pkgs \
111-
--packages="[lightning-colossalai,lightning-bagua]" \
111+
--packages="[lightning-colossalai]" \
112112
--req_files="[requirements/_integrations/strategies.txt]"
113113
displayName: "Prune packages" # these have installation issues
114114

requirements/_integrations/strategies.txt

-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
# in case you want to preserve/enforce restrictions on the latest compatible version, add "strict" as an in-line comment
33

44
lightning-colossalai >=0.1.0
5-
lightning-bagua >=0.1.0

src/lightning/pytorch/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
3232

3333
### Removed
3434

35-
-
35+
- Removed the Bagua integration (`Trainer(strategy="bagua")`) ([#19445](https://github.com/Lightning-AI/lightning/pull/19445))
3636

3737
-
3838

src/lightning/pytorch/trainer/connectors/accelerator_connector.py

-16
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
from lightning.pytorch.strategies.ddp import _DDP_FORK_ALIASES
6464
from lightning.pytorch.utilities.exceptions import MisconfigurationException
6565
from lightning.pytorch.utilities.imports import (
66-
_LIGHTNING_BAGUA_AVAILABLE,
6766
_LIGHTNING_COLOSSALAI_AVAILABLE,
6867
_graphcore_available_and_importable,
6968
_habana_available_and_importable,
@@ -196,9 +195,6 @@ def _check_config_and_set_final_flags(
196195
if strategy == "colossalai" and not _LIGHTNING_COLOSSALAI_AVAILABLE:
197196
raise ModuleNotFoundError(str(_LIGHTNING_COLOSSALAI_AVAILABLE))
198197

199-
if strategy == "bagua" and not _LIGHTNING_BAGUA_AVAILABLE:
200-
raise ModuleNotFoundError(str(_LIGHTNING_BAGUA_AVAILABLE))
201-
202198
if strategy != "auto" and strategy not in self._registered_strategies and not isinstance(strategy, Strategy):
203199
raise ValueError(
204200
f"You selected an invalid strategy name: `strategy={strategy!r}`."
@@ -421,11 +417,6 @@ def _choose_and_init_cluster_environment(self) -> ClusterEnvironment:
421417
):
422418
if env_type.detect():
423419
return env_type()
424-
if _LIGHTNING_BAGUA_AVAILABLE:
425-
from lightning_bagua import BaguaEnvironment
426-
427-
if BaguaEnvironment.detect():
428-
return BaguaEnvironment()
429420
return LightningEnvironment()
430421

431422
def _choose_strategy(self) -> Union[Strategy, str]:
@@ -690,13 +681,6 @@ def _register_external_accelerators_and_strategies() -> None:
690681
if "colossalai" not in StrategyRegistry:
691682
ColossalAIStrategy.register_strategies(StrategyRegistry)
692683

693-
if _LIGHTNING_BAGUA_AVAILABLE:
694-
from lightning_bagua import BaguaStrategy
695-
696-
# TODO: Prevent registering multiple times
697-
if "bagua" not in StrategyRegistry:
698-
BaguaStrategy.register_strategies(StrategyRegistry)
699-
700684
if _habana_available_and_importable():
701685
from lightning_habana import HPUAccelerator, HPUParallelStrategy, SingleHPUStrategy
702686

src/lightning/pytorch/utilities/imports.py

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
_OMEGACONF_AVAILABLE = package_available("omegaconf")
2929
_TORCHVISION_AVAILABLE = RequirementCache("torchvision")
3030
_LIGHTNING_COLOSSALAI_AVAILABLE = RequirementCache("lightning-colossalai")
31-
_LIGHTNING_BAGUA_AVAILABLE = RequirementCache("lightning-bagua")
3231

3332

3433
@functools.lru_cache(maxsize=128)

tests/tests_pytorch/trainer/connectors/test_accelerator_connector.py

-15
Original file line numberDiff line numberDiff line change
@@ -872,21 +872,6 @@ def test_colossalai_external_strategy(monkeypatch):
872872
assert isinstance(trainer.strategy, ColossalAIStrategy)
873873

874874

875-
@RunIf(min_cuda_gpus=1) # trigger this test on our GPU pipeline, because we don't install the package on the CPU suite
876-
@pytest.mark.xfail(raises=ImportError, reason="Not updated to latest API")
877-
@pytest.mark.skipif(not package_available("lightning_bagua"), reason="Requires Bagua Strategy")
878-
def test_bagua_external_strategy(monkeypatch):
879-
with mock.patch(
880-
"lightning.pytorch.trainer.connectors.accelerator_connector._LIGHTNING_BAGUA_AVAILABLE", False
881-
), pytest.raises(ModuleNotFoundError):
882-
Trainer(strategy="bagua")
883-
884-
from lightning_bagua import BaguaStrategy
885-
886-
trainer = Trainer(strategy="bagua")
887-
assert isinstance(trainer.strategy, BaguaStrategy)
888-
889-
890875
class DeviceMock(Mock):
891876
def __instancecheck__(self, instance):
892877
return True

0 commit comments

Comments
 (0)