Skip to content

Molmo2-Stage1: pretrain from base Qwen3 + SigLIP2, and add the 8B variant - #818

Merged
jason718 merged 3 commits into
allenai:visionfrom
jason718:jasonr/stage1-scratch-init
Aug 12, 2026
Merged

jason718 merged 3 commits into
allenai:visionfrom
jason718:jasonr/stage1-scratch-init

Conversation

@jason718

@jason718 jason718 commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Stage 1 is pretraining, but Molmo2-Stage1.py started from the released
allenai/Molmo2-4B — an already post-trained model — and continued it on the stage-1
objective. That is a fine-tune, not a stage-1 reproduction. The most recent 32k-step run
opened at CE ~1.15; mm_olmo's true stage-1 start is ~3.1.

init_from now defaults to "scratch", reproducing mm_olmo's
reset_with_pretrained_weights, and a scratch run reads nothing from the released
Molmo2 repo — not weights, not the config, not the tokenizer.

Component Source
LM the base Qwen3 backbone via the generic HF→olmo-core converter; 128 extra embedding rows N(0, 0.02)
ViT base google/siglip2-so400m-patch14-384, blocks 0..24 of 27 (matches vit_layers=[24, 18]) — shared by every variant
Connector random — reset_parameters(): N(0, 0.02) weights, zero biases
Architecture MultimodalLMConfig.molmo2_4B() / molmo2_8B(), built natively
Tokenizer the base Qwen3 backbone's

--init_from=molmo2 keeps the previous behaviour for parity tests and continuation
experiments.

Both sizes: --model_size=4b|8b

An 8B stage-1 run is planned, so molmo2_8B lands with the plumbing that uses it rather
than as an unused public API. --model_size selects the architecture factory, the base
Qwen3 backbone, the released checkpoint for --init_from=molmo2, and the tokenizer.
MODEL_SIZES maps each size to a typed frozen ModelSizeSpec (a plain dict of mixed values
inferred object and cost 3 mypy errors). ExperimentConfig.model_id is replaced by
model_size.

Both factories share a _molmo2_like helper: the vision stack is identical across released
variants, so only the LM and the connector MLP width differ.

4B 8B
d_model / FFN 2560 / 9728 4096 / 12288
tie_word_embeddings True False
released rope_theta 5e6 1e6
base Qwen3 rope_theta 1e6 1e6

The 8B path exposed a second real bug

The from-scratch init unconditionally overwrote lm_head.w_out.weight with the embedding
table. That is correct for a weight-tied backbone, but Qwen3-8B and Molmo2-8B are untied
and the converter emits a distinct trained output head for them — so an 8B run would have
thrown away Qwen3-8B's trained lm_head. The head is now built per tying: tied configs reuse
the embedding table (then retie), untied ones keep the base head and pad the 128 extra rows
with zeros. Those rows are masked by output_vocab_size, so they never enter the softmax or
receive gradient — matching mm_olmo, whose untied ff_out spans only the base vocab.

Verified both ways: 8B head[:151936] equals the base trained lm_head and differs from
the embedding rows; 4B stays tied and shares storage; appended 8B head rows are all zero.

A wrong RoPE base, caused by reading the released config

Deriving the architecture from the released model while loading base weights put those
weights on the wrong rotary base:

rope_theta
Released Molmo2-4B text config 5,000,000
Base Qwen3-4B (what scratch loads) 1,000,000
mm_olmo stage-1 QWEN3_4B 1,000,000

RoPE base now follows the weight source, per size. The 8B independently confirms why
this matters: base Qwen3-8B and released Molmo2-8B are both 1e6, so the released Molmo2-4B
(5e6) is the sole variant that disagrees with its own backbone.

model_size and init_from are resolved from the raw overrides before the model config is
built, because that happens before Config.merge runs — otherwise --model_size=8b or
--init_from=molmo2 would silently keep the defaults' architecture and theta.

Native architecture factories

Composed from factories the repo already had: TransformerConfig.qwen3_4B / qwen3_8B +
VisionEncoderConfig.siglip2_so400m_patch14_378 (truncated to 25 blocks) + the connector.
A cache-gated test asserts each is field-for-field identical to
molmo2_config_from_hf_config on the corresponding released config, so they stay
interchangeable.

Note the HF loader labels the ViT siglip, not siglip2; that field is a label only (the
variant is selected by use_cls_token / patch_embedding_bias / use_pre_ln), so the
factory matches it for exact equality.

Tokenizer: verified drop-in, not assumed

For training, base Qwen3-4B's tokenizer is equivalent to Molmo2's:

  • encode identical on ASCII, unicode, emoji and the pointing markup
  • eos_token_id identical (151645)
  • byte-identical output for the only chat-template calls the data pipeline makes
    (user turn + generation prompt, data/multimodal/qwen3_layout.py)

Qwen3's template does differ — it injects <think>\n\n</think> — but only for
assistant messages, which that pipeline never passes. Worth knowing for anyone who adds
an assistant-message call later. Image-special token IDs come from molmo2_tokens.py
constants, not the tokenizer, so their absence from the base vocab does not affect training
(they are unmapped when decoding, which only matters for debugging).

One SigLIP converter, not two

There was no production SigLIP converter: the only one lived in parity_test.py, and the
from-scratch port copied it into the training script. Promoted to
olmo_core.nn.vision.siglip_state_dict_to_vision_encoder with n_blocks and prefix
arguments — covering both call sites (bare encoder for the parity test; prefixed and
truncated for the MultimodalLM load) — and both copies deleted. It also strips a
vision_model. prefix so it accepts SiglipVisionModel state dicts directly, and raises
if more blocks are requested than the checkpoint has.

(molmo2_hf_state_dict_to_multimodal_lm exists but converts from Molmo2's own HF format,
not a raw SigLIP tower, so it could not serve this path.)

The tied head was not actually tied (bug in the ported code)

544c7eae5 wrote full_emb.clone() into lm_head.w_out.weight, so values matched at init
but to_empty had already untied the parameters — head and embedding table were two
independent tensors that would drift apart during training, while mm_olmo has
weight_tying=True (and Transformer.apply_fsdp's tied-weight handling assumes one
parameter). The molmo2 path already called retie_word_embeddings; the scratch path did
not. Caught by comparing data_ptr():

before:  tied values: True   shared storage: False
after:   tied values: True   shared storage: True   same Parameter object: True

Also: make checks was already red on this file

The mid-file PIXMO_DATASETS import added in #806 trips ruff E402, and isort/black
were failing too (the Makefile checks run over the whole tree). Import moved to the top and
the file formatted, since this PR touches it anyway.

Verification

  • src/test/nn/vision: 97 passed, 17 skipped. The 3 CLIP/SigLIP/SigLIP2 parity tests
    now exercise the shared converter.
  • Both native configs identical to their HF-derived counterparts (cache-gated test pins
    4B and 8B).
  • 8B scratch init exercised end-to-end — real SigLIP2 weights, and Qwen3-8B stood up from
    its real config so the converter and the strict coverage check run for real: 8.662B params,
    vocab (152064, 4096), new rows std 0.0200, correctly untied, 25 vision blocks,
    0 non-finite.
  • Size/init matrix: 4b scratch 1e6 / 4b molmo2 5e6 / 8b both 1e6. --model_size=8B
    case-normalises; 13b rejected at config-build time.
  • Scratch init run end-to-end on CPU against the real architecture: state-dict coverage
    exact (only connector.* missing, nothing unexpected), 4.462B params, vocab
    (152064, 2560), 128 new rows at std 0.0200 (target 0.02) with base rows at 0.0220,
    25 vision blocks with blocks.0.attn.wq std 0.02654 (loaded SigLIP weights, not
    random), 0 non-finite tensors, head and embeddings one shared Parameter.
  • scratch theta 1e6 / molmo2 theta 5e6; --init_from=bogus rejected at config-build
    time rather than after a Beaker job has queued, started and downloaded weights.
  • isort / black / ruff clean. mypy introduces no new errors — the 2 it reports in
    this script are present on vision under the same invocation.

Not changed — worth a reviewer's opinion

The ViT remains frozen (freeze_params=["vision.*"]), so this trains a randomly initialised
connector against a base SigLIP2 encoder that never updates. mm_olmo trains the ViT
during stage 1 (ft_vit=True, lr 6e-6, warmup 2000, wd 0). Frozen-ViT was defensible when
the encoder came from a trained Molmo2; with base SigLIP2 it is a more consequential choice.
Deliberately left out to keep this PR to the init change — the TRAIN_VIT flag on
jasonr/molmo2-infra-compare is the follow-up.

…sed Molmo2-4B

Stage 1 is pretraining, but the script only had the HF-Molmo2 load path, so it
started from the released allenai/Molmo2-4B -- an already post-trained model --
and continued it on the stage-1 objective. That is a fine-tune, not a stage-1
reproduction: initial CE was ~1.15 where mm_olmo's true stage-1 start is ~3.1.

`init_from` now defaults to "scratch", reproducing mm_olmo's
`reset_with_pretrained_weights`: the LM from base Qwen/Qwen3-4B via the generic
HF converter (128 extra embedding rows N(0, 0.02), head tied), the ViT from base
google/siglip2-so400m-patch14-384 via the parity-verified SigLIP mapping (blocks
0..24 of 27, matching vit_layers=[24, 18]), and a randomly-initialised connector
(N(0, 0.02) weights, zero biases). `--init_from=molmo2` keeps the old behaviour
for parity tests and continuation experiments.

Ported from 544c7ea on jasonr/molmo2-infra-compare, with three fixes:

* Call `retie_word_embeddings` after loading. `to_empty` unties tied word
  embeddings, so the head and the embedding table were left as two independent
  parameters that would drift apart during training; mm_olmo has
  weight_tying=True. The molmo2 path already did this. Verified: the two are now
  the same Parameter object sharing storage.
* Validate `init_from` in `build_config` instead of only in `train`, so a typo
  fails locally rather than after a Beaker job has queued, started and
  downloaded weights.
* Move the mid-file `PIXMO_DATASETS` import to the top. It was tripping ruff
  E402, and isort/black were also failing on this file, so `make checks` was red
  on `vision` before this change.

Verified on CPU against the real Molmo2-4B architecture: state-dict coverage
exact (only connector keys missing, nothing unexpected), 4.462B params, vocab
(152064, 2560) with the 128 new rows at std 0.0200 and base rows at 0.0220,
25 vision blocks with loaded (non-random) SigLIP weights, no non-finite values,
head and embeddings tied to one Parameter. isort/black/ruff/mypy all clean.

@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: d1fce637c6

ℹ️ 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".

# instead *continues* the released (already post-trained) Molmo2-4B on the stage-1
# objective — that is a fine-tune, not stage-1 pretraining, so it is opt-in only
# (`--init_from=molmo2`), kept for parity tests and continuation experiments.
INIT_FROM = "scratch"

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 Unfreeze the base ViT for scratch init

With INIT_FROM now defaulting to "scratch", the script loads the base SigLIP2 vision tower but still uses the existing freeze_params=["vision.*"] training config, so default stage-1 runs train a random connector against a fixed base ViT. For the intended mm_olmo stage-1 reproduction this materially changes optimization/convergence because the ViT never receives its stage-1 updates; make the scratch path train vision.* (with its own LR/scheduler) or keep freezing only for the molmo2 continuation path.

Useful? React with 👍 / 👎.

…IP converter

Two things a from-scratch stage-1 run should not need, and a bug the first one was
causing.

1. No HF read for the architecture or tokenizer.

`_build_model_config` read `AutoConfig.from_pretrained("allenai/Molmo2-4B",
trust_remote_code=True)`, so a run that trains from base checkpoints still
depended on the released post-trained repo (and on its remote code, which is
already transformers-5.x bitrotten). Added `MultimodalLMConfig.molmo2_4B()`,
which builds the same architecture natively from `TransformerConfig.qwen3_4B` +
`VisionEncoderConfig.siglip2_so400m_patch14_378` (truncated to 25 blocks) + the
connector. A cache-gated test asserts it is field-for-field identical to
`molmo2_config_from_hf_config` on the released config.

The tokenizer for `--init_from=scratch` is now base `Qwen/Qwen3-4B` — what
mm_olmo's stage 1 uses. Verified a drop-in for training: identical BPE (`encode`
matches on ASCII, unicode, emoji and the pointing markup), identical
`eos_token_id` 151645, and byte-identical output for the only chat-template calls
the data pipeline makes (user turn + generation prompt, `qwen3_layout.py`).
Qwen3's template differs only for assistant messages, which that pipeline never
passes. Image-special token IDs come from `molmo2_tokens.py`, not the tokenizer.

This surfaced a real bug: RoPE base. The released Molmo2-4B uses theta 5e6, but
base Qwen3-4B — whose weights the scratch path loads — was trained with 1e6, and
mm_olmo's stage-1 QWEN3_4B config also uses 1e6. Deriving the architecture from
the released config while loading base weights put those weights on the wrong
rotary base. `_build_model_config` now selects theta by init mode.

`init_from` is resolved from the raw overrides before the model config is built,
since the config is constructed before `Config.merge` runs — otherwise
`--init_from=molmo2` would have silently kept scratch's theta.

2. One SigLIP converter, not two.

The from-scratch port had copied the SigLIP state-dict mapping into the training
script, duplicating `_convert_siglip_state_dict` in `parity_test.py`. Promoted it
to `olmo_core.nn.vision.siglip_state_dict_to_vision_encoder` with `n_blocks` and
`prefix` arguments (covering both call sites: the bare-encoder test and the
prefixed, truncated `MultimodalLM` load), and deleted both copies. It also now
strips a `vision_model.` prefix, so it accepts `SiglipVisionModel` state dicts
directly, and raises if more blocks are requested than the checkpoint has.

Verified: 95 passed / 17 skipped in src/test/nn/vision (the 3 CLIP/SigLIP/SigLIP2
parity tests now exercise the shared converter); native config identical to the
HF-derived one; scratch init still covers the state dict exactly with head and
embeddings tied to one Parameter, 128 new rows at std 0.0200, 25 vision blocks
with loaded SigLIP weights, 0 non-finite; scratch theta 1e6 and molmo2 theta 5e6.
isort/black/ruff clean; mypy introduces no new errors (the 2 it reports in this
script are present on `vision` under the same invocation).

@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: 70f9f18486

ℹ️ 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".

Comment thread src/scripts/train/Molmo2-Stage1.py Outdated
Comment on lines +213 to +214
key, _, value = override.lstrip("-").partition("=")
if key == "init_from" and value:

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 Normalize init_from overrides before choosing RoPE

When callers use the hyphenated form --init-from=molmo2, Config.merge will later normalize it to init_from and set config.init_from == "molmo2", but this pre-merge scan misses it because it only strips leading dashes and never replaces - with _. That builds the model with the scratch RoPE base (1_000_000) while train() still loads the released Molmo2 weights, which expect 5_000_000; normalize with the same rules as config overrides before selecting the model config.

Useful? React with 👍 / 👎.

An 8B stage-1 run is planned, so `molmo2_8B` lands together with the script
plumbing that uses it rather than as an unused public API.

`MultimodalLMConfig.molmo2_8B()` joins `molmo2_4B()`, both built on a shared
`_molmo2_like` helper — the vision stack (SigLIP2-SO400M/14-378 truncated to 25
blocks, vit_layers (24, 18), 2-layer attention-pooling connector) is identical
across released variants, so only the LM and the connector's MLP width differ.
The cache-gated equality test now runs over both variants.

`--model_size=8b` selects the architecture factory, the base Qwen3 backbone to
initialise from, the released checkpoint for `--init_from=molmo2`, and the
tokenizer. `MODEL_SIZES` maps each size to a typed frozen `ModelSizeSpec` rather
than a dict of mixed values (a plain dict inferred `object` and cost 3 mypy
errors). `model_id` on `ExperimentConfig` is replaced by `model_size`.

Fixes a real bug the 8B path exposed: the from-scratch init unconditionally
overwrote `lm_head.w_out.weight` with the embedding table. That is right for a
weight-tied backbone, but Qwen3-8B and Molmo2-8B are untied, and the converter
emits a *distinct trained* output head for them — so an 8B run would have
discarded Qwen3-8B's trained lm_head. The head is now built per tying: tied
configs reuse the embedding table (as before, then retied), untied ones keep the
base head and pad the 128 extra rows with zeros. Those rows are masked by
`output_vocab_size`, so they never enter the softmax or receive gradient, which
matches mm_olmo, whose untied `ff_out` spans only the base vocab.

RoPE base follows the weight source, and 8B confirms why that matters: base
Qwen3-8B *and* released Molmo2-8B are both 1e6; the released Molmo2-4B (5e6) is
the sole variant that disagrees with its backbone.

Verified:
- 97 passed / 17 skipped in src/test/nn/vision.
- Both factories byte-identical to `molmo2_config_from_hf_config` on the released
  4B and 8B configs.
- 8B scratch init exercised end-to-end (real SigLIP2 weights, Qwen3-8B stood up
  from its real config so the converter and strict coverage check run for real):
  8.662B params, vocab (152064, 4096), new rows std 0.0200, correctly untied,
  25 vision blocks, 0 non-finite.
- Head init checked both ways: 8B head[:151936] equals the base trained lm_head
  and differs from the embedding rows; 4B stays tied and shares storage;
  appended 8B head rows are all zero.
- Size/init matrix: 4b scratch 1e6 / 4b molmo2 5e6 / 8b both 1e6; d_model
  2560/4096, ffn 9728/12288, connector out+mlp track the LM.
- `--model_size=8B` case-normalises; `13b` and `--init_from=bogus` rejected at
  config-build time. isort/black/ruff clean; mypy back to the 21-error `vision`
  baseline (no new errors).
@jason718 jason718 changed the title Molmo2-Stage1: initialise from base Qwen3-4B + SigLIP2, not the released Molmo2-4B Molmo2-Stage1: pretrain from base Qwen3 + SigLIP2, and add the 8B variant Aug 12, 2026
@jason718
jason718 merged commit eb4c85e into allenai:vision Aug 12, 2026
1 check passed
@jason718
jason718 deleted the jasonr/stage1-scratch-init branch August 12, 2026 17:53
jason718 added a commit that referenced this pull request Aug 12, 2026
…it parity) (#820)

mm_olmo's captioner sets `ft_connector` / `ft_vit` / `ft_llm` all true
and gives the ViT its
own optimizer group, 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. It overrides
only the learning rate, inheriting `betas=(0.9, 0.95)`, `eps=1e-6` and
`weight_decay=0.0`
from 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 redundant
overrides.

| Group | LR | Warmup | betas / eps / wd |
|---|---|---|---|
| `connector.*` | 2e-4 | 200 | (0.9, 0.95) / 1e-6 / 0.0 |
| `vision.*` | **6e-6** | **2000** | (0.9, 0.95) / 1e-6 / 0.0 |
| LM (default) | 2e-5 | 2000 | (0.9, 0.95) / 1e-6 / 0.0 |

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=false` restores the frozen two-group setup, including
putting the encoder back in
**eval** mode: the train module keys that off `freeze_params`, so the
empty list is what keeps
it in train mode.

Ported from `de031c61f` 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 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`:

```
  step |   connector      vision          LM
     1 |   1.000e-06   3.000e-09   1.000e-08
   200 |   2.000e-04   6.000e-07   2.000e-06   <- connector peaks
  2000 |   1.986e-04   6.000e-06   2.000e-05   <- ViT + LM peak
 32000 |   2.000e-05   6.000e-07   2.000e-06   <- all at 0.1x
```

**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-`-1` pooled) **all 51 vision params still receive finite gradients**
via the existing
`h + 0.0 * image_features.sum()` tie. That tie was added for the
connector; it covers the ViT
too, since the gradient path runs vision → connector → `image_features`.

`--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. 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

| | 4B | 8B |
|---|---|---|
| Trainable params | 4.079B → **4.462B** (+9.4%) | 8.280B → **8.662B**
(+4.6%) |
| Extra AdamW state (2 × fp32) | +2.85 GiB | +2.85 GiB |
| Extra gradients | +1.42 GiB | +1.42 GiB |

Plus ViT backward activations for the 382.5M-param encoder.
`vision_activation_checkpointing` already defaults to `True` in the
train module and now
actually 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=true` and an
LM `ac_config` stop
being optional — both still open follow-ups from the mm_olmo comparison.

Co-authored-by: Jason Ren <[email protected]>
jason718 added a commit that referenced this pull request Aug 14, 2026
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`.

---------

Co-authored-by: Jason Ren <[email protected]>
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