torchtune
torchtune copied to clipboard
add a "division by zero" check in chunked loss handling in kd_losses.py
Context
What is the purpose of this PR? Is it to
- [ ] add a new feature
- [ ] fix a bug
- [ ] update tests and/or documentation
- [x] other (add a "division by zero" check in chunked loss handling in kd_losses.py)
Please link to any issues this PR addresses.
Changelog
What are the changes made in this PR?
- add a "division by zero" check in chunked loss handling in kd_losses.py (Issue https://github.com/pytorch/torchtune/issues/2225)
Test plan
Please make sure to do each of the following if applicable to your PR. If you're unsure about any one of these just ask and we will happily help. We also have a contributing page for some guidance on contributing.
- [x] run pre-commit hooks and linters (make sure you've first installed via
pre-commit install
) - [x] add unit tests for any new functionality
- [ ] update docstrings for any new or updated methods or classes
- [x] run unit tests via
pytest tests
- [x] run
pytest -v tests/torchtune/modules/loss/test_kd_losses.py
- [ ] run recipe tests via
pytest tests -m integration_test
- [ ] manually run any new or modified recipes with sufficient proof of correctness
- [ ] include relevant commands and any other artifacts in this summary (pastes of loss curves, eval results, etc.)
UX
If your function changed a public API, please add a dummy example of what the user experience will look like when calling it. Here is a docstring example and a tutorial example
- [x] I did not change any public API
- [ ] I have added an example to docs or docstrings