Conversation
Adds kl_type=jsd to DistillationLossFn, interpolating between forward and reverse KL via a beta weight (0.5 by default gives the symmetric Jensen-Shannon divergence). Mirrors what forward/reverse already do for the top-k correction term. Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
…-loss # Conflicts: # nemo_rl/algorithms/loss/loss_functions.py
The three JSD tests inherited a CUDA-only helper, so they were skipped everywhere without a GPU and never actually ran. The JSD branch is pure tensor math, so setup_distillation_test_data now takes an optional device (default unchanged, still CUDA-or-skip) and these pass device=cpu. Also collapses the repeated prepare/invoke block in those three tests into one helper. The global_valid_* idiom appears 45 times in this file, so the other call sites are left alone rather than half-migrated. Signed-off-by: Kashif Rasul <kashif.rasul@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do ?
Adds a Jensen-Shannon divergence option to the distillation loss, alongside the existing forward/reverse/mixed KL choices.
Issues
The distillation loss currently only supports forward KL, reverse KL, or a fixed linear blend of the two. This adds
kl_type="jsd"with ajsd_betaweight: beta=0 is forward KL, beta=1 is reverse KL, and 0.5 (default) gives the symmetric, bounded Jensen-Shannon divergence - a genuinely different loss shape than blending two KL terms, since both sides are measured against a shared mixture distribution instead of each other directly.Usage
Before your PR is "Ready for review"
Pre checks:
Additional Information