Skip to content

Conversation

@ebezzam
Copy link
Contributor

@ebezzam ebezzam commented Nov 25, 2025

What does this PR do?

The tied weights refactoring from #41580 may have introduced an error for the Seamless M4T model? Opening this PR to not lose track.

Perhaps #42362 will address?

Modeling tests before fix (11 errors)

FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelWithSpeechInputTest::test_model_from_pretrained - ValueError: This checkpoint seem corrupted. The tied weights mapping for this model specifies to tie t2u_model.model.decoder.embed_tokens.weight (which should be present and is not), to t2u_mo... 
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelWithTextInputTest::test_model_from_pretrained - ValueError: This checkpoint seem corrupted. The tied weights mapping for this model specifies to tie t2u_model.model.decoder.embed_tokens.weight (which should be present and is not), to t2u_mo... 
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelWithTextInputTest::test_resize_embeddings_untied_with_deepspeed - ImportError: libmpi.so.40: cannot open shared object file: No such file or directory
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelWithTextInputTest::test_resize_tokens_embeddings_with_deepspeed - ImportError: libmpi.so.40: cannot open shared object file: No such file or directory
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelIntegrationTest::test_speech_to_speech_model - ValueError: This checkpoint seem corrupted. The tied weights mapping for this model specifies to tie t2u_model.model.decoder.embed_tokens.weight (which should be present and is not), to t2u_mo... 
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelIntegrationTest::test_speech_to_text_model - ValueError: This checkpoint seem corrupted. The tied weights mapping for this model specifies to tie t2u_model.model.decoder.embed_tokens.weight (which should be present and is not), to t2u_mo... 
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelIntegrationTest::test_text_to_speech_model - ValueError: This checkpoint seem corrupted. The tied weights mapping for this model specifies to tie t2u_model.model.decoder.embed_tokens.weight (which should be present and is not), to t2u_mo... 
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelIntegrationTest::test_text_to_text_model - ValueError: This checkpoint seem corrupted. The tied weights mapping for this model specifies to tie t2u_model.model.decoder.embed_tokens.weight (which should be present and is not), to t2u_mo... 
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelIntegrationTest::test_to_eng_text - ValueError: This checkpoint seem corrupted. The tied weights mapping for this model specifies to tie t2u_model.model.decoder.embed_tokens.weight (which should be present and is not), to t2u_mo... 
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelIntegrationTest::test_to_rus_speech - ValueError: This checkpoint seem corrupted. The tied weights mapping for this model specifies to tie t2u_model.model.decoder.embed_tokens.weight (which should be present and is not), to t2u_mo... 
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelIntegrationTest::test_to_swh_text - ValueError: This checkpoint seem corrupted. The tied weights mapping for this model specifies to tie t2u_model.model.decoder.embed_tokens.weight (which should be present and is not), to t2u_mo... 
========== 11 failed, 79 passed, 193 skipped, 5 warnings in 116.67s (0:01:56) ====

Modeling tests after fix (7 errors)

FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelWithTextInputTest::test_resize_embeddings_untied_with_deepspeed - ImportError: libmpi.so.40: cannot open shared object file: No such file or directory
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelWithTextInputTest::test_resize_tokens_embeddings_with_deepspeed - ImportError: libmpi.so.40: cannot open shared object file: No such file or directory
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelIntegrationTest::test_speech_to_speech_model - AssertionError: 86400 != 86080
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelIntegrationTest::test_text_to_speech_model - AssertionError: 90560 != 86720
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelIntegrationTest::test_to_eng_text - AssertionError: Lists differ: [2, 10051, 8980, 8212, 949, 1270, 4311, 1123, 5918, 2333] != [2, 10051, 9253, 9253, 9253, 9253, 3765, 3765, 3765, 3765]
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelIntegrationTest::test_to_rus_speech - AssertionError: Lists differ: [2, 10067, 5729, 4798, 9631, 8378, 4446, 2393, 6901, 5983] != [2, 10067, 5560, 5560, 5560, 5560, 5560, 5560, 5560, 5560]
FAILED tests/models/seamless_m4t/test_modeling_seamless_m4t.py::SeamlessM4TModelIntegrationTest::test_to_swh_text - AssertionError: Lists differ: [2, 10071, 5729, 9995, 3089, 7546, 1204, 1721, 2532, 4340] != [2, 10071, 2679, 2679, 2679, 2679, 2679, 2679, 9178, 9178]
=============== 7 failed, 89 passed, 187 skipped, 5 warnings in 171.26s (0:02:51) =========

Essentially such errors are resolved:

ValueError: This checkpoint seem corrupted. The tied weights mapping for this model specifies to tie t2u_model.model.decoder.embed_tokens.weight (which should be present and is not), to t2u_model.lm_head.weight (which is present).

But integration tests are failing which is probably better for another PR?

cc: @vasqu, @ArthurZucker

@ebezzam
Copy link
Contributor Author

ebezzam commented Nov 25, 2025

run-slow: seamless_m4t

@github-actions
Copy link
Contributor

This comment contains run-slow, running the specified jobs:

models: ["models/seamless_m4t"]
quantizations: []

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@github-actions
Copy link
Contributor

CI Results

Workflow Run ⚙️

✅ No failing test specific to this PR 🎉 !

@ebezzam
Copy link
Contributor Author

ebezzam commented Nov 25, 2025

Integration tests are actually failing: https://github.com/huggingface/transformers/actions/runs/19661588575/job/56309175315#step:14:21132

but as mentioned above, this is the case before the above mentioned fix

@github-actions
Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: seamless_m4t

@molbap
Copy link
Contributor

molbap commented Nov 25, 2025

Hi! likely linked to #42385 as well

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ty for having a look! this one is a bit bigger would be happy if we have a more general solution

Comment on lines +2009 to +2020
def tie_weights(self, missing_keys: Optional[set[str]] = None, recompute_mapping: bool = True):
"""We need to overload here to handle the wrong key saved in some main checkpoints."""
if self.config.tie_word_embeddings:
# Some model checkpoints like "facebook/hf-seamless-m4t-medium"'s embedding weight is in decoder.embed_tokens,
# need check here
if missing_keys is not None:
if "lm_head.weight" in missing_keys and "model.decoder.embed_tokens.weight" not in missing_keys:
self.lm_head.weight = self.decoder.embed_tokens.weight
missing_keys.discard("lm_head.weight")

# needs to be done after, otherwise it raises an Error because the correct weights are not present
super().tie_weights(missing_keys=missing_keys, recompute_mapping=recompute_mapping)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep this makes sense, tho I think the explicit mapping can work in revers basically. #42362.
It affects more models!

@vasqu vasqu marked this pull request as draft November 26, 2025 13:55
@vasqu
Copy link
Contributor

vasqu commented Nov 26, 2025

Converting to draft for now and essentially closing it when we have the reverse mapping PR landing. Seems like more models are affected so it's not worth to create exceptions everywhere!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants