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

Replace build() with build_in_name_scope() for some TF tests #28046

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

Rocketknight1
Copy link
Member

@Rocketknight1 Rocketknight1 commented Dec 14, 2023

Should have included this in the TF build() PR but I missed it until now - some of the TF tests should use build_in_name_scope() to ensure layer names aren't changed by that PR!

This fix is just for our tests - users shouldn't be affected by the build() PR unless they're manually calling build() on models and then trying to crossload weights into them.

@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.

Copy link
Collaborator

@amyeroberts amyeroberts 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!

More generally for this case:

This fix is just for our tests - users shouldn't be affected by the build() PR unless they're manually calling build() on models and then trying to crossload weights into them.

Is this something which would fail silently for our users? I'd be surprised if many people were trying to do this, but would be good to at least have an exception thrown somewhere if they do

@Rocketknight1
Copy link
Member Author

@amyeroberts It's hard to say - it would depend exactly on how they were loading the weights. What has changed with this PR is that if you initialize a model via from_config and then explicitly call its build() method, you'll get slightly different weight names for it than you would have before. For every other case (e.g. initialize with from_pretrained() or implicitly call build() via calling the model), there should be no difference.

I think for users to notice an issue they would need to:

  1. Load a model with from_config
  2. Explicitly build it with build()
  3. Have their own weight-loading script that they use to load weights by name into their model after 2)

I think it's pretty unlikely that anyone is doing that, and even if so, they can fix it by using build_in_name_scope() instead.

@Rocketknight1 Rocketknight1 merged commit 3060899 into main Dec 14, 2023
18 checks passed
@Rocketknight1 Rocketknight1 deleted the tf_build_test_fixes branch December 14, 2023 17:42
iantbutler01 pushed a commit to BismuthCloud/transformers that referenced this pull request Dec 16, 2023
…face#28046)

Replace build() with build_in_name_scope() for some tests
staghado pushed a commit to staghado/transformers that referenced this pull request Jan 15, 2024
…face#28046)

Replace build() with build_in_name_scope() for some tests
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.

3 participants