Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
SunMarc committed Dec 11, 2024
1 parent b92fb47 commit 65fec78
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/test_accelerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,15 +766,15 @@ def test_save_model_with_stateful_dataloader(self, use_safetensors, tied_weights

@require_cuda
@require_huggingface_suite
def test_nested_hook(self, use_safetensors):
def test_nested_hook(self):
from transformers.modeling_utils import PretrainedConfig, PreTrainedModel

class MyLinear(torch.nn.Module):
def __init__(self, device=None, dtype=None):
factory_kwargs = {"device": device, "dtype": dtype}
super().__init__()
self.centroid = torch.nn.Embedding(1, 2)
self.indices = torch.nn.parameter(torch.empty((1, 2, 2), **factory_kwargs))
self.indices = torch.nn.Parameter(torch.empty((1, 2, 2), **factory_kwargs))

def forward(self, x):
orig_shape = x.shape
Expand Down Expand Up @@ -821,7 +821,7 @@ def forward(self, x):
offload_folder=offload_folder,
preload_module_classes=["MyLinear"],
)
# before fix, this would raise an error
# weight is on the meta device, we need a `value` to put in on 0
x = torch.randn(1, 2)
my_model(x)
# before fix, this would raise an error
# weight is on the meta device, we need a `value` to put in on 0
x = torch.randn(1, 2)
my_model(x)

0 comments on commit 65fec78

Please sign in to comment.