Repository navigation
Molmo2-Stage1: train the ViT as a third optimizer group (mm_olmo ft_vit parity) - #820
Merged
Merged
Conversation
…it parity) mm_olmo's captioner sets ft_connector/ft_vit/ft_llm all true and gives the ViT its own optimizer group (vit_learning_rate=6e-6, vit_weight_decay=0.0, vit_betas=[0.9, 0.95], vit_eps=1e-6, cosine warmup 2000 / alpha_f=0.1), so it trains three component groups. This script froze the encoder with freeze_params=["vision.*"] and trained two. `TRAIN_VIT` (default True) unfreezes the encoder and adds the vision group. The group overrides only the learning rate, inheriting betas (0.9, 0.95), eps 1e-6 and weight decay 0.0 from the top-level AdamWConfig — which is exactly what mm_olmo configures for the ViT. `--train_vit=false` restores the frozen two-group setup, including putting the encoder back in eval mode (the train module keys that off `freeze_params`, so an empty list keeps it in train mode). Ported from de031c6 on jasonr/molmo2-infra-compare, minus that branch's unrelated SEQUENCE_LENGTH change, and promoted from a module constant to a CLI-overridable field. `train_vit` is resolved from the raw overrides before `Config.merge` runs, like model_size/init_from, because it shapes freeze_params, the optimizer groups and the per-group scheduler — all built pre-merge; the merged config is then re-checked against the resolved value. This matters more now that stage 1 starts from base weights (#818): the encoder is base SigLIP2 rather than a trained Molmo2 ViT, so freezing it was leaving the vision tower at its pretraining state for the whole run. Verified on CPU: - Three real optimizer param groups bind on a tiny model: connector 11 params lr 2e-4, vision 51 params lr 6e-6, LM 47 params lr 2e-5 — all with betas (0.9, 0.95), eps 1e-6, wd 0.0. - Per-group LR curves dispatch correctly through PerGroupScheduler: connector peaks 2e-4 at step 200, ViT 6e-6 at 2000, LM 2e-5 at 2000, each cosine-decaying to 0.1x by step 32000. - The FSDP lockstep invariant still holds with a trainable ViT: on an all-text microbatch (collator's dummy zero crop, all-(-1) pooled) every one of the 51 vision params still receives a finite gradient via the `h + 0.0 * image_features.sum()` tie, so the vision all-gather and reduce-scatter fire on every rank each step. - `--train_vit=false` yields two groups and freeze_params=["vision.*"]. - 242 passed / 17 skipped across src/test/nn/vision and src/test/data/multimodal; isort/black/ruff/mypy clean. Cost: trainable params 4.079B -> 4.462B for the 4B (+9.4%; 8.280B -> 8.662B, +4.6% for the 8B), plus ~2.85 GiB of fp32 AdamW state and ~1.42 GiB of gradients for the 382.5M-param encoder, and ViT backward activations. `vision_activation_checkpointing` already defaults to True in the train module, which now actually earns its keep.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mm_olmo's captioner sets
ft_connector/ft_vit/ft_llmall true and gives the ViT itsown optimizer group, so it trains three component groups. This script froze the encoder
with
freeze_params=["vision.*"]and trained two.TRAIN_VIT(defaultTrue) unfreezes the encoder and adds the vision group. It overridesonly the learning rate, inheriting
betas=(0.9, 0.95),eps=1e-6andweight_decay=0.0from the top-level
AdamWConfig— exactly what mm_olmo configures for the ViT(
vit_betas=[0.9,0.95],vit_eps=1e-6,vit_weight_decay=0.0), so there are no redundantoverrides.
connector.*vision.*All three cosine-decay to
alpha_f=0.1.This matters more since #818. Stage 1 now starts from base checkpoints, so the encoder is
base SigLIP2 rather than a trained Molmo2 ViT — freezing it was leaving the vision tower at
its pretraining state for the entire run.
--train_vit=falserestores the frozen two-group setup, including putting the encoder back ineval mode: the train module keys that off
freeze_params, so the empty list is what keepsit in train mode.
Ported from
de031c61fonjasonr/molmo2-infra-compare, minus that branch's unrelatedSEQUENCE_LENGTHchange, and promoted from a module constant to a CLI-overridable field.train_vitis resolved from the raw overrides beforeConfig.mergeruns — likemodel_size/init_from— because it shapesfreeze_params, the optimizer groups and theper-group scheduler, all built pre-merge. The merged config is then re-checked against the
resolved value so a stray override cannot slip through.
Verified on CPU
Three real optimizer param groups bind (not just config fields) on a tiny model:
connector 11 params @ 2e-4, vision 51 params @ 6e-6, LM 47 params @ 2e-5 — each with
betas (0.9, 0.95), eps 1e-6, wd 0.0.
Per-group LR curves dispatch correctly through
PerGroupScheduler:The FSDP lockstep invariant still holds with a trainable ViT. Every rank must produce
vision gradients every step or the collectives desync, and the mixture hands some ranks
all-text microbatches. Tested directly: on an all-text batch (the collator's dummy zero crop,
all-
-1pooled) all 51 vision params still receive finite gradients via the existingh + 0.0 * image_features.sum()tie. That tie was added for the connector; it covers the ViTtoo, since the gradient path runs vision → connector →
image_features.--train_vit=falseyields two groups andfreeze_params=["vision.*"].242 passed / 17 skipped across
src/test/nn/visionandsrc/test/data/multimodal;isort/black/ruff/mypy clean. No test was added for the script's own config — no training
script in this repo has one — so the above is local-run verification.
Cost to budget for
Plus ViT backward activations for the 382.5M-param encoder.
vision_activation_checkpointingalready defaults toTruein the train module and nowactually earns its keep. Given the 4B peaked near 44 GiB with a frozen ViT, the 8B with a
trainable one is where
--train_module.response_logits_only=trueand an LMac_configstopbeing optional — both still open follow-ups from the mm_olmo comparison.