Skip to content

feat(megatron): expose optimizer parameter-group overrides - #2543

Open
gusario wants to merge 1 commit into
THUDM:mainfrom
gusario:feat/custom-optimizer-config-overrides
Open

gusario wants to merge 1 commit into
THUDM:mainfrom
gusario:feat/custom-optimizer-config-overrides

Conversation

@gusario

@gusario gusario commented Nov 12, 2026

Copy link
Copy Markdown

Megatron supports per-parameter optimizer configuration through config_overrides, but slime's optimizer factory does not expose it. A custom multimodal model therefore needs to edit the backend to give its language, vision and projector parameters different learning rates.

Add --custom-optimizer-config-overrides-path, a callback receiving (args, optimizer_config). Its mapping is passed unchanged to get_megatron_optimizer; the default call remains unchanged when the flag is absent. The customization guide shows how to retain standard weight-decay exclusions and use native max_lr/min_lr groups without replacing the scheduler. This uses the existing Megatron API and requires no Megatron patch.

Validation:

  • python -m pytest tests/test_stateless_adam.py -q: 8 passed on CPU. Optimizer-construction coverage now checks callback arguments, exact override forwarding, the path without a callback, and that FP32 optimizer shards remain outside autograd. This file already runs in cpu-unittest.
  • A separate CPU integration check against pinned Megatron ae76c60e6 and slime's real scheduler passed: three distinct LR schedules through warmup/cosine decay, per-group minimum LR, and bias/1D weight-decay exclusions. It also detects deliberately removed min_lr overrides and a linear schedule substituted for cosine.
  • Black 24.3.0, isort 5.13.2, Ruff and git diff --check passed for the changed files.

No end-to-end GPU training or distributed save/resume run was performed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant