-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add TorchScriptable transformer classifier and subword BPE tokenizer #4566
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WHOAAAA!!
Will leave @jxmsML to do a deeper review and approve. On the surface I see only minor issues.
Please black before committing.
return text | ||
|
||
|
||
class TorchScriptTransformerClassifier(nn.Module): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is getting huge. I'd suggest we break modules.py up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved tokenizer out of module.py. Do we want to split the modules further? e.g., generator_module and classifier_module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll let you decide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's good for now. If there are more models to add. We can group them further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nits
Sorry for keeping this PR pending 😔. I will work on the comment next week. |
@stephenroller @EricMichaelSmith Shall we merge it? 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a minor comment. The lint CI check is failing - I'd run autoformat.sh to resolve
Co-authored-by: Eric Smith <EricMichaelSmith@users.noreply.github.com>
@klshuster calling the tech lead to force a decision: accept or iterate more? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephenroller Hmm it looks fine to approve to me - @zzhangncsu I added one last minor comment. Great to have this functionality and unit test coverage!
@EricMichaelSmith @ It seems I have a warning "1 workflow awaiting approval" since i'm a first-time contributor. Also the long_gpu_tests failes. Any suggestions? |
Yeah, I think one of us has to approve running the CI checks. The long_gpu_tests check fails with a |
I think that's unrelated to this PR. Also I trust @EricMichaelSmith here, if approved let's get it in |
I did the merge. seems not helpful. |
@stephenroller did you ever see this error when debugging CI checks? It looks to come from downloading http://parl.ai/downloads/_models/wikipedia_full/tfidf_retriever/model.tgz , nothing to do with this PR itself |
@EricMichaelSmith Shall we merge the PR? :-) |
Hmm, assuming that the long_gpu_tests PR is still the only one that fails, and assuming that it still fails given the error above, yes, I'd say that you're fine to merge now, given that we now see this same error in main :/ |
Sounds good. I don't have the write permission though. Please feel free to merge it. Thanks! |
Just merged. Thanks again for doing this! |
Patch description
Enable Torchscripting of a Transformer classifier agent and subword BPE tokenizer.
Testing steps
Run unit tests:
pytest tests/test_torchscript.py
Exporting model
Call to export model:
Other information
Support GPU model without DataParallel . See pytorch/pytorch#30635 for more information.