Skip to content

Molmo2-Stage1: align with the released Molmo2-4B-Pretrain config - #822

Merged
jason718 merged 2 commits into
allenai:visionfrom
jason718:jasonr/stage1-mmolmo-batch-defaults
Aug 14, 2026
Merged

jason718 merged 2 commits into
allenai:visionfrom
jason718:jasonr/stage1-mmolmo-batch-defaults

Conversation

@jason718

@jason718 jason718 commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Aligns stage 1 with the config the released model was actually trained with:
/weka/oe-training-default/mm-olmo/released-models-molmo2-1225/Molmo2-4B-Pretrain/config.yaml,
whose runtime_data.args records the exact launch command. That supersedes the argparse
defaults in train_captioner.py, which earlier work in this series had been treating as
ground truth.

30/30 settings now match in a field-by-field diff against the YAML.

Corrected by the real config

was released config source
seq_len 2536 2560 --seq_len=2560 passed explicitly; data.sequence_length: 2560 in both 4B and 8B
4B backbone base Qwen/Qwen3-4B Qwen/Qwen3-4B-Instruct-2507 launch line train_captioner.py qwen3_4b_instruct; init_path .../qwen3-4b-instruct.pt
4B scratch rope_theta 1e6 5e6 Instruct-2507's own rope_theta is 5e6
rope_full_precision false true model.llm.rope_full_precision: true in both configs
FSDP param_dtype bf16 fp32 fsdp.precision: float → fp32 params/grads/buffers, bf16 only via amp_bf16 autocast
seeds 12536 / 34521 6198 / 95818 seed / data.seed

The RoPE-base question is now properly resolved. Qwen3-4B-Instruct-2507 has rope_theta=5e6
(base Qwen3-4B has 1e6), so the released Molmo2-4B's 5e6 comes from its backbone, not from a
Molmo2-side long-context change as #818 assumed. The 8B confirms it from the other direction: it
ran train_captioner.py qwen3_8b — the base backbone, theta 1e6, untied. Different backbones,
not a Molmo2 quirk. The 8B settings are unchanged.

The 4B tokenizer switch is safe for the data pipeline: Instruct-2507 is identical to Molmo2's for
everything used — BPE (encode matches on ASCII, unicode, emoji and pointing markup),
eos_token_id 151645, and the user-turn chat template.

Confirmed already correct (no change)

max_duration: 32000 — I had flagged this as needing to be 31,000; the released run really is
32,000 and its checkpoint directory is step32000. Mixture rates 0.6 / 0.3 / 0.1.
loss_token_weighting: null, which independently validates the "none" change in the first
commit. ft_embedding: lm_head; ft_vit/ft_llm/ft_connector all true;
global_train_batch_size: 128; every per-component LR, warmup, beta, eps and weight decay;
alpha_f 0.1; z-loss 1e-4; grad clip 1.0; batch_divisor: global_batch; max_crops: 8.

Correction to an earlier recommendation: response_logits_only: false in the released config.
I had proposed enabling it as a "free memory win" based on train_captioner.py; the run that
produced the released model did not use it, so our False already matches. That item comes off
the follow-up list.

Also in this PR (first commit)

  • loss_token_weighting: "root_subsegments" → "none". Verified with build_branched_sequence:
    a 2-branch example weights 0.707107 (= 1/√2) before and 1.0 after, while a single-branch example
    is 1.0 either way — confirming the divergence was purely cross-example re-weighting between
    caption / pointing / NLP.
  • Global batch 8 → 128 sequences. This also fixes a real footgun: the old global of 8 failed the
    global % (microbatch x dp_world_size) == 0 check at 16 GPUs, which is what killed the first
    16-GPU launch of this script ~30 s after it logged Training for 32,000 steps. 128 divides
    8/16/32/64.

Verification

  • 30/30 field-by-field match against the released YAML.
  • 249 passed / 17 skipped across src/test/nn/vision, src/test/data/multimodal and
    src/test/nn/embedding_test.py.
  • Real-weight Molmo2-4B parity on GPU — logits, LM forward, embedding and training-logits: 5 passed.
    rope_full_precision=True is a no-op there (the parity path is fp32) and parity is unchanged.
  • Native-config-vs-HF-derived equality test still passes, since rope_full_precision was set on
    both paths.
  • isort/black clean on the changed files; ruff and mypy at the vision baseline (the F841 in
    molmo2_loader.py and the 21 mypy errors are pre-existing).

Still divergent, needing more than a constant

Rough priority order: activation_checkpointing: true (LM whole_layer) together with
device_train_microbatch_size: 4; packing dynamic_solver buffer 48 with image_weight: 1.0
(we use token-only next-fit, and the ported knapsack defaults to 30.0); float32_attention: true
for LM and ViT; multi_component_grad_norm: true; pointing_format: html-v1 (we emit html-v2);
response_residual_dropout: 0.1; compile covering ViT and connector as well as the LM;
enable_variable_sized_token_pooling: true.

…r loss

Two recipe settings that kept a default run from being an mm_olmo stage-1
reproduction.

loss_token_weighting: "root_subsegments" -> "none"

mm_olmo's captioner leaves `Molmo2PreprocessorConfig.loss_token_weighting` at its
"none" default (`MessageWeight()`, no scaling), so every response token is weighted
equally. We were scaling each branch by 1/sqrt(n_branches). Both sides normalise
the loss as sum(CE*w)/sum(w) over the global batch, so a *uniform* rescale cancels
— but it does not cancel when branch counts differ between examples, which is the
normal case in this mixture: PixMoCap yields 2 branches (caption + transcript) but
1 when an example has no transcripts, and pointing/Tulu examples vary again. The
net effect was re-weighting caption vs pointing vs NLP relative to mm_olmo.

Verified with build_branched_sequence: a 2-branch example gives weights 0.707107
(= 1/sqrt(2)) under root_subsegments and 1.0 under none, while a single-branch
example gives 1.0 under both — confirming the difference is purely the
cross-example one described above. `root_subsegments` remains available (mm_olmo
itself uses root_subsegments_root_tokens in its SFT/video scripts).

Batch: seq_len 4096 -> 2536, global 8 -> 128 sequences

Now exactly mm_olmo's `--seq_len 2536` and `global_train_batch_size=128`, i.e.
324,608 tokens/step instead of 32,768. The old default was smoke-sized: the
earlier head-to-head runs only reached parity by passing
`--global_batch_size=324608` and editing SEQUENCE_LENGTH at every launch.

This also removes a real footgun. `global % (microbatch x dp_world_size) == 0` is
enforced, and the old global of 8 sequences failed it at 16 GPUs — that is exactly
what killed the first 16-GPU launch of this script, ~30s after it logged "Training
for 32,000 steps". 128 divides every world size we use: 8/16/32/64 give 16/8/4/2
grad-accum steps per rank.

`device_train_microbatch_size` stays 1 where mm_olmo uses 4. That is purely a
memory/throughput knob — gradient accumulation makes the two mathematically
identical at the same global batch — and microbatch >1 at this sequence length
OOM'd previously without activation checkpointing, which is still an open
follow-up (`ac_config`). Left deliberately, not overlooked.

Verified: 249 passed / 17 skipped across src/test/nn/vision, src/test/data/multimodal
and src/test/nn/embedding_test.py; divisibility OK for world sizes 1-64;
isort/black/mypy clean.

Not changed: MAX_STEPS stays 32,000 where mm_olmo's pointing+nlp path uses 31,000
(and 4 epochs = 22,344 caption-only). At the new batch that is 10.39B tokens vs
mm_olmo's 10.06B — a 3% difference, called out here rather than changed since the
ask was the batch defaults.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8582d21017

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

# response token is weighted equally. `root_subsegments` (1/sqrt(n_branches)) does not
# cancel out of the global `sum(CE*w)/sum(w)` divisor when branch counts differ across
# examples, so it would re-weight caption vs pointing vs NLP relative to mm_olmo.
loss_token_weighting="none",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid rescaling truncated unweighted examples

When loss_token_weighting="none" is used here, two-branch caption/transcript examples still carry subsegment_ids, and PixMoCapDataset._truncate() unconditionally multiplies loss_masks by sqrt(n_before / n_after) if truncation drops a branch. With the new shorter SEQUENCE_LENGTH=2536, any long example whose tail is truncated enough to remove one branch will therefore get surviving response tokens weighted above 1.0, so the run is not actually the unweighted mm_olmo loss this setting is meant to reproduce.

Useful? React with 👍 / 👎.

Re-audited stage 1 against the config the released model was actually trained
with, at /weka/oe-training-default/mm-olmo/released-models-molmo2-1225/
Molmo2-4B-Pretrain/config.yaml (its `runtime_data.args` records the exact launch
command). That config supersedes the argparse defaults in train_captioner.py,
which I had been reading as ground truth, and it corrects four things.

* seq_len 2536 -> 2560. The released runs passed `--seq_len=2560` explicitly,
  overriding the 2536 argparse default; `data.sequence_length: 2560` in both the 4B
  and 8B configs. (The stale comment this script used to carry, "mm_olmo stage 1
  uses ~5248", matched neither.)

* The 4B backbone is the *instruct* model. The launch line is
  `train_captioner.py qwen3_4b_instruct`, and the config's llm.tokenizer is
  `Qwen/Qwen3-4B-Instruct-2507` with `init_path .../qwen3-4b-instruct.pt`. We were
  initialising from base Qwen/Qwen3-4B.

* Which resolves the RoPE-base question properly. Qwen3-4B-Instruct-2507 has
  rope_theta 5e6 (base Qwen3-4B has 1e6), so the released Molmo2-4B's 5e6 comes
  from its backbone, not from a Molmo2-side long-context change as I previously
  assumed. `scratch_rope_theta` for the 4B therefore becomes 5e6, matching
  `molmo2_rope_theta`. The 8B is unchanged and confirms the pattern from the other
  direction: it ran `train_captioner.py qwen3_8b` — the *base* backbone, theta 1e6,
  untied. Different backbones, not a Molmo2 quirk.

* rope_full_precision: both released configs set it true; our factories defaulted
  to false. Set on the native factories and on the HF-derived path so the two stay
  identical (the equality test still passes, and it is a no-op for the fp32 parity
  tests, which still pass).

Also matched, since they were free: `fsdp.precision: float` -> FSDP param_dtype
float32 (fp32 params/grads/buffers, bf16 only via the amp autocast) where we had
bf16 params; and the seeds, `seed: 6198` / `data.seed: 95818`.

Confirmed already correct, so no change: max_duration 32000 (I had wrongly flagged
this as needing to be 31000 — the released run really is 32000, and the checkpoint
directory is `step32000`); mixture rates 0.6/0.3/0.1; `loss_token_weighting: null`,
which validates the "none" change in the previous commit; `ft_embedding: lm_head`;
ft_vit/ft_llm/ft_connector all true; global_train_batch_size 128; per-component
LRs, warmups, betas, eps, weight decays; alpha_f 0.1; z-loss 1e-4; grad clip 1.0;
batch_divisor global_batch; max_crops 8.

And one correction to an earlier claim: `response_logits_only: false` in the
released config. I had recommended enabling it as a "free memory win" on the basis
of train_captioner.py; the run that produced the released model did not use it, so
our False already matches.

Verified: 30/30 settings match in a field-by-field diff against the YAML;
249 passed / 17 skipped in src/test/nn/vision + src/test/data/multimodal +
embedding_test; real-weight Molmo2-4B parity (logits, LM forward, embedding,
training-logits) 5 passed on GPU; isort/black clean on the changed files; ruff and
mypy at the `vision` baseline (the F841 in molmo2_loader.py and the 21 mypy errors
are pre-existing).

Still divergent from the released config, needing more than a constant, in rough
priority order: activation_checkpointing true (LM whole_layer) with
device_train_microbatch_size 4; packing `dynamic_solver` buffer 48 with
image_weight 1.0 (we use token-only next-fit); float32_attention true for LM and
ViT; multi_component_grad_norm true; pointing_format html-v1 (we emit html-v2);
response_residual_dropout 0.1; compile covering ViT and connector as well as the
LM; enable_variable_sized_token_pooling true.
@jason718 jason718 changed the title Molmo2-Stage1: match mm_olmo's batch defaults and unweighted captioner loss Molmo2-Stage1: align with the released Molmo2-4B-Pretrain config Aug 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a9a8b6337

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

SCRATCH_VIT_ID = "google/siglip2-so400m-patch14-384" # shared by every Molmo2 variant
NEW_EMBEDDING_INIT_STD = 0.02 # mm_olmo `new_embedding_init_range`
SEQUENCE_LENGTH = 4096 # fixed pad length; mm_olmo's captioner default is 2536
SEQUENCE_LENGTH = 2560 # fixed pad length; the released runs passed `--seq_len=2560`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pass the shorter cap to NLP sources

Lowering the batch pad length here without threading the same limit into the default NLP mixture leaves Tulu4DatasetConfig() at its 4096-token truncation cap in _build_mixture_sources. When NLP_RATE is positive (the default), Tulu conversations between 2561 and 4096 tokens still get returned, and MultimodalCollator then silently tail-cuts them to 2560; for rows with a long first user message this can drop all assistant loss tokens, bypassing Tulu's own “removed all loss tokens” skip check and training on zero/partial-loss NLP samples. Please pass max_sequence_length=SEQUENCE_LENGTH into the Tulu source (and any other mixture source that can exceed the pad length) so truncation happens with the dataset's loss-token validation.

Useful? React with 👍 / 👎.

@jason718
jason718 merged commit 0593f89 into allenai:vision Aug 14, 2026
1 check passed
@jason718
jason718 deleted the jasonr/stage1-mmolmo-batch-defaults branch August 14, 2026 00:20
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