-
Notifications
You must be signed in to change notification settings - Fork 537
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into change_gauntlet_avging
- Loading branch information
Showing
25 changed files
with
652 additions
and
372 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
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
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
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
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,2 @@ | ||
# Copyright 2022 MosaicML LLM Foundry authors | ||
# SPDX-License-Identifier: Apache-2.0 |
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,39 @@ | ||
# Copyright 2022 MosaicML LLM Foundry authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import gc | ||
|
||
import pytest | ||
import torch | ||
from composer.utils import dist, get_device, reproducibility | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def initialize_dist(request: pytest.FixtureRequest): | ||
"""Initialize the default PyTorch distributed process group for tests.""" | ||
# should we just always initialize dist like in train.py? | ||
_default = pytest.mark.world_size(1).mark | ||
world_size = request.node.get_closest_marker('world_size', _default).args[0] | ||
gpu = request.node.get_closest_marker('gpu') | ||
if world_size > 1: | ||
dist.initialize_dist(get_device('gpu' if gpu is not None else 'cpu')) | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def clear_cuda_cache(request: pytest.FixtureRequest): | ||
"""Clear memory between GPU tests.""" | ||
marker = request.node.get_closest_marker('gpu') | ||
if marker is not None and torch.cuda.is_available(): | ||
torch.cuda.empty_cache() | ||
gc.collect() # Only gc on GPU tests as it 2x slows down CPU tests | ||
|
||
|
||
@pytest.fixture | ||
def random_seed() -> int: | ||
return 17 | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def seed_all(random_seed: int): | ||
"""Sets the seed for reproducibility.""" | ||
reproducibility.seed_all(random_seed) |
Oops, something went wrong.