Revert low cpu mem tie weights (#29135)
* Revert "Add tie_weights() to LM heads and set bias in set_output_embeddings() (#28948)" This reverts commit725f4ad1cc. * Revert "Patch to skip failing `test_save_load_low_cpu_mem_usage` tests (#29043)" This reverts commit4156f517ce.
This commit is contained in:
@@ -305,12 +305,6 @@ class BertGenerationEncoderTest(ModelTesterMixin, GenerationTesterMixin, Pipelin
|
||||
model = BertGenerationEncoder.from_pretrained("google/bert_for_seq_generation_L-24_bbc_encoder")
|
||||
self.assertIsNotNone(model)
|
||||
|
||||
@unittest.skip(
|
||||
"Not currently compatible. Fails with - NotImplementedError: Cannot copy out of meta tensor; no data!"
|
||||
)
|
||||
def test_save_load_low_cpu_mem_usage(self):
|
||||
pass
|
||||
|
||||
|
||||
@require_torch
|
||||
class BertGenerationEncoderIntegrationTest(unittest.TestCase):
|
||||
|
||||
@@ -564,10 +564,6 @@ class DeformableDetrModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineT
|
||||
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
|
||||
)
|
||||
|
||||
@unittest.skip("Cannot be initialized on meta device as some weights are modified during the initialization")
|
||||
def test_save_load_low_cpu_mem_usage(self):
|
||||
pass
|
||||
|
||||
def test_two_stage_training(self):
|
||||
model_class = DeformableDetrForObjectDetection
|
||||
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
|
||||
|
||||
@@ -520,10 +520,6 @@ class DetaModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin
|
||||
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
|
||||
)
|
||||
|
||||
@unittest.skip("Cannot be initialized on meta device as some weights are modified during the initialization")
|
||||
def test_save_load_low_cpu_mem_usage(self):
|
||||
pass
|
||||
|
||||
|
||||
TOLERANCE = 1e-4
|
||||
|
||||
|
||||
@@ -329,12 +329,6 @@ class FSMTModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin
|
||||
def test_resize_embeddings_untied(self):
|
||||
pass
|
||||
|
||||
@unittest.skip(
|
||||
"Not currently compatible. Fails with - NotImplementedError: Cannot copy out of meta tensor; no data!"
|
||||
)
|
||||
def test_save_load_low_cpu_mem_usage(self):
|
||||
pass
|
||||
|
||||
|
||||
@require_torch
|
||||
class FSMTHeadTests(unittest.TestCase):
|
||||
|
||||
@@ -372,12 +372,6 @@ class MarianModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMix
|
||||
def test_training_gradient_checkpointing_use_reentrant_false(self):
|
||||
pass
|
||||
|
||||
@unittest.skip(
|
||||
"Not currently compatible. Fails with - NotImplementedError: Cannot copy out of meta tensor; no data!"
|
||||
)
|
||||
def test_save_load_low_cpu_mem_usage(self):
|
||||
pass
|
||||
|
||||
|
||||
def assert_tensors_close(a, b, atol=1e-12, prefix=""):
|
||||
"""If tensors have different shapes, different values or a and b are not both tensors, raise a nice Assertion error."""
|
||||
|
||||
@@ -1144,10 +1144,6 @@ class MusicgenTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin,
|
||||
|
||||
self.assertNotIn(config.pad_token_id, output_generate)
|
||||
|
||||
@unittest.skip("Fails with - TypeError: _weight_norm_interface() missing 1 required positional argument: 'dim'")
|
||||
def test_save_load_low_cpu_mem_usage(self):
|
||||
pass
|
||||
|
||||
|
||||
def get_bip_bip(bip_duration=0.125, duration=0.5, sample_rate=32000):
|
||||
"""Produces a series of 'bip bip' sounds at a given frequency."""
|
||||
|
||||
@@ -687,12 +687,6 @@ class ReformerLocalAttnModelTest(ReformerTesterMixin, GenerationTesterMixin, Mod
|
||||
def test_left_padding_compatibility(self):
|
||||
pass
|
||||
|
||||
@unittest.skip(
|
||||
"Not currently compatible. Fails with - NotImplementedError: Cannot copy out of meta tensor; no data!"
|
||||
)
|
||||
def test_save_load_low_cpu_mem_usage(self):
|
||||
pass
|
||||
|
||||
|
||||
@require_torch
|
||||
class ReformerLSHAttnModelTest(
|
||||
@@ -854,12 +848,6 @@ class ReformerLSHAttnModelTest(
|
||||
def test_left_padding_compatibility(self):
|
||||
pass
|
||||
|
||||
@unittest.skip(
|
||||
"Not currently compatible. Fails with - NotImplementedError: Cannot copy out of meta tensor; no data!"
|
||||
)
|
||||
def test_save_load_low_cpu_mem_usage(self):
|
||||
pass
|
||||
|
||||
|
||||
@require_torch
|
||||
@require_sentencepiece
|
||||
|
||||
@@ -515,12 +515,6 @@ class XLMRobertaXLModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTes
|
||||
self.assertEqual(position_ids.shape, expected_positions.shape)
|
||||
self.assertTrue(torch.all(torch.eq(position_ids, expected_positions)))
|
||||
|
||||
@unittest.skip(
|
||||
"Not currently compatible. Fails with - NotImplementedError: Cannot copy out of meta tensor; no data!"
|
||||
)
|
||||
def test_save_load_low_cpu_mem_usage(self):
|
||||
pass
|
||||
|
||||
|
||||
@require_torch
|
||||
class XLMRobertaModelXLIntegrationTest(unittest.TestCase):
|
||||
|
||||
@@ -435,23 +435,6 @@ class ModelTesterMixin:
|
||||
max_diff = (model_slow_init.state_dict()[key] - model_fast_init.state_dict()[key]).sum().item()
|
||||
self.assertLessEqual(max_diff, 1e-3, msg=f"{key} not identical")
|
||||
|
||||
def test_save_load_low_cpu_mem_usage(self):
|
||||
with tempfile.TemporaryDirectory() as tmpdirname:
|
||||
for model_class in self.all_model_classes:
|
||||
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
|
||||
model_to_save = model_class(config)
|
||||
|
||||
model_to_save.save_pretrained(tmpdirname)
|
||||
|
||||
model = model_class.from_pretrained(
|
||||
tmpdirname,
|
||||
low_cpu_mem_usage=True,
|
||||
)
|
||||
|
||||
# The low_cpu_mem_usage=True causes the model params to be initialized with device=meta. If there are
|
||||
# any unloaded or untied parameters, then trying to move it to device=torch_device will throw an error.
|
||||
model.to(torch_device)
|
||||
|
||||
def test_fast_init_context_manager(self):
|
||||
# 1. Create a dummy class. Should have buffers as well? To make sure we test __init__
|
||||
class MyClass(PreTrainedModel):
|
||||
|
||||
Reference in New Issue
Block a user