Add reverse KL divergence (RKL) loss for speculative decoding#667
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds a reverse KL loss variant, wires ChangesReverse KL loss support
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit/models/test_metrics.py (1)
118-120: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a parser-level test for
--loss-fn rkl.These assertions stop at
resolve_loss_fn("rkl"), so a typo or regression inscripts/train.py'schoices/CLI wiring would still pass. Please add one test that parses--loss-fn rklend to end.As per path instructions, "Check that new code paths introduced in the PR are covered."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/models/test_metrics.py` around lines 118 - 120, Add an end-to-end parser-level test for the new `--loss-fn rkl` path so CLI wiring in `scripts/train.py` is exercised, not just `resolve_loss_fn`. Extend the existing metrics test coverage by parsing the training arguments with `--loss-fn rkl` and asserting the parsed loss function resolves to `reverse_kl_div_loss`, using the relevant parser/CLI entrypoint from `scripts/train.py` and the `resolve_loss_fn` symbol to locate the flow. Keep the existing unit test for `resolve_loss_fn("rkl")`, but add the new parser assertion to catch regressions in `choices` or argument parsing.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/unit/models/test_metrics.py`:
- Around line 118-120: Add an end-to-end parser-level test for the new
`--loss-fn rkl` path so CLI wiring in `scripts/train.py` is exercised, not just
`resolve_loss_fn`. Extend the existing metrics test coverage by parsing the
training arguments with `--loss-fn rkl` and asserting the parsed loss function
resolves to `reverse_kl_div_loss`, using the relevant parser/CLI entrypoint from
`scripts/train.py` and the `resolve_loss_fn` symbol to locate the flow. Keep the
existing unit test for `resolve_loss_fn("rkl")`, but add the new parser
assertion to catch regressions in `choices` or argument parsing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8593e77b-371d-48a4-ada9-c91ccf623826
📒 Files selected for processing (3)
scripts/train.pysrc/speculators/models/metrics.pytests/unit/models/test_metrics.py
|
This pull request has merge conflicts that must be resolved before it can be |
3605f23 to
3baf3c4
Compare
3baf3c4 to
5e73609
Compare
|
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
…roject#667) <!-- markdownlint-disable --> <!-- PLEASE FILL IN THE PR DESCRIPTION HERE ENSURING ALL CHECKLIST ITEMS (AT THE BOTTOM) HAVE BEEN CONSIDERED. --> ## Purpose Draft training only had forward KL, which is mass-covering; reverse KL `KL(draft || target)` is mode-seeking and can favour acceptance. Add it as a selectable loss. ## Tests - Two-node-independent unit tests in test_metrics.py: identical dists -> ~0 and random -> non-negative, equals forward KL with args swapped, and resolve_loss_fn("rkl") wiring. 17 passed. ## Checklist I have filled in: - [x] The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)". - [x] The test plan/results, such as providing test command and pasting the results. - [ ] (Optional) The necessary documentation update. - [x] I (a human) have written or reviewed the code in this pr to the best of my ability. --------- Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com> Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com> Co-authored-by: Orestis Zambounis <23146389+orestis-z@users.noreply.github.com> Co-authored-by: Orestis Zambounis <orestis.zambounis@gmail.com>
…roject#667) <!-- markdownlint-disable --> <!-- PLEASE FILL IN THE PR DESCRIPTION HERE ENSURING ALL CHECKLIST ITEMS (AT THE BOTTOM) HAVE BEEN CONSIDERED. --> ## Purpose Draft training only had forward KL, which is mass-covering; reverse KL `KL(draft || target)` is mode-seeking and can favour acceptance. Add it as a selectable loss. ## Tests - Two-node-independent unit tests in test_metrics.py: identical dists -> ~0 and random -> non-negative, equals forward KL with args swapped, and resolve_loss_fn("rkl") wiring. 17 passed. ## Checklist I have filled in: - [x] The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)". - [x] The test plan/results, such as providing test command and pasting the results. - [ ] (Optional) The necessary documentation update. - [x] I (a human) have written or reviewed the code in this pr to the best of my ability. --------- Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com> Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com> Co-authored-by: Orestis Zambounis <23146389+orestis-z@users.noreply.github.com> Co-authored-by: Orestis Zambounis <orestis.zambounis@gmail.com> Signed-off-by: Eros483 <arnabmandal2912@gmail.com>
Purpose
Draft training only had forward KL, which is mass-covering; reverse KL
KL(draft || target)is mode-seeking and can favour acceptance. Add it as a selectable loss.Tests
Checklist
I have filled in: