Repository navigation
[main] feat(moe): Support apply wd to qk layernorm for Qwen3-Next (4/4) #2753
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
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 |
|---|---|---|
|
|
@@ -925,6 +925,17 @@ def validate_args(args, defaults={}): | |
| dc = torch.cuda.get_device_capability() | ||
| assert dc[0] >= 8, "Unsupported compute capability for GroupedGEMM kernels." | ||
|
|
||
| if args.no_weight_decay_cond_type is not None: | ||
| print_rank_0( | ||
| 'WARNING: --no-weight-decay-cond-type is deprecated. Please use --apply-wd-to-qk-layernorm instead.', | ||
| args.rank, | ||
| ) | ||
| if args.no_weight_decay_cond_type == "apply_wd_to_qk_layernorm": | ||
| args.apply_wd_to_qk_layernorm = True | ||
| else: | ||
| raise ValueError(f"Invalid no_weight_decay_cond_type: {args.no_weight_decay_cond_type}") | ||
| args.no_weight_decay_cond_type = None | ||
|
|
||
| if args.weight_decay_incr_style == 'constant': | ||
| assert args.start_weight_decay is None | ||
| assert args.end_weight_decay is None | ||
|
|
@@ -2077,6 +2088,8 @@ def _add_regularization_args(parser): | |
| help='Dropout probability for hidden state transformer.') | ||
| group.add_argument('--weight-decay', type=float, default=0.01, | ||
| help='Weight decay coefficient for L2 regularization.') | ||
| group.add_argument('--apply-wd-to-qk-layernorm', action='store_true', | ||
| help='Apply weight decay to qk layernorm as a special case.') | ||
| group.add_argument('--clip-grad', type=float, default=1.0, | ||
| help='Gradient clipping based on global L2 norm.') | ||
| group.add_argument('--adam-beta1', type=float, default=0.9, | ||
|
|
@@ -2111,6 +2124,12 @@ def _add_regularization_args(parser): | |
| group.add_argument('--muon-extra-scale-factor', type=float, default=1.0, | ||
| help='Additional scale factor for the muon update') | ||
|
|
||
| group.add_argument('--no-weight-decay-cond-type', type=str, choices=['apply_wd_to_qk_layernorm'], | ||
|
Contributor
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. Why are we adding a deprecated argument? Is this for checkpoint compatibility or something?
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. It is for compatibility, because it has been added to the dev branch for about half a year. |
||
| help='Type of no weight decay condition. Choices: ' | ||
| 'None (default): apply weight decay to 1D weights and biases.' | ||
| '"apply_wd_to_qk_layernorm": additionally apply weight decay to ' | ||
| 'qk layernorm as a special case.' | ||
| 'DEPRECATED. Please use --apply-wd-to-qk-layernorm instead. ') | ||
| return parser | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand what this option does. In particular, "as a special case"? What's the general case then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally all len==1 (eg layernorm weights) or bias terms get added to the
wd=0group. This says "do not add the q or k layernorm weights to the wd=0 group, leave them as wd=1".