-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Split PytorchModelHandler into PytorchModelHandlerTensor and PytorchModelHandlerKeyedTensor #21810
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
Conversation
| from apache_beam.utils.annotations import experimental | ||
|
|
||
|
|
||
| class PytorchModelHandler(ModelHandler[torch.Tensor, |
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.
Is the intention to still keep PytorchModelHandler?
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.
No I think we want to drop PytorchModelHandler
| import torch | ||
| from apache_beam.ml.inference.api import PredictionResult | ||
| from apache_beam.ml.inference.base import RunInference | ||
| from apache_beam.ml.inference.pytorch_inference import PytorchModelHandler |
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.
For the tests, I changed them to use PytorchModelHandlerTensor, and PytorchModelHandlerKeyedTensor. Should the tests default to use PytorchModelHandler since PytorchModelHandlerTensor, and PytorchModelHandlerKeyedTensor are experimental? How should we handle this
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.
Let's drop PytorchModelHandler and exercise the type-specific ones.
|
Can one of the admins verify this patch? |
3 similar comments
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
TheNeuralBit
left a comment
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.
Thanks!
| """ Implementation of the ModelHandler interface for PyTorch. | ||
| NOTE: This API and its implementation are under development and | ||
| do not provide backward compatibility guarantees. |
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.
IIUC we want to drop the experimental tag and NOTE for this one, but we'll keep the named input one (KeyedTensor) marked experimental. See here: #21803 (comment)
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.
SG
| from apache_beam.utils.annotations import experimental | ||
|
|
||
|
|
||
| class PytorchModelHandler(ModelHandler[torch.Tensor, |
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.
No I think we want to drop PytorchModelHandler
| import torch | ||
| from apache_beam.ml.inference.api import PredictionResult | ||
| from apache_beam.ml.inference.base import RunInference | ||
| from apache_beam.ml.inference.pytorch_inference import PytorchModelHandler |
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.
Let's drop PytorchModelHandler and exercise the type-specific ones.
|
PTAL @TheNeuralBit |
Codecov Report
@@ Coverage Diff @@
## master #21810 +/- ##
==========================================
- Coverage 74.15% 74.13% -0.03%
==========================================
Files 698 698
Lines 92417 92429 +12
==========================================
- Hits 68530 68519 -11
- Misses 22636 22659 +23
Partials 1251 1251
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
| self._model_class, | ||
| self._state_dict_path, | ||
| self._device, | ||
| **self._model_params) |
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.
What do you think about naming model parameters as a dictionary?
The advantage is that users can specify exactly what their parameters should be.
They would specify the parameters like this:
model_parameters = {
'key_1': 'parameter_1'
}
Then in the future if optional parameters are added they won't collide.
Feel free to do that change in another PR if you think it's a good idea.
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.
are you referring to something like this? #21806
…odelHandlerKeyedTensor (apache#21810) * Start to split of Pytorch handlers * Remove old PytorchModelHandler
Split
PytorchModelHandlerinto experimentalPytorchModelHandlerTensorandPytorchModelHandlerKeyedTensortransforms.Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username).addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.