Skip to content

Commit 18a4544

Browse files
committed
remove it
1 parent 0255319 commit 18a4544

File tree

136 files changed

+53
-3199
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+53
-3199
lines changed

conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"test_gradient_checkpointing_backward_compatibility",
5555
"test_gradient_checkpointing_enable_disable",
5656
"test_torch_save_load",
57-
"test_initialization",
5857
"test_forward_signature",
5958
"test_model_get_set_embeddings",
6059
"test_model_main_input_name",

tests/models/aimv2/test_modeling_aimv2.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
from ...test_modeling_common import (
4040
TEST_EAGER_MATCHES_SDPA_INFERENCE_PARAMETERIZATION,
4141
ModelTesterMixin,
42-
_config_zero_init,
4342
_test_eager_matches_sdpa_inference,
4443
floats_tensor,
4544
ids_tensor,
@@ -427,30 +426,6 @@ def test_model_get_set_embeddings(self):
427426
def test_multi_gpu_data_parallel_forward(self):
428427
pass
429428

430-
# Override as the `logit_scale` parameter initialization is different for Aimv2
431-
def test_initialization(self):
432-
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
433-
434-
configs_no_init = _config_zero_init(config)
435-
for model_class in self.all_model_classes:
436-
model = model_class(config=configs_no_init)
437-
for name, param in model.named_parameters():
438-
if param.requires_grad:
439-
# check if `logit_scale` is initialized as per the original implementation
440-
if name == "logit_scale":
441-
self.assertAlmostEqual(
442-
param.data.item(),
443-
np.log(1 / 0.07),
444-
delta=1e-3,
445-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
446-
)
447-
else:
448-
self.assertIn(
449-
((param.data.mean() * 1e9).round() / 1e9).item(),
450-
[0.0, 1.0],
451-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
452-
)
453-
454429
def test_load_vision_text_config(self):
455430
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
456431

tests/models/align/test_modeling_align.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ def test_batching_equivalence(self, atol=3e-4, rtol=3e-4):
466466

467467
@unittest.skip(reason="Start to fail after using torch `cu118`.")
468468
def test_multi_gpu_data_parallel_forward(self):
469-
super().test_multi_gpu_data_parallel_forward()
469+
pass
470470

471471
@unittest.skip(reason="Hidden_states is tested in individual model tests")
472472
def test_hidden_states_output(self):
@@ -488,35 +488,6 @@ def test_retain_grad_hidden_states_attentions(self):
488488
def test_model_get_set_embeddings(self):
489489
pass
490490

491-
# override as the `temperature` parameter initialization is different for ALIGN
492-
def test_initialization(self):
493-
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
494-
495-
configs_no_init = _config_zero_init(config)
496-
for model_class in self.all_model_classes:
497-
model = model_class(config=configs_no_init)
498-
for name, param in model.named_parameters():
499-
if param.requires_grad:
500-
# check if `temperature` is initialized as per the original implementation
501-
if name == "temperature":
502-
self.assertAlmostEqual(
503-
param.data.item(),
504-
1.0,
505-
delta=1e-3,
506-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
507-
)
508-
elif name == "text_projection.weight":
509-
self.assertTrue(
510-
-1.0 <= ((param.data.mean() * 1e9).round() / 1e9).item() <= 1.0,
511-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
512-
)
513-
else:
514-
self.assertIn(
515-
((param.data.mean() * 1e9).round() / 1e9).item(),
516-
[0.0, 1.0],
517-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
518-
)
519-
520491
def _create_and_check_torchscript(self, config, inputs_dict):
521492
if not self.test_torchscript:
522493
self.skipTest(reason="test_torchscript is set to False")

tests/models/altclip/test_modeling_altclip.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -464,29 +464,6 @@ def test_retain_grad_hidden_states_attentions(self):
464464
def test_model_get_set_embeddings(self):
465465
pass
466466

467-
# override as the `logit_scale` parameter initialization is different for AltCLIP
468-
def test_initialization(self):
469-
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
470-
configs_no_init = _config_zero_init(config)
471-
for model_class in self.all_model_classes:
472-
model = model_class(config=configs_no_init)
473-
for name, param in model.named_parameters():
474-
if param.requires_grad:
475-
# check if `logit_scale` is initialized as per the original implementation
476-
if name == "logit_scale":
477-
self.assertAlmostEqual(
478-
param.data.item(),
479-
np.log(1 / 0.07),
480-
delta=1e-3,
481-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
482-
)
483-
else:
484-
self.assertIn(
485-
((param.data.mean() * 1e9).round() / 1e9).item(),
486-
[0.0, 1.0],
487-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
488-
)
489-
490467
def _create_and_check_torchscript(self, config, inputs_dict):
491468
if not self.test_torchscript:
492469
self.skipTest(reason="test_torchscript is set to False")

tests/models/aria/test_modeling_aria.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,6 @@ def setUp(self):
198198
self.model_tester = AriaVisionText2TextModelTester(self)
199199
self.config_tester = ConfigTester(self, config_class=AriaConfig, has_text_modality=False)
200200

201-
@unittest.skip(reason="Unstable test")
202-
def test_initialization(self):
203-
pass
204-
205201

206202
SKIP = False
207203
torch_accelerator_module = getattr(torch, torch_device)

tests/models/aya_vision/test_modeling_aya_vision.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,6 @@ def test_training_gradient_checkpointing_use_reentrant(self):
197197
def test_training_gradient_checkpointing_use_reentrant_false(self):
198198
pass
199199

200-
@unittest.skip(reason="Siglip uses a non-standard initialization scheme")
201-
def test_initialization(self):
202-
pass
203-
204200
@unittest.skip(reason="Compile not yet supported because in LLava models")
205201
@pytest.mark.torch_compile_test
206202
def test_sdpa_can_compile_dynamic(self):

tests/models/bamba/test_modeling_bamba.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
from ...generation.test_utils import GenerationTesterMixin
4343
from ...test_configuration_common import ConfigTester
44-
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, ids_tensor
44+
from ...test_modeling_common import ModelTesterMixin, ids_tensor
4545
from ...test_pipeline_mixin import PipelineTesterMixin
4646

4747

@@ -335,30 +335,6 @@ def test_decoder_model_past_with_large_inputs(self):
335335
config_and_inputs = self.model_tester.prepare_config_and_inputs()
336336
self.model_tester.create_and_check_decoder_model_past_large_inputs(*config_and_inputs)
337337

338-
def test_initialization(self):
339-
r"""
340-
Overriding the test_initialization test as the A_log and D params of the Bamba mixer are initialized differently
341-
"""
342-
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
343-
344-
configs_no_init = _config_zero_init(config)
345-
for model_class in self.all_model_classes:
346-
model = model_class(config=configs_no_init)
347-
for name, param in model.named_parameters():
348-
if param.requires_grad:
349-
if "A_log" in name:
350-
A = torch.arange(1, config.mamba_n_heads + 1, dtype=torch.float32)
351-
torch.testing.assert_close(param.data, torch.log(A), rtol=1e-5, atol=1e-5)
352-
elif "D" in name:
353-
D = torch.ones(config.mamba_n_heads, dtype=torch.float32)
354-
torch.testing.assert_close(param.data, D, rtol=1e-5, atol=1e-5)
355-
else:
356-
self.assertIn(
357-
((param.data.mean() * 1e9).round() / 1e9).item(),
358-
[0.0, 1.0],
359-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
360-
)
361-
362338
def test_attention_outputs(self):
363339
r"""
364340
Overriding the test_attention_outputs test as the Bamba model outputs attention only for its attention layers

tests/models/beit/test_modeling_beit.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
from ...test_backbone_common import BackboneTesterMixin
3636
from ...test_configuration_common import ConfigTester
37-
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
37+
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
3838
from ...test_pipeline_mixin import PipelineTesterMixin
3939

4040

@@ -382,24 +382,6 @@ def test_training_gradient_checkpointing_use_reentrant(self):
382382
def test_training_gradient_checkpointing_use_reentrant_false(self):
383383
pass
384384

385-
def test_initialization(self):
386-
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
387-
388-
configs_no_init = _config_zero_init(config)
389-
for model_class in self.all_model_classes:
390-
model = model_class(config=configs_no_init)
391-
for name, param in model.named_parameters():
392-
# we skip lambda parameters as these require special initial values
393-
# determined by config.layer_scale_init_value
394-
if "lambda" in name:
395-
continue
396-
if param.requires_grad:
397-
self.assertIn(
398-
((param.data.mean() * 1e9).round() / 1e9).item(),
399-
[0.0, 1.0],
400-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
401-
)
402-
403385
@slow
404386
def test_model_from_pretrained(self):
405387
model_name = "microsoft/beit-base-patch16-224"

tests/models/bit/test_modeling_bit.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
if is_torch_available():
3030
import torch
31-
from torch import nn
3231

3332
from transformers import BitBackbone, BitForImageClassification, BitImageProcessor, BitModel
3433

@@ -200,22 +199,6 @@ def test_backbone(self):
200199
config_and_inputs = self.model_tester.prepare_config_and_inputs()
201200
self.model_tester.create_and_check_backbone(*config_and_inputs)
202201

203-
def test_initialization(self):
204-
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
205-
206-
for model_class in self.all_model_classes:
207-
model = model_class(config=config)
208-
for name, module in model.named_modules():
209-
if isinstance(module, (nn.BatchNorm2d, nn.GroupNorm)):
210-
self.assertTrue(
211-
torch.all(module.weight == 1),
212-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
213-
)
214-
self.assertTrue(
215-
torch.all(module.bias == 0),
216-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
217-
)
218-
219202
def test_hidden_states_output(self):
220203
def check_hidden_states_output(inputs_dict, config, model_class):
221204
model = model_class(config)

tests/models/blip/test_modeling_blip.py

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -456,41 +456,6 @@ def test_retain_grad_hidden_states_attentions(self):
456456
def test_model_get_set_embeddings(self):
457457
pass
458458

459-
# override as the `logit_scale` parameter initialization is different for Blip
460-
def test_initialization(self):
461-
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
462-
463-
configs_no_init = _config_zero_init(config)
464-
for model_class in self.all_model_classes:
465-
model = model_class(config=configs_no_init)
466-
for name, param in model.named_parameters():
467-
if param.requires_grad:
468-
# check if `logit_scale` is initialized as per the original implementation
469-
if name == "logit_scale":
470-
self.assertAlmostEqual(
471-
param.data.item(),
472-
np.log(1 / 0.07),
473-
delta=1e-3,
474-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
475-
)
476-
else:
477-
# See PR #38607 (to avoid flakiness)
478-
data = torch.flatten(param.data)
479-
n_elements = torch.numel(data)
480-
# skip 2.5% of elements on each side to avoid issues caused by `nn.init.trunc_normal_` described in
481-
# https://github.com/huggingface/transformers/pull/27906#issuecomment-1846951332
482-
n_elements_to_skip_on_each_side = int(n_elements * 0.025)
483-
data_to_check = torch.sort(data).values
484-
if n_elements_to_skip_on_each_side > 0:
485-
data_to_check = data_to_check[
486-
n_elements_to_skip_on_each_side:-n_elements_to_skip_on_each_side
487-
]
488-
self.assertIn(
489-
((data_to_check.mean() * 1e9).round() / 1e9).item(),
490-
[0.0, 1.0],
491-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
492-
)
493-
494459
def _create_and_check_torchscript(self, config, inputs_dict):
495460
if not self.test_torchscript:
496461
self.skipTest(reason="test_torchscript is set to False")
@@ -981,30 +946,6 @@ def test_training_gradient_checkpointing_use_reentrant(self):
981946
def test_training_gradient_checkpointing_use_reentrant_false(self):
982947
pass
983948

984-
# override as the `logit_scale` parameter initialization is different for Blip
985-
def test_initialization(self):
986-
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
987-
988-
configs_no_init = _config_zero_init(config)
989-
for model_class in self.all_model_classes:
990-
model = model_class(config=configs_no_init)
991-
for name, param in model.named_parameters():
992-
if param.requires_grad:
993-
# check if `logit_scale` is initialized as per the original implementation
994-
if name == "logit_scale":
995-
self.assertAlmostEqual(
996-
param.data.item(),
997-
np.log(1 / 0.07),
998-
delta=1e-3,
999-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
1000-
)
1001-
else:
1002-
self.assertIn(
1003-
((param.data.mean() * 1e9).round() / 1e9).item(),
1004-
[0.0, 1.0],
1005-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
1006-
)
1007-
1008949
def _create_and_check_torchscript(self, config, inputs_dict):
1009950
if not self.test_torchscript:
1010951
self.skipTest(reason="test_torchscript is set to False")
@@ -1194,30 +1135,6 @@ def test_training_gradient_checkpointing(self):
11941135
loss = model(**inputs).loss
11951136
loss.backward()
11961137

1197-
# override as the `logit_scale` parameter initialization is different for Blip
1198-
def test_initialization(self):
1199-
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
1200-
1201-
configs_no_init = _config_zero_init(config)
1202-
for model_class in self.all_model_classes:
1203-
model = model_class(config=configs_no_init)
1204-
for name, param in model.named_parameters():
1205-
if param.requires_grad:
1206-
# check if `logit_scale` is initialized as per the original implementation
1207-
if name == "logit_scale":
1208-
self.assertAlmostEqual(
1209-
param.data.item(),
1210-
np.log(1 / 0.07),
1211-
delta=1e-3,
1212-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
1213-
)
1214-
else:
1215-
self.assertIn(
1216-
((param.data.mean() * 1e9).round() / 1e9).item(),
1217-
[0.0, 1.0],
1218-
msg=f"Parameter {name} of model {model_class} seems not properly initialized",
1219-
)
1220-
12211138
def _create_and_check_torchscript(self, config, inputs_dict):
12221139
if not self.test_torchscript:
12231140
self.skipTest(reason="test_torchscript is set to False")

0 commit comments

Comments
 (0)