feat(training): support configurable loss fn via training args#542
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:
WalkthroughThis PR adds configurable loss function selection across draft model training via a new ChangesLoss function configurability
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
b000085 to
b6b6665
Compare
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Require two reviewsWonderful, this rule succeeded.PRs labelled "two-reviews" must have at least two approving reviews before merging.
|
|
I noticed that there were no tests to verify CLI args so I created a new file but lmk if you want me to rename/move the tests :) |
|
The quality checks have failed. Please run |
b6b6665 to
a87277e
Compare
|
The quality checks have failed. Please run |
fynnsu
left a comment
There was a problem hiding this comment.
Thanks! Should be almost good to merge
461a3b4 to
74d1ffc
Compare
74d1ffc to
6f1f9c7
Compare
|
The quality checks have failed. Please run |
6f1f9c7 to
9072bb2
Compare
shanjiaz
left a comment
There was a problem hiding this comment.
Great job! Thanks for contributing.
|
The quality checks have failed. Please run |
Head branch was pushed to by a user without write access
9072bb2 to
0fa1077
Compare
|
The quality checks have failed. Please run |
0fa1077 to
2108793
Compare
|
The quality checks have failed. Please run |
Signed-off-by: Christina Xu <chrxu@redhat.com>
2108793 to
c0a39ee
Compare
DFlash's hardcoded default was ce_loss until PR vllm-project#542, which per issue vllm-project#541 was only meant to make the loss configurable but accidentally flipped DFlash's default to kl_div (never validated for DFlash). Pass --loss-fn explicitly via a new LOSS_FN config var (default "ce") so our runs use the validated objective; override with LOSS_FN=kl_div. Uses the upstream --loss-fn flag (no core-code divergence). The core default fix will go via a separate upstream issue/PR. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Re-pins BASELINE.md links to 6b03432 (the commit that defaults DFlash loss to ce) and updates the hyperparameter table + notes: loss is now --loss-fn ce (the validated DFlash default per issue vllm-project#541), not the unvalidated kl_div vllm-project#542 default. noise-std/scheduler remain upstream defaults. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
denom, vllm-project#542, vocab) Reference doc resolving the recurring "~3.5 vs ~12 loss" confusion: - The reported loss is a decay-weighted reduction; PR vllm-project#496 (0d73ed0) changed the denominator Σ(mask·decay) -> Σ(mask), scaling reported loss + gradient ~3.4x (12/3.5 = Σmask/Σdecay). Pre-vllm-project#496 ~12, post-vllm-project#496 ~3.5. Implies ~3.4x lower effective LR post-vllm-project#496. - Not ce-vs-kl (both ~3.5 after the reduction); vllm-project#542 separately flipped the default ce->kl_div contra vllm-project#541. - Debunks the "vLLM defaults vocab to 32000" claim: launch_vllm never sets vocab, run uses full 151,936; ln(32000) vs ln(151936) is ~1.5 apart, not 12 vs 3.5. - SpecForge ref (soft-CE, ÷B*T, no decay; eagle3 uses LK loss) not comparable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
PLEASE FILL IN THE PR DESCRIPTION HERE ENSURING ALL CHECKLIST ITEMS (AT THE BOTTOM) HAVE BEEN CONSIDERED.
Purpose
This PR addresses #541
Description
It adds a --loss-fn argument and input validation to
scripts/train.py. If defined, it passes the resolved loss function to get_trainer_kwargs() so each model's compute_metrics call uses arg.loss_fn. If args.loss_fn=None, it falls back to the previously hardcoded loss fn.Tests
I added unit tests here
tests/unit/train/test_cli_args.pyto test that arg.loss_fn is passed correctly to each model's get_trainer_kwargs() and that we maintain backward compatibilityI have filled in: