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

[Transformer2DModel] Handle norm_type safely while remapping #8370

Merged
merged 5 commits into from
Jun 4, 2024

Conversation

sayakpaul
Copy link
Member

What does this PR do?

See: #7647 (comment)

@sayakpaul sayakpaul requested review from yiyixuxu and DN6 May 31, 2024 10:35
@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.

Comment on lines 88 to 95
else:
input_norm_type = config["norm_type"]
mappings = _CLASS_REMAPPING_DICT.get(previous_class_name)
all_norm_types = list({k for k in mappings if "norm" in k})
logger.info(
f"`{previous_class_name}` couldn't be mapped because `{input_norm_type}` isn't available"
f" in the remappings. Available `norm_type`s: {all_norm_types}"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure we need to do this check if a remapping doesn't exist. Any specific reason why we can't just return the class?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't understand. What class is to be returned in this case?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The original class. Why can this just not be

if remapped_class:
  ...
else:
  return old_class

Copy link
Member Author

Choose a reason for hiding this comment

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

We are doing that only. Additionally, we're providing the user with some information via the warning. Do you think no need?

Copy link
Collaborator

Choose a reason for hiding this comment

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

they don't need a warning here - they get the class they intended to use

sayakpaul and others added 2 commits June 3, 2024 11:56
Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
@sayakpaul
Copy link
Member Author

@yiyixuxu @DN6 done removing the warning when returning the old_class.

@sayakpaul sayakpaul merged commit 6ddbf62 into main Jun 4, 2024
17 checks passed
@sayakpaul sayakpaul deleted the safe-norm-type-handling-transformer branch June 4, 2024 09:39
sayakpaul added a commit that referenced this pull request Jun 4, 2024
* handle norm_type of transformer2d_model safely.

* log an info when old model class is being returned.

* Apply suggestions from code review

Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>

* remove extra stuff

---------

Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
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