-
Notifications
You must be signed in to change notification settings - Fork 531
Unit test for TensorWeightedAvg RecMetric #3139
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
base: main
Are you sure you want to change the base?
Conversation
This pull request was exported from Phabricator. Differential Revision: D77169334 |
c9839b1
to
7557083
Compare
Summary: Main test lies in test_tensor_weighted_avg.py This patch adds a unit test for TensorWeightedAvg metric. The existing framework for the rec metric testing module did not support processing tensors tied to a task's tensor_name, which the tensor weighted avg metric uses. Main modifications to other tests include changes to the TestMetric's _get_states() method signature to support processing arbitrary tensors in the testing framework. Rollback Plan: Differential Revision: D77169334
This pull request was exported from Phabricator. Differential Revision: D77169334 |
Summary: Main test lies in `test_tensor_weighted_avg.py` This patch adds a unit test for TensorWeightedAvg metric. The existing framework for the rec metric testing module did not support processing tensors tied to a task's tensor_name, which the tensor weighted avg metric uses. Increases code coverage to 97.7%. [Previous external tests covered 35%](https://www.internalfb.com/quality/coverage?query=%7B%22key%22%3A%22AND%22%2C%22children%22%3A[%7B%22key%22%3A%22CONTAINS_ANY_OF_FBIDS%22%2C%22field%22%3A%22CODE_QUALITY_ONCALL%22%2C%22value%22%3A[%7B%22title%22%3A%22torchrec%20(torchrec%20%3A%20Zain%20Huda)%22%2C%22fbid%22%3A%22711323163133477%22%2C%22photo%22%3A%22%22%7D]%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Ffb%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_CONTAINS_TEXT%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22tests%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_CONTAINS_TEXT%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22__init__.py%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fgithub%2F%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fcsrc%2F%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fdatasets%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Finference%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fpt2%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_CONTAINS_TEXT%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22benchmark%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fmetrics%2F%22%7D]%7D&is_e2e=false&show_all_partitions=false&split_graph=true) Main modifications to other tests include changes to the TestMetric's _get_states() method signature to support processing arbitrary tensors in the testing framework. Differential Revision: D77169334
7557083
to
33b6180
Compare
This pull request was exported from Phabricator. Differential Revision: D77169334 |
Summary: Main test lies in `test_tensor_weighted_avg.py` (format similar to `test_weighted_avg.py`) This patch adds a unit test for TensorWeightedAvgMetric. The existing framework for the rec metric testing module does not support processing tensors tied to a task's tensor_name, which the tensor weighted avg metric uses. Main modifications to other tests include changes to the TestMetric's _get_states() method signature to support processing arbitrary tensors in the testing framework. Increases code coverage to 97.7%. [Previous external tests covered 35%](https://www.internalfb.com/quality/coverage?query=%7B%22key%22%3A%22AND%22%2C%22children%22%3A[%7B%22key%22%3A%22CONTAINS_ANY_OF_FBIDS%22%2C%22field%22%3A%22CODE_QUALITY_ONCALL%22%2C%22value%22%3A[%7B%22title%22%3A%22torchrec%20(torchrec%20%3A%20Zain%20Huda)%22%2C%22fbid%22%3A%22711323163133477%22%2C%22photo%22%3A%22%22%7D]%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Ffb%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_CONTAINS_TEXT%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22tests%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_CONTAINS_TEXT%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22__init__.py%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fgithub%2F%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fcsrc%2F%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fdatasets%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Finference%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fpt2%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_CONTAINS_TEXT%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22benchmark%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fmetrics%2F%22%7D]%7D&is_e2e=false&show_all_partitions=false&split_graph=true) Differential Revision: D77169334
33b6180
to
24a2fd6
Compare
This pull request was exported from Phabricator. Differential Revision: D77169334 |
Summary: Main test lies in `test_tensor_weighted_avg.py` (format similar to `test_weighted_avg.py`) This patch adds a unit test for TensorWeightedAvgMetric. The existing framework for the rec metric testing module does not support processing tensors tied to a task's tensor_name, which the tensor weighted avg metric uses. Main modifications to other tests include changes to the TestMetric's _get_states() method signature to support processing arbitrary tensors in the testing framework. Increases code coverage to 97.7%. [Previous external tests covered 35%](https://www.internalfb.com/quality/coverage?query=%7B%22key%22%3A%22AND%22%2C%22children%22%3A[%7B%22key%22%3A%22CONTAINS_ANY_OF_FBIDS%22%2C%22field%22%3A%22CODE_QUALITY_ONCALL%22%2C%22value%22%3A[%7B%22title%22%3A%22torchrec%20(torchrec%20%3A%20Zain%20Huda)%22%2C%22fbid%22%3A%22711323163133477%22%2C%22photo%22%3A%22%22%7D]%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Ffb%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_CONTAINS_TEXT%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22tests%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_CONTAINS_TEXT%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22__init__.py%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fgithub%2F%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fcsrc%2F%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fdatasets%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Finference%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fpt2%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_CONTAINS_TEXT%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22benchmark%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fmetrics%2F%22%7D]%7D&is_e2e=false&show_all_partitions=false&split_graph=true) Differential Revision: D77169334
24a2fd6
to
e3ca582
Compare
This pull request was exported from Phabricator. Differential Revision: D77169334 |
Summary: Main test lies in `test_tensor_weighted_avg.py` (format similar to `test_weighted_avg.py`) This patch adds a unit test for TensorWeightedAvgMetric. TensorWeightedAvgMetric allows users to pass in a tensor that is not a prediction/weight/label with a corresponding tensor name, into a dict called "required_inputs". The purpose is to compute and emit the weighted average of a tensor of their choice. However, the existing framework for the rec metric testing module does not support processing tensors under "required_inputs". Main modifications to other tests include changes to the TestMetric's _get_states() method signature to support processing tensor passed into "required_inputs". Increases code coverage to 97.7%. [Previous external tests covered 35%](https://www.internalfb.com/quality/coverage?query=%7B%22key%22%3A%22AND%22%2C%22children%22%3A[%7B%22key%22%3A%22CONTAINS_ANY_OF_FBIDS%22%2C%22field%22%3A%22CODE_QUALITY_ONCALL%22%2C%22value%22%3A[%7B%22title%22%3A%22torchrec%20(torchrec%20%3A%20Zain%20Huda)%22%2C%22fbid%22%3A%22711323163133477%22%2C%22photo%22%3A%22%22%7D]%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Ffb%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_CONTAINS_TEXT%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22tests%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_CONTAINS_TEXT%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22__init__.py%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fgithub%2F%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fcsrc%2F%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fdatasets%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Finference%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fpt2%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_NOT_CONTAINS_TEXT%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22benchmark%22%7D%2C%7B%22key%22%3A%22CODE_QUALITY_STARTS_WITH%22%2C%22field%22%3A%22CODE_QUALITY_FILE_PATH%22%2C%22value%22%3A%22fbcode%2Ftorchrec%2Fmetrics%2F%22%7D]%7D&is_e2e=false&show_all_partitions=false&split_graph=true) Reviewed By: kausv Differential Revision: D77169334
e3ca582
to
0dd138e
Compare
This pull request was exported from Phabricator. Differential Revision: D77169334 |
Main test lies in
test_tensor_weighted_avg.py
(format similar totest_weighted_avg.py
)This patch adds a unit test for TensorWeightedAvgMetric.
TensorWeightedAvgMetric allows users to pass in a tensor that is not a prediction/weight/label with a corresponding tensor name, into a dict called "required_inputs". The purpose is to compute and emit the weighted average of a tensor of their choice.
However, the existing framework for the rec metric testing module does not support processing tensors under "required_inputs". Main modifications to other tests include changes to the TestMetric's _get_states() method signature to support processing tensor passed into "required_inputs".
Increases code coverage from 0% to 97.5%