Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tf shared embedding #17730

Merged

Conversation

ArthurZucker
Copy link
Collaborator

@ArthurZucker ArthurZucker commented Jun 16, 2022

What does this PR do?

A hack was used to properly import the shared embedding weights, but it can be removed (removing it also is convenient for the sharding PR)

Found this while testing #17713. In HF's save_pretrained and load_pretrained the layer name is changed using name = "/".join(weight_name.split("/")[1:]). This was breaking for OPT as the layer name was 'decoder.embed_tokens/model.decoder.embed_tokens/weight:0' instead of 'tfopt_model/model/decoder/embed_tokens/weight:0'. The naming is strange and had to use a scope hack. The hack comes from BART

@ArthurZucker ArthurZucker self-assigned this Jun 16, 2022
@ArthurZucker
Copy link
Collaborator Author

All the TF weights of OPT will need to be updated if this is approved. I think I can handle that along with #17713.

@patrickvonplaten patrickvonplaten marked this pull request as ready for review June 16, 2022 12:07
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

@@ -281,14 +281,14 @@ def test_inference_no_head(self):


@require_tf
@slow
# @slow
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will need to be uncommented before merging.

Copy link
Contributor

Choose a reason for hiding this comment

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

Think it's already fixed in the new commit

tests/models/opt/test_modeling_tf_opt.py Show resolved Hide resolved
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jun 16, 2022

The documentation is not available anymore as the PR was closed or merged.

@patrickvonplaten patrickvonplaten merged commit f44e2c2 into huggingface:main Jun 16, 2022
@ArthurZucker ArthurZucker deleted the fix_tf_shared_embedding branch June 16, 2022 12:31
sgugger pushed a commit that referenced this pull request Jun 16, 2022
* fix the naming

* from pt in test for now

* make style

* slow test and removed from_pt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants