Repository navigation
[Multimodal 9] Still-changing mixed mid-training (from #916) - #939
Merged
jason718 merged 1 commit intoNov 11, 2026
Merged
Conversation
This was referenced Oct 26, 2026
12 of 13 tasks
jason718
force-pushed
the
jasonr/molmo2-mixed-midtraining
branch
from
October 28, 2026 23:35
f90d1f7 to
cae0c28
Compare
jason718
force-pushed
the
jasonr/molmo2-mixed-midtraining-wip
branch
from
October 28, 2026 23:35
5ec24da to
b028637
Compare
jason718
force-pushed
the
jasonr/molmo2-mixed-midtraining
branch
from
October 28, 2026 23:36
cae0c28 to
eac4fad
Compare
jason718
force-pushed
the
jasonr/molmo2-mixed-midtraining-wip
branch
from
October 28, 2026 23:36
b028637 to
819cb83
Compare
jason718
force-pushed
the
jasonr/molmo2-mixed-midtraining
branch
from
October 30, 2026 02:56
eac4fad to
0cb3c7f
Compare
jason718
force-pushed
the
jasonr/molmo2-mixed-midtraining-wip
branch
from
October 30, 2026 02:56
819cb83 to
779f29b
Compare
jason718
force-pushed
the
jasonr/molmo2-mixed-midtraining
branch
from
November 8, 2026 00:31
0cb3c7f to
a8fb914
Compare
jason718
force-pushed
the
jasonr/molmo2-mixed-midtraining-wip
branch
from
November 8, 2026 00:31
779f29b to
e7c127b
Compare
jason718
added a commit
that referenced
this pull request
Nov 10, 2026
…1.py (#913) ## Summary PR 4 of 7 for moving the Molmo2 stage-1 reproduction from the long-lived `vision` branch onto `main`. #910 (model), #911 (train module) and #912 (data core) are merged; this PR adds the **stage-1 recipe** that makes them runnable end to end: the datasets, the mixtures, and `Molmo2-Stage1.py`. About 6.7k source lines and 4.8k test lines. It also restores one fix needed for the recipe to train correctly: activation-checkpoint RNG replay (see "Why the RNG fix is here"). Almost all of it is new files; the only existing files touched are listed under "Read closely" below. ## Review map Reading every file closely is not necessary. Here is where attention pays off. ### Read closely (about 1.9k lines) | File | Lines | What to check | |---|---|---| | `scripts/train/Molmo2-Stage1.py` | 1537 | The recipe itself: the `v1` / `v2` / `v3` mixture rates, step counts, optimizer groups and learning rates, the `--init_from` paths, and the launch settings. This is where a wrong constant changes the training run silently. | | `train/callbacks/unsharded_export.py` | 128 | Writes `model.safetensors` and a config copy into each permanent checkpoint from a background op on rank 0; skips ephemeral checkpoints. Moved here from #911 because the stage-1 script is its only user. | | `distributed/checkpoint/__init__.py` | +30 | `load_unsharded_model_state()`: the only change to a shared distributed module. Additive. | | `nn/transformer/model.py` (+`ac_rng_test.py`) | +24 / -4 | Activation checkpointing now preserves the RNG state when dropout is active (`masked_dropout`, `ResidualStream` dropout, `nn.Dropout`), so the recomputed forward replays the original dropout masks. Required by this recipe; see below. | | `data/multimodal/__init__.py`, `sequence_builder.py` | +92 / +4 | Exports, and a type annotation on `build_branched_sequence` that already accepted multi-turn branches. No behaviour change. | ### Skim for the shared pattern (about 4.9k lines of dataset code) These are adapters. Each one defines a config dataclass and a map-style dataset, formats its rows into the stage-1 prompt family, builds the sequence with the #912 builders, and truncates with `truncate_example`. Seven of them (`academic_dataset`, `gui_syn`, `ocr_caption_tars`, `olmocr`, `pixmo_points_v2`, `synthetic_ocr`, `text_rich_caption`) use the `EpochSeededExamples` mixin from #912 for epoch-aware sampling; the others do not sample per epoch. If one is right, the rest are variations. | Group | Files | |---|---| | Pointing and counting | `pixmo_points.py` (433), `pixmo_points_v2.py` (579), `gui_syn.py` (243), `detect_counting_question.py` (82) | | OCR | `olmocr.py` (328), `ocr_caption_tars.py` (366), `synthetic_ocr.py` (384), `text_rich_caption.py` (200), `mixtures/ocr.py` (245) | | Academic QA | `academic/registry.py` (611), `academic_dataset.py` (179), `academic/formatters.py` (102), `mixtures/stage1_academic.py` (149) | | Other sources | `pixmo_clocks.py` (145), `pixmo_cap_qa.py` (104), `pixmo_ama.py` (96), `tulu.py` (173), `finevision.py` (249), `mmfinereason.py` (218) | ### Tests (about 4.8k lines) They mirror the modules above (one test file per dataset group), plus `molmo2_training_logits_parity_test.py` (GPU, needs the HF checkpoint) and the callback and distributed-checkpoint tests. A test that needs Weka data skips when the data is absent. ### Invariants the design relies on (worth a spot check) These are stated in the script's docstring and should hold across every file: - Every default source is a **train split only**; the training set of a benchmark the stage-2 checkpoints are evaluated on is never a stage-1 source. - OCR and academic sources use a **style tag as the whole user turn**, with no question text. - Data lives on Weka, so datasets read paths from `paths.py` (#912) and nothing here needs S3 or GCS secrets. - Mixture rates per recipe are as in the script's docstring: `v1` caption 0.6 / pointing and counting 0.3 / text 0.1; `v2` caption 0.5 / pointing 0.25 / OCR 0.25; `v3` caption 0.33 / pointing 0.16 / OCR 0.34 / academic 0.14 / clocks 0.03. ## Series | # | PR | Status | |---|---|---| | 1/7 | #910 Model: HF Molmo2 loader, flex attention, split-vocab embedding | merged | | 2/7 | #911 Train module, `PerGroupScheduler`, weighted CE | merged | | 3/7 | #912 Data core | merged | | 4/7 | #913 Stage-1 recipe **(this PR)** | review | | 5/7 | #934 Data infrastructure, stage-2 recipe, Qwen3-0.6B / 1.7B sizes | draft, stacked on this PR | | 6/7 | #936 OLMo 3.5 alignment training: OLMoDDP hooks and train module, optimizer, callbacks, alignment pipeline | draft | | 7/7 | #937 In-repo evaluation suites and remaining tools | draft | | 8 | #938 Stable mixed mid-training (from #916) | draft | | 9 | #939 Still-changing mixed mid-training (from #916) | draft | PRs 5 to 7 bring the rest of `vision` onto `main`, so that `main` can do everything `vision` can. Separate: activation-checkpoint RNG replay for `ResidualStream.masked_dropout` is already in this PR; #906 (open) will need a rebase on it. ## Why this is a separate PR - It is the bulk of the series, but the review is mostly pattern-checking, and it is the only part that depends on external data locations and recipe choices. - It can be iterated (new datasets, recipe tweaks) without touching any core API from #910 to #912. - It is what makes stage 1 runnable, so it is where the end-to-end evidence belongs. ## Does this change anything on `main` / the text side? No intended text-side change. The shared files it touches are the additive checkpoint helper, the callbacks `__init__` export, a type annotation, and the activation-checkpointing change in `nn/transformer/model.py`. That last one changes behaviour only for models that use dropout together with activation checkpointing (their recompute now replays the dropout masks, which it previously did not); with `dropout=0`, the default, text models are unaffected. For the series as a whole, text-side outputs (weights, logits, loss and gradients) were compared bit for bit against `main` on CPU and match, and the existing test suites show no regressions. Text GPU and distributed paths (FSDP2, TP, CP) cannot run on the CPU box I used, so CI's GPU jobs are the check there. ## Why the RNG fix is here Stage 1 trains with full activation checkpointing and 10% response-token residual dropout. Without replaying the RNG, the recompute draws different dropout masks than the original forward, so gradients are taken against a different sample than the loss. This was held out of #910 because #906 (open) rewrites the same lines; the end-to-end parity run below showed it cannot be left out of the recipe: without it the run trains much worse than `vision` (final loss 1.83 vs 1.19). The change here is `vision`'s own fix (#828) unchanged, with its test. #906 fixes the general case differently and will need a rebase on top of this. ## Not included (stays on `vision`) Stage 2 (`Molmo2-Stage2.py`, `image_only_v9`, multi-image datasets, `compare_sft_example.py`), the stage-1 data infrastructure upgrades, and the OLMo 3.5 alignment work; see the plan above. ## Testing **CPU:** `src/test/data`, the callback and distributed-checkpoint tests: 462 passed, 0 failed (before the last test-only fix below). ruff, black, isort and `mypy src/` (the CI config) are clean. `Molmo2-Stage1.py dry_run` resolves for the default, `--recipe=v2` and `--recipe=v3` (32k and 50k steps). One test (`test_st_qa_train_validation_split`) read a Weka path with no skip, which failed on the CI runner; it now skips when the data is absent. **GPU smoke (Beaker, 8x GPU, FSDP2):** an earlier 30-step run of the stack: CE loss 3.23 → 2.57, checkpoint and unsharded export written. **End-to-end parity on Beaker** (`ai2/molmofication`, Holmes, allocated, `--recipe=v3`, 1 node x 8 GPUs, 2000 steps, same seed and arguments; W&B disabled because `BeakerCallback.pre_train` calls `wandb.Run.get_url()`, which the image's `wandb` lacks, existing code unrelated to this series). V is the control: `vision` at the commit this series was cut from. | Run | Code | Result | |---|---|---| | [V](https://beaker.org/ex/01M5N24PSKG4EYXQNXQ7KK45XC) | `vision` @ `f639a28` (control) | CE 3.16 -> 1.20 | | [P](https://beaker.org/ex/01M5N222MQ1JSY1TBDWY3YZBEY) | this PR **without** the RNG fix | trains worse than V, gap grows: +0.05 (steps 1-50), +0.41 (201-500), +0.60 (1501-2000); final-100-step CE 1.83 vs 1.20 | | [P2](https://beaker.org/ex/01M5NWNH21XHNA9WFKPJRARQHS) | this PR **with** the RNG fix | tracks V | Windowed mean CE, with the fix (P2) against the control (V): | steps | P2 | V | P2 - V | |---|---|---|---| | 1-50 | 2.619 | 2.619 | +0.000 | | 51-200 | 2.114 | 2.096 | +0.018 | | 201-500 | 1.638 | 1.640 | -0.002 | | 501-1000 | 1.326 | 1.315 | +0.011 | | 1001-1500 | 1.248 | 1.238 | +0.011 | | 1501-2000 | 1.199 | 1.201 | -0.002 | Last 100 steps: P2 1.192, V 1.197. The offset has no trend (-0.002 per 1000 steps; without the fix, +0.195 per 1000 steps). Two identical-code runs (P and R1) differ by about 0.015 per logged point, so window means agree within about that. Per-point differences between P2 and V are larger (stdev 0.057) because the data draws differ on purpose: the review fixes made PixMo-Cap sampling epoch-aware. Caveats: one run per arm. The gradient norm is spiky; P2 had two transient spikes (step 300: 30, step 455: 37.6) that V did not, with normal loss at those steps and clipping at 1.0 (the unfixed run spiked as high as 165). I cannot tell noise from a small residual difference from single runs. **Checkpoint and resume:** run [R1](https://beaker.org/ex/01M5N222PV51TWTJ7YR9KXWWNP) (1000 steps) wrote a checkpoint; [R2](https://beaker.org/ex/01M5NS0S9NSNFQGJBQVDGF2ENE) resumed it from step 1000 to 2000 (first logged step 1005). Over steps 1001-2000 its loss differs from the uninterrupted run P by +0.003 on average (stdev 0.013), inside the same-code noise. The unsharded `model.safetensors` export was written. This pair ran on the code before the RNG fix; resume does not depend on it, but I have not rerun it on the final code. **Second parity check: Qwen3-0.6B on 2 nodes (16 GPUs), against a finished `vision` run.** This covers paths the 4B runs above did not: `response_logits_only=true`, no activation checkpointing, and 16-GPU FSDP. Reference: `molmo2-stage1-0p6b-v3-50k-20261023` (`vision` HEAD), whose per-step training loss is readable from its W&B files. Test: [`mm-e2e-0p6b-main-2k`](https://beaker.org/ex/01M5QC1TVNGX0R8CXF8VZ725C5), this branch plus `vision`'s #933 (the 0.6B size) cherry-picked, with the reference's launch arguments, image and environment, stopped at step 2000 by `hard_stop` while keeping its 50k-step LR schedule. Windowed mean CE: | steps | run | reference | diff | |---|---|---|---| | 1-50 | 4.580 | 4.595 | -0.015 | | 51-200 | 2.722 | 2.729 | -0.007 | | 201-500 | 2.383 | 2.380 | +0.002 | | 501-1000 | 1.738 | 1.737 | +0.002 | | 1001-2000 | 1.519 | 1.520 | -0.002 | Last 100 steps: 1.443 vs 1.458; trend of the difference -0.006 per 1000 steps; loss finite throughout. Per-point differences between the two runs have stdev 0.093, which matches what two independent runs of the same curve should give (the reference's own per-step noise is about 0.064, so about 0.09 for a difference). Caveat: the reference ran `vision` HEAD, which includes data-code changes made after this series' cut point (#902, #903, #918), so this is a sanity check of overall health, not an apples-to-apples control; the rigorous rerun comes once those changes land on `main`. **Offline check, no GPU:** one training step of a tiny multimodal model on `vision`@cut and on this branch (dropout off) produces bit-identical loss, gradients and updated weights, so the model and train-module path is unchanged apart from the RNG fix. **GPU logit parity vs HF Molmo2 (4B and 8B pass; O-7B skipped):** see #910. **Not covered:** long-horizon loss parity against the released Molmo2-4B-Pretrain recipe (these are 2000-step checks); GPU text-side paths beyond CI; a resume rerun on the final code.
…5/v6 visual data, 256K text stage, compile_vision
jason718
force-pushed
the
jasonr/molmo2-mixed-midtraining
branch
from
November 10, 2026 20:28
a8fb914 to
f530d76
Compare
jason718
force-pushed
the
jasonr/molmo2-mixed-midtraining-wip
branch
from
November 10, 2026 20:28
e7c127b to
4f7f5c8
Compare
Base automatically changed from
jasonr/molmo2-mixed-midtraining
to
jasonr/molmo2-complete-parity
November 11, 2026 07:24
Contributor
Author
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.
Summary
PR 9 of the multimodal series: the still-changing part of the OLMo 3.5 mixed mid-training work from #916. Stacked on PR 8 (stable mixed mid-training), which is stacked on #937. Draft; expect it to keep changing while the hero runs go on.
Included:
annotation_sampling="documents": every annotation of a drawn image becomes its own document sharing the image's crops (pixmo_points,pixmo_points_v2,text_rich_caption,academic_dataset, packing/collator support).compile_vision(compile the vision encoder's blocks, off by default) and the cuDNN gate that reads the loaded runtime version.Series
Why a separate PR
It holds what is still being changed while the heroes run, so churn here does not force restacks of the stable PR or anything under it. It lands after PR 8 once the recipe settles.
How it was ported
Per-file 3-way from the stable state (#916 minus these commits) to the full #916 head, onto the PR 8 tip; 20 files changed (+987/-56). One conflict in
sdpa.py(import line) and one in the CHANGELOG, both trivial.Testing
CPU,
src/test/{internal,train,nn/vision,data/multimodal}: 1549 passed, 42 skipped, 3 failed (the same three environment-only failures as on #937: two S3 checkpoint tests andtest_clip_parity). ruff, black, isort andmypy src/clean.Not run yet: GPU parity or a smoke for these changes. It needs its own short check once the heroes finish.