Skip to content
Closed
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
10 changes: 8 additions & 2 deletions tests/test_utils/test_activation_checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import torch.nn.functional as F
from colossalai.context.parallel_mode import ParallelMode
from colossalai.context.random import add_seed, seed, set_mode, reset_seeds
from colossalai.utils import checkpoint
from colossalai.utils.activation_checkpoint import checkpoint


def forward(x, weight):
Expand All @@ -17,9 +17,10 @@ def forward(x, weight):


@pytest.mark.gpu
@pytest.mark.skip("set seed error")
@pytest.mark.parametrize("cpu_offload", [True, False])
def test_activation_checkpointing(cpu_offload):
# clear all previous seeds possibly set by other tests
reset_seeds()

# We put initilization here to avoid change cuda rng state below
inputs = torch.rand(2, 2, requires_grad=True, device='cuda')
Expand Down Expand Up @@ -62,3 +63,8 @@ def test_activation_checkpointing(cpu_offload):
# other tests will fail if running together with this test
# as other tests can't overwrite the seed set by this test
reset_seeds()


if __name__ == '__main__':
test_activation_checkpointing(cpu_offload=False)
test_activation_checkpointing(cpu_offload=True)