Repository navigation
Conversation
…es to vision The recipe, data module, entry point, calibration, guide and tests from rustins/native-mixed-midtraining. Two adaptations to the merged alignment code: the joint-alignment source builders register on import of vision_alignment_phases, and the caption source sets style_length_conditioning=True explicitly (vision's PixMoCapDatasetConfig default is False). Co-authored-by: RustinS <[email protected]>
…h recipe.text_config With recipe.text_config (the text team's resolved mid-training config.json), the recipe takes the text mixture (cached in the recipe's own work dir), token budget, global batch, LM learning rate and schedule, optimizer and train-module settings, checkpoint cadence and callbacks, and launch resources from it. The connector and vision learning rates scale with the LM's (2x and 1/10, Rustin's ratios). Without it, the legacy s002 recipe is unchanged. The recipe has its own main() through the alignment runner, launches through the alignment launcher (workspace, budget, secrets) on two nodes, and uses the multimodal callback subclasses. The text-settings extraction is shared with alignment (text_train_settings); alignment's resolved config is unchanged.
…M without alignment recipe.parent_checkpoint now accepts the endpoint of any alignment stage (bridge, perception or joint), so each stage ablation can feed midtraining; for bridge and perception parents, whose LM was frozen with router load balancing off, the text LM's router coefficients are restored. recipe.pretraining_checkpoint starts from a text LM checkpoint instead: the multimodal model is built around it as alignment's bridge builds it (pretrained SigLIP, fresh connector, image-token rows) and loaded by the initialize_multimodal callback. Exactly one of the two must be set; the resolved config records alignment_phase. Tests cover each stage, the LM start and the guard; the guide documents both starting points and the text-config path.
…caller build_config(cli, text_config=..., launch=...) lets a launcher that builds the text team's config itself (a scaling-ladders midtraining or microanneal workload) hand it over directly, instead of a saved config.json; recipe.text_config stays for standalone runs. The launcher's own launch config (image, secrets, environment) is used on two nodes.
…ixture as the visual share As alignment's perception and joint use it: one sampled annotation per example, its calibrated means, and its loss shares within the visual share.
jason718
force-pushed
the
jasonr/olmo35-mixed-midtraining
branch
from
October 6, 2026 02:47
99b6fd6 to
d978842
Compare
…n the launch The v3 Stage-1 sources render PDFs (pypdfium2) and read HDF5 (h5py), which the text team's image lacks; append the same post-setup alignment uses for its stage1_v3 data, also to a caller-supplied launch.
… prefetch threads A recipe field, because in scaling-ladders --data_loader.* overrides also reach the text team's own loader, which has no such field.
… decay from the text config From an alignment checkpoint, connector and vision encoder train at half the LM's LR; from the text LM, the fresh connector at 10x and the pretrained vision encoder at a fifth. Their weight decay is the text config's for every parameter (0.1) instead of Rustin's 0; the legacy s002 path is unchanged.
…batch), as microanneal.py does
…ad-ahead depth The loader's default, max(2 * prefetch_workers, 4) examples in flight, is less than one rank batch of examples, so the prefetch threads cannot work through the GPU step.
…ument boundaries MultimodalLMConfig.document_mode (None: decided by the LM, as before) forces the wrapper's isolation mode. False with a recurrent LM runs each packed sequence as one causal stream, the state carrying across examples as text pretraining carries it across packed documents, and the recipe then keeps the text team's kernel_fun KDA kernels instead of the FLA kernels that document boundaries need. For measuring what the boundary path costs.
jason718
added a commit
that referenced
this pull request
Nov 11, 2026
…te-grad skip, EMo from the text config
jason718
added a commit
that referenced
this pull request
Nov 11, 2026
…#916; its hero-phase tests fail without it)
jason718
added a commit
that referenced
this pull request
Nov 13, 2026
jason718
added a commit
that referenced
this pull request
Nov 13, 2026
…te-grad skip, EMo from the text config
jason718
added a commit
that referenced
this pull request
Nov 13, 2026
…#916; its hero-phase tests fail without it)
jason718
added a commit
that referenced
this pull request
Nov 14, 2026
jason718
added a commit
that referenced
this pull request
Nov 14, 2026
…te-grad skip, EMo from the text config
jason718
added a commit
that referenced
this pull request
Nov 14, 2026
…#916; its hero-phase tests fail without it)
jason718
added a commit
that referenced
this pull request
Nov 16, 2026
jason718
added a commit
that referenced
this pull request
Nov 16, 2026
…te-grad skip, EMo from the text config
jason718
added a commit
that referenced
this pull request
Nov 16, 2026
…#916; its hero-phase tests fail without it)
jason718
added a commit
that referenced
this pull request
Nov 18, 2026
jason718
added a commit
that referenced
this pull request
Nov 18, 2026
…te-grad skip, EMo from the text config
jason718
added a commit
that referenced
this pull request
Nov 18, 2026
…#916; its hero-phase tests fail without it)
jason718
added a commit
that referenced
this pull request
Nov 20, 2026
jason718
added a commit
that referenced
this pull request
Nov 20, 2026
…te-grad skip, EMo from the text config
jason718
added a commit
that referenced
this pull request
Nov 20, 2026
…#916; its hero-phase tests fail without it)
jason718
added a commit
that referenced
this pull request
Nov 25, 2026
jason718
added a commit
that referenced
this pull request
Nov 25, 2026
…te-grad skip, EMo from the text config
jason718
added a commit
that referenced
this pull request
Nov 25, 2026
…#916; its hero-phase tests fail without it)
jason718
added a commit
that referenced
this pull request
Nov 30, 2026
jason718
added a commit
that referenced
this pull request
Nov 30, 2026
…te-grad skip, EMo from the text config
jason718
added a commit
that referenced
this pull request
Nov 30, 2026
…#916; its hero-phase tests fail without it)
jason718
added a commit
that referenced
this pull request
Nov 30, 2026
jason718
added a commit
that referenced
this pull request
Nov 30, 2026
…te-grad skip, EMo from the text config
jason718
added a commit
that referenced
this pull request
Nov 30, 2026
…#916; its hero-phase tests fail without it)
jason718
added a commit
that referenced
this pull request
Nov 30, 2026
…1.7B sizes (#934) ## Summary PR 5 of 7 for moving the Molmo2 reproduction from the long-lived `vision` branch onto `main`. **#913 (stage-1 recipe) is merged, so this targets `main` directly**; the diff here is only this PR's change. This PR brings the multimodal **data pipeline up to `vision`'s current state** and adds the **stage-2 recipe**, plus the Qwen3-0.6B / 1.7B model sizes: - **Epoch-aware, resumable mixture loading** (`mixture_data_loader`, `alignment.py`, `mixture_weights`, `packing`, `rng`): per-source epochs (`get(index, epoch)`), configurable `MultimodalMixtureConfig` / `MultimodalSourceConfig` mixtures, loader state that resumes mid-epoch. - **Message layouts** (`document_layout`, `qwen3_layout`, `molmo2_tokens`: `Molmo2TokenIds`, `prepare_molmo2_tokenizer`): the released `qwen3` layout and a `document` layout, selected per source. - **Truncation and sampling** (`sft_common`, `pixmo_cap`, `message_sequence`, `collator`): `truncate_example(..., recompute_root_subsegments=...)` and `truncate_for_format`; `sft_example_rng`. - **Stage-1 data updates** from `vision`: `pixmo_points`, `pixmo_points_v2`, `finevision`, `fs_cache`, and small updates to the OCR, academic and text-rich sources. - **Stage 2:** `Molmo2-Stage2.py`, the `image_only_v9` mixture, multi-image datasets, `mm_olmo_loader`, and the `sft_demo` mode of `PixMoCapDataset`. - **Model sizes:** `MultimodalLMConfig.molmo2_0_6B()` / `molmo2_1_7B()` and `--model_size=0.6b|1.7b` in `Molmo2-Stage1.py`. About 5.4k source lines and 3.7k test lines in 56 files. Everything is opt-in; existing behaviour on `main` does not change. ## Review map Reading every file closely is not necessary. ### Read closely | File | Lines | What to check | |---|---|---| | `data/multimodal/mixture_data_loader.py` | +925 / -79 | The loader's state, epoch and resume semantics, and how per-source epochs reach `get(index, epoch)`. The most behaviour-sensitive file in the PR. | | `data/multimodal/sft_common.py` | +174 / -32 | `truncate_example` (rejects cutting any image-structural token; rescales branch weights only when `recompute_root_subsegments=True`) and `truncate_for_format`. Replaces the weighting-aware version added in #912's review; same behaviour, `vision`'s API. | | `data/multimodal/pixmo_cap.py` | +293 / -37 | Routes through the shared `truncate_example` (the local copy that always rescaled is gone); `sft_demo` now truncates; `__getitem__` uses the dataset's current epoch. | | `data/multimodal/packing.py`, `collator.py` | +150 / +41 | Packing contract; the collator still refuses to cut `<im_patch>` tokens (from #912's review). | | `scripts/train/Molmo2-Stage2.py` | 564 (new) | The stage-2 recipe: mixture, optimizer groups, learning rates, launch settings. | | `nn/vision/multimodal.py`, `molmo2_tokens.py` | +80 / +118 | The model-side pieces the new data pipeline needs (0.6B / 1.7B factories, token ids). Only the data-pipeline and size parts of `vision`'s file are here. | ### Skim for the shared pattern `pixmo_points.py` (+1005), `finevision.py` (+334), `pixmo_points_v2.py` (+135), `multi_image_datasets.py` (289 new), `mixtures/image_only_v9.py` (360 new), `alignment.py` (314 new), `message_sequence.py`, `document_layout.py`, `fs_cache.py`, and small updates to `text_rich_caption`, `ocr_caption_tars`, `olmocr`, `synthetic_ocr`, `academic_dataset`. These are dataset adapters and mixture definitions that follow one shape; if one is right, the rest are variations. ### Tests (about 3.7k lines) One test file per module group, plus `molmo2_tokens_test`, `molmo2_native_config_test` (now covers 0.6B / 1.7B) and the model-size test for the stage-1 script. ## 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 | merged | | 5/7 | this PR: data infrastructure, stage-2 recipe, 0.6B / 1.7B sizes | approved | | 6/7 | #936 OLMo 3.5 alignment training: OLMoDDP hooks and train module, optimizer, callbacks, alignment pipeline | draft | | 7/7 | #937 evals, mixed mid-training (from #916), catch-up with #916 | draft | With PRs 6 and 7, `main` reproduces everything on `vision`, apart from the intentional divergences below. ## Why this is a separate PR - It is the data and recipe layer that every later PR builds on, and it can be checked without any OLMo 3.5 or OLMoDDP code. - The loader and truncation changes are behaviour-sensitive and deserve a focused review, separate from #913's recipe. - Stage 2 only needs this data layer, so it lands here and not behind the alignment work. ## Does this change anything on `main` / the text side? No. This PR adds files under `data/multimodal/`, `nn/vision/` and `scripts/`; `nn/transformer`, `optim`, `train` and the text data pipeline are untouched. Only multimodal entry points change behaviour. ## Behaviour added or fixed during review These are in the final diff; each has a test that fails without it. - **Epochs reach every source.** `sft_example_rng` varies Qwen-layout streams with the epoch (epoch 0 is the unchanged stream, so first passes are identical). Points, Count, CoSyn and FineVision honor `set_epoch`, which the default (non-continuous) loader calls; GUISyn builds per explicit epoch; selected sources forward the epoch. A scan test fails for any source with an epoch-taking `get` but no `set_epoch` (the alignment and mid-training sources run with `continuous_stream=True` and are excluded). - **Truncation is independent of strict validation** (`pixmo_points._finalize_example`), and multi-image examples longer than the recipe's length are truncated or rejected so the loader skips them instead of the collator stopping the run. The collator's image-patch id follows the mixture's `token_ids`. - **Resume identities.** FineVision fingerprints every source with a stable Arrow fingerprint and binds it to the token ids; `strict_annotations=True` requires `skip_bad_rows=False`; a row selection over an unpinned source advertises no fingerprint. - **Mixture and stage-2 plumbing.** Subset mixtures open only the groups they need; Stage 2 derives source names from the registry order (matching the datasets returned) without opening sources twice; the stage-2 registry test skips without Weka data. ## Intentional divergences from `vision` Where `vision` and `main` differ on purpose: - **No HF export direction** (`multimodal_lm_state_dict_to_hf`) and no `output_vocab_size` logit masking: both were removed in #910's review. Nothing on `vision` calls either. - **Reviewed fixes kept:** the collator's image-token guard, and PixMo-Cap's truncation through the shared function (the weighting-off fix). - **Type-only fixes** so `mypy src/` passes (annotations in tests and the stage-2 script, an undefined `Molmo2TokenIds` annotation in `sft_common`, which was a latent lint error on `vision`). - **Not in this PR:** the B-side parts of `vision`'s `multimodal.py` and the data package exports (OLMoDDP model, document-mode attention, replay datasets), which arrive with PR 6. ## Testing CPU on the final tip: `src/test/{data/multimodal,scripts,nn/vision}` 665 passed, 26 skipped, 1 failed. The failure, `test_clip_parity`, is environment-only and fails the same way on `main` on the dev box. ruff, black, isort and `mypy src/` (CI config) are clean. `package_import_test` runs subprocess imports with a 45 s timeout that the slow dev box exceeds, so it was checked separately with a longer timeout; CI runs it as is. **GPU parity (Beaker [`mm-e2e-0p6b-A-2k`](https://beaker.org/ex/01M5RK532QEWWEVZG8S6HG2S0W), 0.6B, 2 nodes, 2000 steps, this PR's code) vs the `vision` reference run `molmo2-stage1-0p6b-v3-50k-20261023`:** windowed mean train CE, 2026-10-25. | steps | this PR | reference | diff | |---|---|---|---| | 1-50 | 4.623 | 4.595 | +0.027 | | 51-200 | 2.720 | 2.729 | -0.008 | | 201-500 | 2.371 | 2.380 | -0.010 | | 501-1000 | 1.739 | 1.737 | +0.002 | | 1001-2000 | 1.530 | 1.520 | +0.010 | Per-point diff over 401 logged steps: mean +0.004, stdev 0.099 (independent runs of this size differ by about this much per point). All windows after warm-up are within ±0.015, the noise floor for identical code. Caveats: one run per arm, loss only (no downstream eval), and the run is of an earlier tip. The later review fixes change only Qwen-layout draws from epoch 1 on (epoch 0 is bit-identical, tested against `example_rng`), and I did not rerun parity after them.
jason718
added a commit
that referenced
this pull request
Nov 30, 2026
jason718
added a commit
that referenced
this pull request
Nov 30, 2026
…te-grad skip, EMo from the text config
jason718
added a commit
that referenced
this pull request
Nov 30, 2026
…#916; its hero-phase tests fail without it)
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.
Not for merge yet. This is the one OLMo-core PR the multimodal launcher points to: allenai/scaling-ladders#83 pins its
olmo-coresubmodule to this PR's head commit, and jobs launch from there. It is based onvisionand contains:vision:main(with Fix OLMoDDP Torch 2.13 training and preserve HF inference numerics #885 squash-merged as c808ade) was synced intovisionin Sync main into vision: #885, #888, #910-#912, #920 #943 andvisionmerged here (70fd5bd), so this branch no longer carries the unmerged PR headb5db31dbd. The shared code differs frommainonly byvision's reviewed hooks (Add the OLMoDDP hooks a multimodal wrapper needs, inert by default #886) and the activation-checkpoint RNG fix; the HF numerics files aremain's final Fix OLMoDDP Torch 2.13 training and preserve HF inference numerics #885. Run 5's resolved config and first batches are unchanged by the update (byte-identical tensors).Everything else multimodal that the runs use is already on
vision(#902, #886, #889, #903, #918).How to run (alignment, mixed midtraining, evals, results table):
ladders/olmoe3/multimodal/handover.mdin allenai/scaling-ladders#83; the stage-1 evals use allenai/olmo-eval#458.Mixed midtraining
Continue a multimodal model on mostly text plus a vision share of the loss. The text side is the text team's own config; the recipe adds only the vision side.
--recipe.parent_checkpoint, the endpoint of any alignment stage (bridge, perception or joint), so each stage ablation can feed midtraining (bridge and perception parents get the text LM's router load-balancing coefficients back, since midtraining trains the LM); or--recipe.pretraining_checkpoint, a text LM without alignment (pretrained SigLIP, a fresh connector and image-token rows, initialized as bridge does). The resolved config recordsalignment_phase.build_config(cli, text_config=..., launch=...)takes the text team's config and launch config in memory, as scaling-ladders'mixed_midtraining.pypasses them (built exactly as theirmidtraining.pyormicroanneal.pybuilds them); or--recipe.text_config=<config.json>for standalone runs. Inherited: text mix (cached in the recipe's own work dir), token budget, global batch, LM LR and schedule, optimizer and train-module settings, checkpoint cadence, launch. Microanneal vs full scale is chosen by the scaling-ladders workload.--recipe.text_loss_share(default 0.9);--recipe.visual_data=stage1_v3for the v3 Stage-1 mixture (one annotation per example, calibrated means, v3 loss shares within the vision share), or Rustin's eight groups; connector and vision LRs scale with the LM's (2x and 1/10, no weight decay on either); two nodes. This rule was briefly replaced (34205a0: half the LM's LR, the text config's weight decay) and restored in becf70c: in 10B microanneals from the 14T alignment endpoint (2026-10-07, one seed each, same LM settings), the 2x/1/10 rule scored higher on every stage-1 task but olmOCR-Bench (PixMo-Points F1 55.5 vs 53.4, PixMo-Count val 75.6 vs 68.1, SA-Co Gold 4k F1 80.6 vs 74.9, caption avg 50.1 vs 47.5, CC-OCR 64.5 vs 61.7; olmOCR-Bench 41.7 vs 42.6), with text level.main()through the alignment runner, multimodal callback subclasses, connector activation checkpointing off, nodata_loader.text_only, explicit captionstyle_length_conditioning=True.Validation
src/test/internal: 411 passed (Rustin's tests updated only where behaviour changed on purpose; new tests for the text-config path, in-memory config, caller-supplied launch, each alignment stage as parent, the LM start, the one-of-two guard).🤖 Generated with Claude Code