KEMBAR78
Moved functions to pytorch_utils.py by anmolsjoshi · Pull Request #16625 · huggingface/transformers · GitHub
Skip to content

Conversation

@anmolsjoshi
Copy link
Contributor

@anmolsjoshi anmolsjoshi commented Apr 6, 2022

What does this PR do?

Moved all pruning stuff, apply_chunking_to_forward to pytorch_utils.py

Fixes #15543

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@patrickvonplaten @sgugger

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 6, 2022

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

@anmolsjoshi
Copy link
Contributor Author

@patrickvonplaten I'm new to contributing to this repo. What other updates are required?

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 tackling this! There are a few imports that seem wrong in some of the modeling files, could you fix them?

return input


def find_pruneable_heads_and_indices(
Copy link
Collaborator

Choose a reason for hiding this comment

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

For backward compatibility, these functions should still be imported in this module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sgugger does that mean a copy of the functions should remain in modeling_utils.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or as described here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, just from .pytorch_utils import find_pruneable_heads_and_indices (and same for the others)

Copy link
Contributor Author

@anmolsjoshi anmolsjoshi Apr 6, 2022

Choose a reason for hiding this comment

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

@sgugger Thank you - trying my best to learn!

I incorporated your comment. Won't resolve this conversation until you have confirmed that I incorporated it correctly.

@patrickvonplaten patrickvonplaten requested a review from sgugger April 7, 2022 08:37
Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

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

Went through all the files and it looks good to me!

Think it would make a bit more sense to leave Conv1D in modeling_utils.py next to classes like PoolerAnswerClass instead of moving it to a pytorch utils class since it's more related to modeling IMO - what do you think @sgugger ?

@sgugger
Copy link
Collaborator

sgugger commented Apr 7, 2022

Those should be removed entirely honestly (components should be in model files, not modeling_utils), so I care little where they are :-)

@anmolsjoshi
Copy link
Contributor Author

@patrickvonplaten won't moving Conv1D back to modeling_utils.py cause circular imports?

@anmolsjoshi
Copy link
Contributor Author

@patrickvonplaten any thoughts?

@anmolsjoshi
Copy link
Contributor Author

@sgugger any more changes to complete on this PR?

@patrickvonplaten
Copy link
Contributor

Good to go for me!

@patrickvonplaten
Copy link
Contributor

Waiting for final review from @sgugger

@sgugger
Copy link
Collaborator

sgugger commented Apr 12, 2022

I'm good on my side, was waiting for you Patrick ;-)

@sgugger sgugger merged commit a315988 into huggingface:main Apr 12, 2022
@anmolsjoshi anmolsjoshi deleted the utilsReorg branch April 12, 2022 17:38
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
* Moved functions to pytorch_utils.py

* isort formatting

* Reverted tf changes

* isort, make fix-copies

* documentation fix

* Fixed Conv1D import

* Reverted research examples file

* backward compatibility for pytorch_utils

* missing import

* isort fix
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.

Move generic PyTorch utils function from modeling_utils.py to pytorch_utils

4 participants