-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Script Fairseq transformer #1620
Conversation
This pull request was exported from Phabricator. Differential Revision: D19234599 |
4c51e8c
to
99a57a7
Compare
This pull request was exported from Phabricator. Differential Revision: D19234599 |
1 similar comment
This pull request was exported from Phabricator. Differential Revision: D19234599 |
99a57a7
to
1c0b372
Compare
This pull request was exported from Phabricator. Differential Revision: D19234599 |
1c0b372
to
326944b
Compare
Differential Revision: D19382299 fbshipit-source-id: 56cbdc3462a19ff87d3c9b8b79878ed3b44806f9
Summary: Pull Request resolved: fairinternal/fairseq-py#1011 Pull Request resolved: facebookresearch#1620 Make Fairseq transformer scriptable. Discussion points on possible code refactoring: (1) Original decoder output is a tuple (x, {"attn": attn, "inner_states": inner_states}). TorchScript does not support dictionary with values of different types (attn: Tensor, inner_states: List[Tensor]). Current workaround is to use [attn] for attention field and access via output["attn"][0] in downstream. This is currently used in fairspeq custom transformer code. Another (maybe) cleaner alternative is to use namedtuple for decoder output but involves tons of downstream changes too. (2) Currently TorchScript doesn't support **kwargs. Some unused arguments might get passed in due to polymorphism. Now the only workaround I can think of is to add possible unused arguments, (e.g. line 666 in transformer.py) Differential Revision: D19234599 fbshipit-source-id: 64b8a64995bd2bf9a24f6b0665609a2856dad840
326944b
to
dd06781
Compare
This pull request was exported from Phabricator. Differential Revision: D19234599 |
Summary: Pull Request resolved: fairinternal/fairseq-py#1011 Pull Request resolved: facebookresearch/fairseq#1620 Make Fairseq transformer scriptable. Discussion points on possible code refactoring: (1) Original decoder output is a tuple (x, {"attn": attn, "inner_states": inner_states}). TorchScript does not support dictionary with values of different types (attn: Tensor, inner_states: List[Tensor]). Current workaround is to use [attn] for attention field and access via output["attn"][0] in downstream. This is currently used in fairspeq custom transformer code. Another (maybe) cleaner alternative is to use namedtuple for decoder output but involves tons of downstream changes too. (2) Currently TorchScript doesn't support **kwargs. Some unused arguments might get passed in due to polymorphism. Now the only workaround I can think of is to add possible unused arguments, (e.g. line 666 in transformer.py) Reviewed By: myleott Differential Revision: D19234599 fbshipit-source-id: db3dd364ecf3ae14fb7ac8c0928bd0ebe250f19d
This pull request has been merged in a07cb6f. |
Summary: Pull Request resolved: fairinternal/fairseq-py#1011 Pull Request resolved: facebookresearch#1620 Make Fairseq transformer scriptable. Discussion points on possible code refactoring: (1) Original decoder output is a tuple (x, {"attn": attn, "inner_states": inner_states}). TorchScript does not support dictionary with values of different types (attn: Tensor, inner_states: List[Tensor]). Current workaround is to use [attn] for attention field and access via output["attn"][0] in downstream. This is currently used in fairspeq custom transformer code. Another (maybe) cleaner alternative is to use namedtuple for decoder output but involves tons of downstream changes too. (2) Currently TorchScript doesn't support **kwargs. Some unused arguments might get passed in due to polymorphism. Now the only workaround I can think of is to add possible unused arguments, (e.g. line 666 in transformer.py) Reviewed By: myleott Differential Revision: D19234599 fbshipit-source-id: db3dd364ecf3ae14fb7ac8c0928bd0ebe250f19d
Summary: Pull Request resolved: fairinternal/fairseq-py#1011 Pull Request resolved: facebookresearch/fairseq#1620 Make Fairseq transformer scriptable. Discussion points on possible code refactoring: (1) Original decoder output is a tuple (x, {"attn": attn, "inner_states": inner_states}). TorchScript does not support dictionary with values of different types (attn: Tensor, inner_states: List[Tensor]). Current workaround is to use [attn] for attention field and access via output["attn"][0] in downstream. This is currently used in fairspeq custom transformer code. Another (maybe) cleaner alternative is to use namedtuple for decoder output but involves tons of downstream changes too. (2) Currently TorchScript doesn't support **kwargs. Some unused arguments might get passed in due to polymorphism. Now the only workaround I can think of is to add possible unused arguments, (e.g. line 666 in transformer.py) Reviewed By: myleott Differential Revision: D19234599 fbshipit-source-id: db3dd364ecf3ae14fb7ac8c0928bd0ebe250f19d
Summary: Pull Request resolved: fairinternal/fairseq-py#1011 Pull Request resolved: facebookresearch/fairseq#1620 Make Fairseq transformer scriptable. Discussion points on possible code refactoring: (1) Original decoder output is a tuple (x, {"attn": attn, "inner_states": inner_states}). TorchScript does not support dictionary with values of different types (attn: Tensor, inner_states: List[Tensor]). Current workaround is to use [attn] for attention field and access via output["attn"][0] in downstream. This is currently used in fairspeq custom transformer code. Another (maybe) cleaner alternative is to use namedtuple for decoder output but involves tons of downstream changes too. (2) Currently TorchScript doesn't support **kwargs. Some unused arguments might get passed in due to polymorphism. Now the only workaround I can think of is to add possible unused arguments, (e.g. line 666 in transformer.py) Reviewed By: myleott Differential Revision: D19234599 fbshipit-source-id: db3dd364ecf3ae14fb7ac8c0928bd0ebe250f19d
Summary:
Make Fairseq transformer scriptable. Discussion points on code quality:
(1) Original decoder output is a tuple (x, {"attn": attn, "inner_states": inner_states}). TorchScript does not support dictionary with values of different types (attn: Tensor, inner_states: List[Tensor]). Current workaround is to use [attn] for attention field and access via output["attn"][0] in downstream. This is currently used in fairspeq custom transformer code. Another (maybe) cleaner alternative is to use namedtuple for decoder output but involves tons of downstream changes too.
(2) Currently TorchScript doesn't support **kwargs. Some unused arguments might get passed in due to polymorphism. Now the only workaround I can think of is to add possible unused arguments, (e.g. line 666 in transformer.py)
Differential Revision: D19234599