Repository navigation
Bring offline KD upgrades such as Ghost Token and Top-P to Megatron K… #2459
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
Changes from all commits
b4112bd
95c9aa7
3f751f3
df93c40
32be4ee
ef8233c
c1fb187
51a8b60
57fc703
c1857f0
2ad0e70
02151b3
7bb3c08
83c1a1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -208,21 +208,36 @@ def get_args(): | |
| "--train_iters", type=int, required=True, help="Number of training iterations" | ||
| ) | ||
| parser.add_argument( | ||
| "--no_skip_lm_loss", action="store_true", help="Disable skipping language model loss" | ||
| "--kd_loss_alpha", | ||
| type=float, | ||
| default=1.0, | ||
| help="KD loss weight alpha in (1 - alpha) * lm_loss + alpha * kd_loss. 1.0 skips the LM loss entirely.", | ||
| ) | ||
| parser.add_argument("--kd_loss_scale", type=float, default=1.0, help="KD loss weight") | ||
| parser.add_argument( | ||
| "--no_async_save", | ||
| action="store_true", | ||
| help="Save checkpoints synchronously. Async saving spawns a worker that needs its own " | ||
| "CUDA context, which fails when the training process already fills the GPU.", | ||
| ) | ||
| parser.add_argument( | ||
| "--logit_kl_topk", | ||
| "--logit_kl_top_k", | ||
| type=int, | ||
| default=None, | ||
| help="Restrict the logit KL loss to the teacher's top-k vocabulary entries, " | ||
| "replacing the full-vocab temporaries with [seq, k] ones.", | ||
| help="Restrict the logit KL loss to the teacher's top-k vocabulary entries plus a residual " | ||
| "bucket for the remaining probability mass (distributions are still normalized over the full vocab).", | ||
| ) | ||
| parser.add_argument( | ||
| "--logit_kl_top_p", | ||
| type=float, | ||
| default=None, | ||
| help="Nucleus threshold in (0, 1] applied on top of --logit_kl_top_k: only the smallest prefix " | ||
| "of the sorted top-k whose cumulative teacher probability reaches this value is distilled.", | ||
| ) | ||
| parser.add_argument( | ||
| "--logit_kl_top_p_min_k", | ||
| type=int, | ||
| default=1, | ||
| help="Minimum number of top-k entries kept per token when --logit_kl_top_p is active.", | ||
| ) | ||
| parser.add_argument("--lr", type=float, default=1e-4, help="Peak learning rate") | ||
| parser.add_argument("--min_lr", type=float, default=1e-5, help="Minimum learning rate") | ||
|
|
@@ -474,9 +489,10 @@ def _build_model_provider(hf_path, load_weights=True, moe_grouped_gemm=True): | |
| ) | ||
|
|
||
| kd_config = ModelOptDistillConfig( | ||
| skip_lm_loss=not args.no_skip_lm_loss, | ||
| kd_loss_scale=args.kd_loss_scale, | ||
| logit_kl_topk=args.logit_kl_topk, | ||
| kd_loss_alpha=args.kd_loss_alpha, | ||
| logit_kl_topk=args.logit_kl_top_k, | ||
| logit_kl_top_p=args.logit_kl_top_p, | ||
| logit_kl_top_p_min_k=args.logit_kl_top_p_min_k, | ||
|
AAnoosheh marked this conversation as resolved.
|
||
| ) | ||
|
Comment on lines
491
to
496
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [IMPORTANT Compatibility] Two concrete ways this breaks across the repo boundary:
Nothing inside ModelOpt reads
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checked against the pinned Megatron-Bridge: |
||
|
|
||
| # HF VLM configs expose ``vision_config``; Megatron-Bridge nests the text model under | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.