Skip to content

Molmo2 stage 1: tag-only caption prompt, mm_olmo v2 pointing data, and a general OCR group - #875

Merged
jason718 merged 24 commits into
visionfrom
jasonr/stage1-pointing-v2-ocr
Sep 29, 2026
Merged

jason718 merged 24 commits into
visionfrom
jasonr/stage1-pointing-v2-ocr

Conversation

@jason718

@jason718 jason718 commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #852, whose author has left the team, and absorbs #876. This PR targets stage 1 only and does four things: it adds mm_olmo's second-generation pointing / counting data, adds a general OCR data group, adds a v2 data recipe that uses both (--recipe=v2), and makes the caption prompt the same at training and test time: the bare tag long_caption:, with no instruction and no length number. The default recipe stays the released v1 mixture, so the data groups are opt-in. The caption prompt change is not: it applies to every stage-1 run.

Caption prompt: the bare tag, at training and at test time

Stage-1 caption training used a form that neither the reference implementation trains on nor the eval sends, and even the reference form carried a number that differed between training and test.

Caption user turn
OLMo-core stage-1 training, before long_caption 63: Describe this image.
mm_olmo stage-1 training long_caption 63: (the caption's length // 15, with noise)
olmo-eval dense_caption_captioner, before long_caption 65:
OLMo-core stage-1 training, after long_caption:
olmo-eval dense_caption_captioner, after allenai/olmo-eval#401 long_caption:

Two things were removed. The sampled instruction: mm_olmo's stage-1 formatter runs with prompt_templates="none", under which a caption's question is the empty string, but PixMoCapDataset appended a sentence from CAPTION_PROMPTS / TRANSCRIPT_PROMPTS. And the length number: mm_olmo puts the caption's length in the tag so a length can be requested at inference, with a fixed 65 at test time. Over the 714,985 training captions that number has median 65 and runs 41–105 for the middle 90%, so the eval was asking for a typical-length caption anyway. Dropping it means training and test share one prompt with no value that differs between them; what is lost is length control at inference, which nothing here uses.

Code: PixMoCapDatasetConfig.style_length_conditioning is renamed style_tag (the tag is the whole user turn; False still gives the un-tagged natural-language prompt; fixed_prompt still overrides). style_tag_prompt(style) takes only the style, so no OCR tag carries a number either. style_length_prefix and the bucket constants are gone. Checkpoints trained before this saw the sentence-plus-number form, which no olmo-eval task sends any more.

Counting prompt: training and test already agree, once the eval side lands

No code here: stage-1 counting trains on point_count: <label>. The eval side is fixed in the companion PRs, after which a stage-1 checkpoint is tested on exactly that string. OLMo-core's training formatter matches the new stage-1 eval prompt on 540/540 PixMo-Count validation labels.

CountBenchQA is not used for stage 1: it is a test set with no train split, and it ships a question rather than an object name.

Pointing and counting (--pointing_data=v2)

Ports mm_olmo's PixMoPointV2 / PixMoCountConfigV2, the pointing group of train_molmo3_stage1.py.

v2 replaces v1; it is not extra data. The v2 builds are the same images as the v1 sources, re-annotated: pixmo-points-with-masks-v17 is exactly the union of the two v1 points train splits (152,858 + 70,714 = 223,572 rows, every url matched), and count-v2 train has the same 36,411 image hashes as v1 count train. Training on both would show every image twice. That is why the flag switches the group rather than adding to it, as mm_olmo's molmo3 recipe does.

Source Rows trained What is new over v1
pixmo_points_v2 220,290 images VLM audit verdict per point set; easy and paired absence queries per image, sub-sampled per epoch
pixmo_count_v2 36,901 images Same audit, regrouped by image
cosyn_point 68,051 reused, now tagged cosyn_point: under the stage-1 family, as mm_olmo does, so there is no untagged image source. Its question stays the English request its data stores: its names column is a short summary written for the answer's label (Highest Growth Period for "Highlight the period that shows the largest five-year increase..."), so it cannot become a bare label, and a tag of its own keeps pointing: meaning that an object name follows.
cosyn_point_v2 68,051 mm_olmo's audited CoSyn build (CoSynPointConfigV2, cosyn-point-v2-masks): the v1 build's images, questions, points and names unchanged (all 68,051 train rows match), plus a per-question VLM audit. Its agent masks only feed segmentation, so they are ignored. The ~18% of questions that failed the audit (17.3% clear_error, 1.0% error on a 1-in-20 sample) keep training behind their own tag, aux_cosyn_point:; mm_olmo tags them aux_pointing:, but that would put an English request after a tag that is otherwise followed by an object name. Used by the v2 pointing group in place of cosyn_point.

The v2 group splits its 0.30 rate linearly by size (mm_olmo size_weighted=1): 20.3% / 3.4% / 6.3% of the mixture. v1 splits by sqrt(size): 9.6% / 6.5% / 7.6% / 6.3%.

OCR (--ocr_rate, --ocr_sources)

General OCR data only: an image in, its text or a description of a text-rich figure out, and no question in the prompt. The user turn is a style tag and nothing else. 17 registered sources, 12 on by default.

Task Tag Default sources Registered, not default
Transcription olmocr: olmOCR-mix documents, books, loc_transcripts, national_archives s2pdf, iabooks (same pages as documents / books)
Transcription textocr: textocr hiertext, cocotext, ubertext (split unverifiable)
Transcription synth_ocr: nvidia_synth_en
Transcription receipt_ocr: synth_receipts_en
Figure captions fig_caption_high: fig_caption_mid: fig_caption_low: text_rich_{chart,diagram,doc,graphic,table}
  • olmOCR-mix and the figure captions are mm_olmo's two stage-1 OCR groups (olmo_ocr, figure_ocr, 0.075 each). TextOCR and the two synthetic sets are the default sources outside mm_olmo's recipe.
  • Two synthetic English sets (synthetic_ocr.py), train splits only, stored under /weka/oe-training-default/jasonr/dataset/ocr/:
    • nvidia_synth_en: nvidia/OCR-Synthetic-Multilingual-v1 en/train, 1,460,304 images (63 HDF5 files, 661 GB, CC BY 4.0); validation / test and the other languages are never read. The images are words scattered over photos or flat colours (36% have vertical words), so they get a tag of their own, synth_ocr:, with TextOCR's answer form: the words joined by spaces. The own tag keeps synthetic scattered text apart from TextOCR's real photos. The dataset's labels join the words in source-sentence order, which only 16% of images show visually (496 validation images), so the target is rebuilt from the line boxes in visual reading order. Needs h5py, which the launch now installs.
    • synth_receipts_en: albertobarnabo/synthetic-receipts-ocr, 16,437 receipts (US 11,986 + UK 4,451 of the 30,000 train rows; Apache 2.0); the eval parquets and the DE/IT/FR locales are never read. Photo-degraded image, with a tag of its own, receipt_ocr:, kept apart from olmOCR's page transcriptions; the target is the printed lines, with the price-column padding collapsed (DIS MEN JUN $12.99) and rule lines dropped. The parquet row groups hold hundreds of inline images each, so the English train rows were converted once to a 1.5 GB Arrow dataset (prepare_synthetic_receipts).
  • Figure captions are the three-level build, tagged fig_caption_{high,mid,low} rather than mm_olmo's ocr_caption_<level>_level: all three levels describe the figure, and the most detailed one quotes the text inside a description rather than transcribing it. Each image carries a summary, a layout description and a dense read-out (medians 30 / 154–199 / 395–600 tokens), emitted as three branches. On weka: chart 353,439 rows, doc 438,267. With the Qwen3 tokenizer and 8 crops an example is ~1.7k–2.0k tokens; 1 of 80 sampled examples exceeds the 2,560-token training length.
  • The rate is split by task before size. A flat sqrt(size) split hands the figure captions 72.7% of the OCR rate and page transcription 23.0%, because each figure category is larger than all of olmOCR-mix. mm_olmo gives its two groups equal rates, so the rate is halved between transcription and figure captions, then split by sqrt(size) within each. At --ocr_rate=0.15: nvidia_synth_en and olmocr_documents 2.29% each, textocr 0.72%, synth_receipts_en 0.63%, the five figure categories 0.89–1.99% each.
  • Left for a later stage: the Cambrian subsets (images from VQA datasets, machine-recaptioned) and TextCaps (five reference captions joined). Neither is "read the text off the image". The single-caption text_rich_caption_v6_tars build is superseded by the three-level one.

Data recipes (--recipe)

A recipe sets the defaults of the four group rates and the pointing sources, before the merge; an explicit --pointing_rate / --nlp_rate / --ocr_rate / --pointing_data still wins, and the recipe is recorded in the config.

Group v1 (default, released Molmo2-4B-Pretrain) v2
Caption (pixmo_cap) 0.60 0.50
Pointing and counting 0.30, v1 sources 0.25, v2 sources
Text only (tulu4) 0.10 0
OCR 0 0.25, default OCR sources

Per source in v2, with the real sizes: pixmo_points_v2 16.93%, pixmo_count_v2 2.84%, cosyn_point_v2 5.23% (linear by size); transcription 12.5% (nvidia_synth_en 3.82%, olmocr_documents 3.82%, textocr 1.20%, synth_receipts_en 1.05%, olmocr_books 1.00%, olmocr_national_archives 0.81%, olmocr_loc_transcripts 0.80%) and figure captions 12.5% (text_rich_doc 3.32%, _chart 2.98%, _table 2.82%, _diagram 1.89%, _graphic 1.48%), each split by sqrt(size). A synthetic source is weighted as if no larger than the largest real source of its task (ocr_weighting_sizes): plain sqrt gave the 1.46M NVIDIA images 6.59% of the mixture on size alone, more than the four olmOCR-mix subsets together, while a run sees under half of them. Capped, it weighs like olmOCR-mix documents (218,831 after the English filter). With 32k steps at 1–2 examples per packed sequence, every OCR source is seen 0.1–6.6 times.

Stage 1 only, and no segmentation

  • PixMoPointsV2DatasetConfig / PixMoCountV2DatasetConfig have no prompt_templates, system_prompt or p_high_res. The family is fixed: bare lowercased label behind "<style>:", as in the released Molmo2-4B-Pretrain formatter. The OCR configs have no system_prompt either: their user turn is always the bare <style>: tag.
  • There is no segmentation path. The v17 data ships masks; a test pins that they never produce a branch or rescue an over-max_points annotation, and that neither config has a mask option. CocoTrain (mm_olmo's fourth "pointing" entry) emits pixmo_seg with bboxes and RLE masks and no points, so it is not ported.

Train splits only

Source Finding Guard
pixmo-points-with-masks-v17 Exactly the two v1 train splits. 0 overlap with pixmo-points-eval (431 urls) and -eval-v3 (1,211 images). 1 image is also in the v1 points-counting validation split. heldout_paths: rows whose image_url is in a held-out set are dropped. 220,291 → 220,290
count-v2 Its validation / test splits are copies of train (36,411 of 36,411 sha256 shared). Its train split shares 15 of 540 real PixMo-Count test images. heldout_paths on image_sha256 against the real count val / test. 36,916 → 36,901. No split field.
olmOCR-mix Separate _train / _eval parquets. The training script refuses any olmocr.split but train.
Figure captions The build holds 2,048 rows per category out as validation; 0 ids shared with train. Reads train only; there is no split option, and a build without a train split fails.
TextOCR 1,200 keys sampled from the first, middle and last shard: all TextVQA train images, 0 of 3,166 val, 0 of 3,289 test. none needed
HierText, COCO-Text, UberText Official val / test splits exist, tar keys are synthetic and the JSON carries no split, so it cannot be established which splits the tars hold. Not default (SPLIT_UNVERIFIED_SOURCES); selecting one logs a warning.

A held-out set that cannot be read fails the build rather than passing. The 1 and 15 overlaps are inherited from PixMo's own splits and also exist in the v1 sources stage 1 already trains on; this PR guards only the new sources.

Carried over from #852

All six critical findings of the #852 review are fixed: negatives rotate per epoch (paired-negative pool coverage over the 4 pointing epochs 25.0% → 67.8%, epoch 0 bit-identical), blank / null labels and null points are dropped, an empty mixture source raises by name, tar keys are unicode, and the OCR sources skip unusable rows through get_example_with_skip. Shard indexing is O(n) (20k-sample shard 5.80 s → 0.77 s).

Checkpoint retention

Molmo2-Stage1.py now passes max_checkpoints=None. CheckpointerCallback's default of 3 also deletes old permanent checkpoints, which removed steps 8000 and 16000 of the v2 run below before they could be scored. Every 2,000-step checkpoint is now kept: about 49 GB each with the optimizer, so about 780 GB for a 32k-step run.

Results: --recipe=v2, 32k steps

molmo2-stage1-4b-v2-20260926 (Beaker): 2x8 B300, 22h46m, final train CE about 1.1. Scored with olmo-eval #412, whose stage-1 prompts send exactly the training tags (-o prompt_templates=none -o system_prompt_style=style_and_length_v2), on the olmo_core_vlm provider at the trained 8 crops. The v1 baseline is molmo2-stage1-4b-capmw125u-20260904 step 32000: the released mixture, trained before this PR, so it saw the numbered caption tag and never saw the OCR tags.

Task v1 32k v2 32k Reference, same harness
dense_caption_captioner, judge avg 57.1 56.9
pixmo_points_eval_mp, F1 0.784 0.794
sa_co_gold_subset_mp, F1 0.620 0.681
sa_co_gold_point_4k_mp, F1 (absent-object accuracy) 0.540 (0.461) 0.837 (0.843)
pixmo_count / :test, accuracy 0.896 / 0.878 0.904 / 0.876
olmocr_bench, overall 26.5* 51.1 Molmo2-4B 35.4, Qwen3-VL-4B 79.3
cc_ocr_multi_scene_en, macro F1 6.1* 78.4 Molmo2-4B 72.8, Qwen3-VL-4B 78.1
omnidocbench_no_cdm_en (v1.6), text edit, lower is better 0.980* 0.247 Molmo2-4B 0.442, Qwen3-VL-4B 0.046
omnidocbench_v15_no_cdm_en, text edit 0.980* 0.236 Molmo2-4B 0.445, Qwen3-VL-4B 0.041

* v1 answers the untrained OCR tags with a points tag, so these are the empty-answer floor. References are the #412 OCR runs restricted to the same English subsets and pages. Steps 24000 and 28000 score within about a point of step 32000 on every task. The SA-Co gain is refusal: the v2 data adds absent objects, and present-object accuracy only moves 0.993 to 0.979.

Verification

Known gaps

  • v2 pointing has no per-example point cap, unlike v1 (max_total_points_per_example=60). Sampled with the Qwen3 tokenizer: 4.0% of v2 examples exceed 2,560 tokens and 4.9% of their loss tokens are truncated, against 0% for v1. The images and labels are otherwise identical (pointing 152,858 images / 2,023,407 labels; counting 70,714 / 310,025). Worth porting the cap before v2 becomes the default.

  • With no mask branches every refusal is a pointing refusal, about 2x mm_olmo's density at equal knobs. p_paired_negatives=0.25 is inherited, not re-tuned.

  • The tar index cache defaults to a container-local directory and is built by every rank.

  • PIXMO_POINTS_V2 defaults to another user's weka directory (the same one mm_olmo reads).

Usage

python src/scripts/train/Molmo2-Stage1.py launch RUN --recipe=v2
python src/scripts/train/Molmo2-Stage1.py launch RUN --pointing_data=v2
python src/scripts/train/Molmo2-Stage1.py launch RUN --ocr_rate=0.15

uwGZQ and others added 6 commits September 3, 2026 02:47
…ge 1

Ports mm_olmo's second-generation pointing data and adds an OCR group to the
stage-1 mixture, all opt-in so the default run is unchanged.

Pointing (mm_olmo PixMoPointV2 / PixMoCountConfigV2, `--pointing_data=v2`):
* pixmo_points_v2.py: PixMoPointsV2DatasetConfig over the audited, image-grouped
  pixmo-points-with-masks-v17 build (VLM audit_result per point set, easy /
  paired absence queries sub-sampled per epoch, optional negative_weight) and
  PixMoCountV2DatasetConfig over count-v2. Row selection is an in-memory pyarrow
  index; field names follow mm_olmo's.
* sft_formatter.py: aux_pointing / aux_point_count marker styles for
  audit-failed points (same prompt pool and answer as the base style, different
  style token), base_pointing_style().
* pixmo_points.py: _build_example takes per-branch loss weights.
* Molmo2-Stage1.py: pointing_data selector with nested pointing_v2 / count_v2
  configs; the v2 group is split linearly by size (mm_olmo size_weighted=1).

OCR (`--ocr_rate`, `--ocr_sources`, bare `<style>:` tag = style_and_length_v3):
* olmocr.py: OlmOcrMixDatasetConfig (mm_olmo OlmOcrMixConfig) over the four
  olmOCR-mix-1025 subsets, pages rendered from PDFs with pypdfium2 at a sampled
  longest side, English filter, "No text found" for blank pages.
* ocr_caption_tars.py: OcrCaptionTarsDatasetConfig over the oe-encoder
  webdataset-style tars (<key>.jpg|png + <key>.json); TarShardIndex scans shard
  headers once and caches member offsets as .npz.
* mixtures/ocr.py: registry of 20 OCR sources (olmocr / ocr_caption /
  scene_text styles) and build_ocr_source(). s2pdf and iabooks are registered
  but left out of DEFAULT_OCR_SOURCES: 97.4% / 99.4% of their pages are already
  in olmOCR-mix documents / books train (none in eval); the script warns if
  both renderings of the same pages are selected.
* pixmo_cap.py: style_length_prefix / style_tag_prompt shared with the OCR
  sources. message_sequence.py: encode_sft_example accepts a float
  message_weight (matching its runtime behaviour).
* paths.py: PIXMO_POINTS_V2, OLMOCR_MIX, OE_ENCODER_DATA (env-overridable).

Tests: pixmo_points_v2_test.py, olmocr_test.py, ocr_caption_tars_test.py.
…tar index

Six fixes from Jason's review of a6d307f, plus the two documentation
corrections it asked for.

Changes what the model trains on:

* Negatives now rotate across epochs. `example_rng` was mm_olmo's derivation
  with `epoch` pinned to 0, and neither data loader passed an epoch to its
  sources, so `n_easy_samples` / `p_paired_negatives` redrew one fixed subset
  forever instead of sub-sampling per epoch as documented. `example_rng` gains
  mm_olmo's `+ len(dataset) * epoch` term (dataset.py:70-73), a shared
  `EpochSeededExamples` mixin derives per (row, epoch) streams, and both loaders
  call `set_epoch` from `reshuffle`. Measured on the v17 build: the paired-negative
  pool is 67.8% covered after the four epochs the pointing group runs, against the
  25.0% a pinned epoch repeats. Epoch 0 is bit-identical to before, so nothing
  already run changes.
* `PixMoCountV2Dataset.keep` drops blank / null labels and null points, and its
  row filter now mirrors it. A blank label did not crash; it trained "pointing:"
  against an empty-named <points> tag.
* `_size_fractions` rejects an empty source by name instead of handing it weight
  0 (silently dropped by the loader) or dividing by zero into NaN weights.

Aborts the run:

* `PixMoPointsV2Dataset.keep` rejects a null `points`, matching the row filter,
  which tolerates one. A row pairing a good annotation with a null one was
  admitted and then raised TypeError in `format_row`.
* Tar index keys are stored as unicode. numpy encodes str through the ASCII
  codec, so one non-ASCII member name raised UnicodeEncodeError from `__init__` --
  at mixture-build time, where the loader's error tolerance does not apply.
  The cache filename carries a format version so v1 caches are ignored, and an
  unreadable cache is rebuilt rather than fatal.
* Both OCR sources build through `sft_common.get_example_with_skip`, so a row with
  no usable target substitutes the next one instead of spending the loader's error
  budget. Two tests that asserted the raise now assert the skip.

Also from the review:

* `CocoTrain` is described correctly: it is a segmentation source (`pixmo_seg`,
  bboxes + RLE, no points on positives), not detection-as-pointing, so it stays
  unported for the same reason the mask branches do.
* The `text_rich_*` tars carry only mm_olmo's `mid_level` caption -- verified
  byte-identical on chart/HTMLChartPipeline_area_0-0, where high/mid/low are
  145/645/2262 chars -- so that group is a fifth of `figure_ocr` and the OCR group
  is not mm_olmo's OCR mixture. Recorded in mixtures/ocr.py; a three-level loader
  is left to the follow-on.
* Quantified the `include_masks` question: mm_olmo's filter admits 220,314 rows
  against our 220,291 (+0.010%), so the linear split inside the v2 group is
  effectively unchanged. Dropping the mask branches does, however, make every
  refusal a pointing refusal where mm_olmo sends about half to segmentation
  (`zero_points_as_segmentation=0.5`), so this port shows ~2x mm_olmo's
  pointing-refusal density at equal knobs. Both documented.

Unasked but adjacent, from the findings Jason listed and set aside:

* Shard indexing was quadratic in shard size (`stem not in order` scanned a
  list); a set makes a 20k-sample shard 5.80s -> 0.77s, 40k 25.2s -> 1.2s.
* `--ocr_tars.dataset_path` / `.style` / `.strip_text_tags` were accepted, saved
  into the run config and then overwritten per source. They are refused now, and
  `--ocr_data_root` relocates the tar tree for real.
* The index temp file carries a uuid, not just the pid (two hosts sharing a cache
  filesystem can collide), and is cleaned up if the write fails.
The v2 pointing and OCR sources added here are stage-1 sources, but they
carried SFT-stage surface: the v2 pointing configs defaulted to the SFT
prompt family (`uber_model_v2` templates + `demo_or_style_v2`), the same
wrong-by-default shape that cost ~11 f1 on pixmo_point_eval_v3_mp before
#836, and the OCR sources accepted the `demo_or_style` families.

* `PixMoPointsV2DatasetConfig` / `PixMoCountV2DatasetConfig`: remove the
  `prompt_templates`, `system_prompt` and `p_high_res` fields. The prompt
  family is now the fixed `STAGE1_PROMPT_FAMILY` (bare lowercased label
  behind "<style>:", as recorded in the released Molmo2-4B-Pretrain
  formatter). `loss_token_weighting` defaults to "none", what stage 1 runs.
* `STYLE_TAG_FAMILIES` / `style_tag_prompt`: pretraining families only
  (`style_and_length`, `_v2`, `_v3`, `none`); `demo_or_style_v2/_v3` are
  refused by both OCR configs' `validate()`.
* `OlmOcrMixDatasetConfig` / `OcrCaptionTarsDatasetConfig`:
  `loss_token_weighting` defaults to "none" (a no-op for these
  single-branch sources; the script already passed it).
* Molmo2-Stage1.py passes only the loss weighting to the v2 configs.

No change to what a stage-1 run trains on: the script already selected
these values. `--pointing_v2.system_prompt=...` and
`--olmocr.system_prompt=demo_or_style_v2` now raise instead of being
accepted.

Tests: src/test/data/multimodal/ 224 passed (torch 2.11, CPU), including
the real-PDF render test with pypdfium2 installed.
Audit of every new source against its held-out data, and a guard wherever
the data itself does not enforce the split.

Pointing / counting
* `pixmo-points-with-masks-v17` is exactly the two v1 train splits
  (152,858 + 70,714 = 223,572 rows), 0 overlap with `pixmo-points-eval`
  (431 urls) and `pixmo-points-eval-v3` (1,211 images), and 1 image shared
  with the v1 `points-counting` validation split.
* `count-v2` ships `validation` / `test` splits that are copies of `train`
  (36,411 of 36,411 sha256 in common), so they are not held-out data; and its
  train split shares 15 of the 540 real PixMo-Count test images.
* Both configs gain `heldout_paths` (default: the real validation / eval
  sets) and drop any row whose image appears in one: -1 and -15 rows on the
  weka builds (220,291 -> 220,290; 36,916 -> 36,901). An unreadable held-out
  set fails the build instead of passing. `PixMoCountV2DatasetConfig.split`
  is removed; only `train` is read.

OCR
* olmOCR-mix: the training script refuses any `olmocr.split` but train.
* The `text_rich_*` tars hold every image of mm_olmo's build, including the
  2,048 per category it holds out: 4 of 1,000 sampled keys are validation ids
  in both `chart` and `table` (base rate 0.58% / 0.64%). Tars have no splits,
  so `OcrCaptionTarsDatasetConfig` gains `heldout_paths` and drops those keys;
  the registry wires each `text_rich_*` source to its `hf/<category>` build.
* TextCaps / TextOCR: 1,200 keys sampled from the first, middle and last
  shard of each are all TextVQA train images (0 of 3,166 val, 0 of 3,289 test).
* HierText / COCO-Text / UberText have official val / test splits, synthetic
  tar keys and no split in their metadata, so their split cannot be
  established. Registered, no longer default (`SPLIT_UNVERIFIED_SOURCES`);
  selecting one logs a warning. Default OCR group: 19 -> 16 sources.

Also
* `validate_data_config` is split out of `build_config`, which resolves the
  Beaker launch and so needs cluster access and a pushed commit; the two
  tests that went through it now run anywhere.
* `--ocr_tars.heldout_paths` is refused like the other per-source fields.
* Two cosmetic reformatting hunks outside the stage-1 data path are reverted.

Tests: src/test/data/multimodal/ 237 passed (torch 2.11, CPU).
…ions

The OCR group is narrowed to general OCR data: an image in, its text (or a
description of a text-rich figure) out, and no question in the prompt.

* Add `TextRichCaptionDatasetConfig` (mm_olmo `TextRichCaptionConfig`, its
  `figure_ocr` group): each image carries `high_level` / `mid_level` /
  `low_level` captions, emitted as three branches under
  `ocr_caption_{high,mid,low}_level:`. It reads the `train` split of the HF
  build and has no option to read anything else (2,048 rows per category are
  held out there; 0 ids shared with train). On weka: chart 353,439 rows,
  doc 438,267. With the Qwen3 tokenizer and 8 crops an example is ~1.7k-2.0k
  tokens (caption medians 30 / 154-199 / 395-600), and 1 of 80 sampled
  examples exceeds the 2,560-token training length.
* Remove the single-caption `text_rich_caption_v6_tars` sources, which are the
  same images with only the mid-level caption, and with them the tar loader's
  `heldout_paths`, whose only use was excluding that build's validation rows.
* Remove the Cambrian subsets (images from VQA datasets, machine-recaptioned)
  and TextCaps (five reference captions joined): neither is "read the text off
  the image", and they are left for a later stage. 21 sources -> 15, default
  16 -> 10: four olmOCR-mix subsets, five figure-caption categories, TextOCR.
* Split the OCR rate by task before size. A flat sqrt(size) split gives the
  figure captions 72.7% of the rate and page transcription 23.0%, because each
  figure category is larger than all of olmOCR-mix. mm_olmo spends 0.075 on
  each of its two OCR groups, so the rate is now halved between transcription
  and figure captions, then split by sqrt(size) within each.
* Refuse `--olmocr.subset` and `--text_rich.category`, which
  `build_ocr_source` overwrites per source, as `--ocr_tars.*` already was.
* No segmentation: a test pins that masks in the v17 data never produce a
  branch or rescue an over-`max_points` annotation, and that neither v2 config
  has a mask option.

Tests: src/test/data/multimodal/ 266 passed (torch 2.11, CPU).
`PixMoCapDataset` built the conditioned user turn as the length tag followed by
a sampled instruction: "long_caption 63: Describe this image.". Neither side
of the comparison uses that form:

* mm_olmo's stage-1 scripts (`train_captioner.py`, `train_molmo3_stage1.py`)
  leave `DataFormatter.prompt_templates` at "none", under which a caption's
  question is the empty string, so they train on "long_caption 63:".
* The stage-1 caption eval (olmo-eval `dense_caption_captioner`, mirroring
  mm_olmo's `default_inference_len=65`) sends "long_caption 65:".

So training saw a sentence that the reference never trains on and that the
model never sees at test time. The conditioned turn is now the tag alone, for
both the caption and the transcript branch; train and test share one form.

`style_length_conditioning=False` still gives the un-tagged natural-language
prompt, and `fixed_prompt` is unchanged. The per-example RNG stream shifts by
the one draw that picked the sentence, so length buckets for a given index
differ from earlier runs; the distribution does not.

Tests: src/test/data/multimodal/ 158 passed (torch 2.11, CPU).
@jason718 jason718 changed the title Molmo2 stage 1: mm_olmo v2 pointing data and an OCR group, train splits only Molmo2 stage 1: tag-only caption prompt, mm_olmo v2 pointing data, and a general OCR group Sep 21, 2026
The caption user turn is now `long_caption:` and the transcript turn
`transcript:`, with no length number. Before, the tag carried mm_olmo's
length hint (the answer's character count // 15 with N(0, 25) noise, dropped
10% of the time; a fixed 65 at inference), so training and test shared a
form but never a value. Over the 714,985 training captions the number had
median 65 and ran 41-105 for the middle 90%, so the eval's 65 asked for a
typical-length caption anyway; what is lost is the ability to request a
length at test time, which nothing in this repo uses.

* `PixMoCapDatasetConfig.style_length_conditioning` -> `style_tag`: the tag
  is the whole user turn; `False` still gives the un-tagged natural-language
  prompt, `fixed_prompt` still overrides.
* `style_tag_prompt(style, system_prompt)` loses its `text` / `rng`
  parameters: every `style_and_length` family renders the bare tag, so the
  OCR sources cannot get a number under `_v2` either. `style_length_prefix`
  and the bucket constants are removed.
* `OlmOcrMixDataset.user_prompt()` and `TextRichCaptionDataset.turns(row)`
  drop their now-unused arguments.

The eval side (olmo-eval `dense_caption_captioner`, which sends
`long_caption 65:`) is changed separately to send `long_caption:`.

Tests: src/test/data/multimodal/ 267 passed (torch 2.11, CPU).
…inting

Two prompt renames, both so a tag says what the task is.

* `ocr_caption_{high,mid,low}_level` -> `figure_caption_{high,mid,low}_level`.
  All three levels describe a text-rich figure; none transcribes it, not even
  the most detailed, which quotes the text inside a description. mm_olmo's
  name for them is `ocr_caption_<level>`; the docstring records that.
* CoSyn pointing now carries the `pointing:` tag under the stage-1 family,
  so stage 1 has one pointing tag and no image source without a tag. Its
  question stays the English sentence stored in the data, which is what
  distinguishes it from the PixMo sources' bare label:
  `pointing: Find the button that submits the form.` mm_olmo tags it
  `cosyn_point:`. Under the SFT family the question is still sent as
  written, so `image_only_v9` is unchanged.

`CoSynPointDatasetConfig` gains `dataset_path` (same default as the path it
had hardcoded) so the source can be built from a fixture; that is what the
two new tests do.

Tests: src/test/data/multimodal/ 269 passed (torch 2.11, CPU).
The OCR sources (olmOCR-mix, caption tars, figure captions) no longer take
a `system_prompt` family: their user turn is always the bare `<style>:` tag,
as the v2 pointing sources already fix their family. This removes
STYLE_TAG_FAMILIES, OCR_SYSTEM_PROMPT and the tests that refused the SFT
families. Also reverts the aux_* change to the formatter's natural-language
template path, which only stage 2 reaches, and drops the SFT-family CoSyn
test and the stage-2 wording this PR added.
Its question is an English request stored in the data, and its names column
is a short summary written for the answer's label, so the request cannot be
reduced to an object name. A tag of its own keeps pointing: meaning that an
object name follows.
…,low}

The level is already in the tag, so the _level suffix only made it longer.
The dataset's column names (high_level / mid_level / low_level) are unchanged.
The tag names the task, not the dataset it came from. mm_olmo calls the style
olmocr; the config field and module keep that name, as they refer to the
olmOCR-mix dataset.
Each tag names the output form it asks for: olmOCR's page transcription
(reading order, HTML tables, LaTeX math) or TextOCR's scene text (the text in
a photo, joined by spaces). olmocr is also mm_olmo's name for the page style.
The non-default scene-text sources take the textocr form too.
Two synthetic transcription sources, English train splits only, both in the
default OCR group:

* nvidia_synth_en: nvidia/OCR-Synthetic-Multilingual-v1 en/train (1,460,304
  images, CC BY 4.0), read from its HDF5 files. The images are words
  scattered over photos or flat colours, often vertical, so it is tagged
  textocr: with TextOCR's answer form. The dataset's `labels` join the words
  in source-sentence order, which only 16% of images show visually, so the
  target is rebuilt from the line boxes in visual reading order.
* synth_receipts_en: albertobarnabo/synthetic-receipts-ocr, US and UK
  locales of the train split (16,437 receipts, Apache 2.0), photo-degraded
  image, tagged olmocr:. The target is the printed lines with the price
  column padding collapsed and rule lines dropped. The English train rows are
  converted once to an Arrow dataset (prepare_synthetic_receipts), since the
  parquet row groups hold hundreds of inline images each.

The launch installs h5py next to pypdfium2.
… receipt:

The NVIDIA set's synthetic scattered text is now learned apart from TextOCR's
real photos, and the receipts apart from olmOCR's page transcriptions. The
answer forms are unchanged.
… receipt_ocr

`--recipe` picks the data mixture before the merge, as a set of defaults:

* v1 (default): the released Molmo2-4B-Pretrain mixture, unchanged: caption
  0.6, pointing and counting 0.3 on the v1 sources, Tulu text 0.1, no OCR.
* v2: caption 0.5, pointing and counting 0.25 on the v2 sources, OCR 0.25
  on the default OCR sources, no text-only data.

An explicit --pointing_rate / --nlp_rate / --ocr_rate / --pointing_data still
overrides the recipe's value, and the recipe is recorded in the config.

The NVIDIA synthetic set is now tagged synth_ocr: and the receipts
receipt_ocr:.
…argest real one

sqrt(size) still gave the 1.46M NVIDIA images the biggest share of
transcription on size alone (6.59% of the v2 mixture, more than the four
olmOCR-mix subsets together), while a run sees under half of them. Its
weighting size is now capped at the largest real source of the same task, so
it counts as olmOCR-mix documents (231,668): both get 3.84% of the v2
mixture. The receipts are below the cap and unchanged in rule.
…test and docs

A run weights by each dataset's length, which for olmOCR-mix is after the
default English filter (documents 218,831, not the 231,668 parquet rows), so
the cap puts NVIDIA at 218,831 and both at 3.82% of the v2 mixture. The code
was already right; the numbers in the test, the comment and the previous
commit message used the unfiltered row counts.
…_cosyn_point:

mm_olmo's CoSynPointConfigV2 build (cosyn-point-v2-masks) has the v1 build's
68,051 train images, questions, points and names unchanged, plus a
per-question VLM audit (81.7% correct, 17.3% clear_error, 1.0% error on a
1-in-20 sample) and agent masks. The v2 pointing group now reads it with
the masks ignored (segmentation is not trained here) and the ~18% of
questions that failed the audit kept behind their own tag, aux_cosyn_point:.
mm_olmo tags them aux_pointing:; the own tag keeps aux_pointing: followed by
an object name.

CoSynPointDatasetConfig gains an optional audit_style; the v1 recipe and
stage 2 are unchanged.
@jason718 jason718 self-assigned this Sep 26, 2026
@jason718
jason718 marked this pull request as ready for review September 26, 2026 08:30

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

ℹ️ 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 on lines +629 to +632
if config.pointing_rate + config.nlp_rate + config.ocr_rate > 1.0:
raise OLMoConfigurationError(
"pointing_rate + nlp_rate + ocr_rate exceeds 1: nothing is left for the caption source"
)

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 Reject negative mixture rates

A negative --ocr_rate passes this validation: _build_mixture_sources() then omits OCR because o > 0 is false, but still subtracts the negative value when calculating the caption weight. For example, with the default pointing/NLP rates and --ocr_rate=-0.1, the unnormalized weights become 0.7/0.3/0.1 and MixtureDataLoader silently renormalizes them, changing the caption/pointing/NLP distribution instead of rejecting the invalid configuration. Validate each mixture rate as finite and within [0, 1] (the same applies to the other two rates).

Useful? React with 👍 / 👎.

CheckpointerCallback's default max_checkpoints=3 deleted the v2 run's
step 8000 and 16000 checkpoints before they could be evaluated.
@jason718
jason718 merged commit 42e65ea into vision Sep 29, 2026
1 check passed
@jason718
jason718 deleted the jasonr/stage1-pointing-v2-ocr branch September 29, 2026 04:22
jason718 added a commit that referenced this pull request Oct 1, 2026
…llbacks and recipe from #869

Squash of two port commits (the first one's tree object was corrupted by an interrupted write).

Port the vision alignment data adapters and evaluators' data layer from #869

The multimodal data package gains RustinS's alignment sources: the document
(native EOS-prefixed) message layout next to the qwen3 one, the
PretrainingReplayDataset that replays a text checkpoint's own pretraining
windows, the perception-phase OCR/audited adapters, strict Arrow-split
validation with content fingerprints, grouped mixture quotas, and the
matching tests. Files that vision had also changed since the fork (#875,
#894) are merged by hand, keeping vision's behavior:

- pixmo_points: `_build_example` accepts both the branch-list convention used
  by vision's stage-1 sources (qwen3 layout, branch weights) and the callable
  convention of the alignment adapters (document layout, strict validation);
  CoSyn keeps the audited-build prefixes and gains split/fingerprint options.
- pixmo_cap: vision's bare style tag and prompt pools stay the default; the
  document layout, transcript validation and length conditioning (opt-in,
  `style_length_conditioning`) are added for the alignment adapters.
- sft_common / sequence_builder / message_sequence: union of both sides
  (epoch-seeded examples from vision, message formats and bounded datasets
  from the alignment recipe).

Two pieces of logic that #868/#869 had placed in shared code move here so the
shared files stay untouched: the per-occurrence metadata alignment for
weighted source mixtures that drop zero-allocation paths (now done by the
replay adapter), and a filesystem cache decorator whose directory comes from
`OLMO_CORE_DATA_VERIFICATION_CACHE_DIR` (`data/multimodal/fs_cache.py`).


Add the OLMoDDP vision alignment train module, callbacks, evaluators and recipe

Builds the three-stage alignment recipe (bridge, perception, joint) from #869
as a multimodal-only layer on the OLMoDDP hooks:

- MultimodalOLMoDDPTrainModule: supplies the weighted response-only loss
  divisor and the valid-token router divisor through
  `_batch_auxiliary_loss_kwargs`; freezes parameters by pattern, restricts
  embedding gradients to the image-token rows, checkpoints frozen parameters
  as `frozen_model.*`, and loads both those checkpoints and native text
  checkpoints (no `lm.` prefix, fresh vision/connector state kept) through
  the `_optimizer_state_dict_for_load` / `_after_load` adapters. Held-out
  multimodal batches return the summed weighted loss; text-only downstream
  batches keep the standard full-logits path.
- train/callbacks/multimodal.py: model initialization from a text checkpoint
  plus a SigLIP tower, the held-out response-loss evaluators, and subclasses
  for W&B run resume and rewritable same-step metric snapshots (with
  `RestoreMetricsCallback`), replacing the shared-callback edits of #868.
- eval/: decoded, academic and fast-text evaluation of alignment checkpoints
  (`scipy` is imported lazily by the pointing metrics).
- internal/vision_alignment*.py and the Vision-Align scripts: the recipe now
  builds `MultimodalOLMoDDPOptimizerConfig`, sets `PYTHONPATH` in its own
  launch env, restores a missing `launch` on config load, and writes
  completion markers through an overwrite-capable helper instead of a
  trainer-wide overwrite policy.

Not carried from #868/#869: the router token mask (padding takes part in
routing statistics), the rowwise-EP forward-only eval dispatch, and the
compiled-flex mask routing; the corresponding tests are dropped.
jason718 added a commit that referenced this pull request Oct 2, 2026
… steps); drop TallyQA's COCO val2017 images (#887)

Based on `vision` at 05885ef (after #875, #893, #894 and the v3.0.0
main sync).

Stage 1 is going to be mixed into text midtraining, which has about 100B
text tokens, so it needs more distinct multimodal data than PixMo-Cap's
~717k images, which a stage-1 run already sees about 4 times. This PR
adds:

1. **An academic QA group** (`--academic_rate`): stage 2's large
synthetic QA sets, copied into stage 1 (stage 2 keeps them). The
training set of a benchmark stage 2 is evaluated on is never a source.
2. **A PixMo-Clocks group** (`--clock_rate`), so clock reading can be
learned without stage 2.
3. **A `v3` recipe** for 50,000 steps: caption 0.33, pointing and
counting 0.16, OCR 0.34, academic QA 0.14, clocks 0.03. The default
recipe stays `v1` at 32,000 steps.
4. **TallyQA without COCO val2017 images.** This changes stage 2 too,
which reads TallyQA's train split.

It also makes the stage-1 prompt family tag every style, which the new
sources depend on ([Prompt](#prompt)).

## Results

The v3 run `molmo2-stage1-4b-v3-50k-20260930`
([beaker](https://beaker.org/ex/01M3R9285B5GT234XXQ644NSR8), 4×8 B300 on
holmes, 50k steps, finished 2026-10-01) trained this PR's code at
`163d1c1f9` (this PR plus #893). Every file this PR touches is identical
to the launch commit, except the removal of the unused share caps, which
leaves the mixture weights unchanged (max difference 6e-17).

All rows are from olmo-eval #412 with the stage-1 prompts (`-o
prompt_templates=none -o system_prompt_style=style_and_length_v2`). v3
and the released checkpoint were scored at #412's `5fc8fa21`. v1 and v2
were scored on 2026-09-27 at `f1f3b2b3`; the caption, pointing and
counting task code is the same at both commits.

| Metric | Released Molmo2-4B-Pretrain | v1 32k | v2 32k | **v3 50k** |
|---|---|---|---|---|
| Caption avg | **57.7** | 57.1 | 56.9 | 56.8 |
| Caption recall | **44.3** | 43.1 | 43.1 | 43.6 |
| Caption consistency | **71.1** | 71.0 | 70.8 | 69.9 |
| PixMo-Points F1 | **81.5** | 78.4 | 79.4 | 78.2 |
| SA-Co Gold subset F1 | 66.3 | 62.0 | **68.1** | 67.2 |
| SA-Co Gold 4k F1 | 55.7 | 54.0 | **83.7** | **83.7** |
| SA-Co Gold 4k absent-object accuracy | 48.0 | 46.1 | 84.3 | **84.7** |
| PixMo-Count val | 88.5 | 89.6 | 90.4 | **91.3** |
| PixMo-Count test | **88.0** | 87.8 | 87.6 | 85.2 |
| olmOCR-Bench | 26.5 | 26.5 | 51.1 | **54.0** |
| CC-OCR multi-scene, English (macro F1) | 19.6 | 6.1 | 78.4 | **79.2**
|
| OmniDocBench v1.6 English, text edit (lower is better) | 0.971 | 0.980
| 0.247 | **0.211** |
| OmniDocBench v1.5 English, text edit (lower is better) | 0.970 | 0.979
| 0.236 | **0.212** |

* **OCR improves.** Against v2: olmOCR-Bench +2.9, CC-OCR +0.8, and
OmniDocBench text edit 0.036 lower on v1.6 and 0.024 lower on v1.5. With
formula grading (CDM), v3's OmniDocBench overall is 66.7 on v1.6 and
70.3 on v1.5. The v1/v2 eval skipped CDM, so OmniDocBench is compared on
text edit only. 9 of the 755 v1.6 pages failed to score for v3.
* **Caption and pointing are flat to about 1 point lower.** Caption avg
is 56.8 against v2's 56.9 (recall +0.5, consistency −0.9). PixMo-Points
F1 is −1.2 and the SA-Co subset −0.9; SA-Co 4k is unchanged. v3 sees
caption and pointing data about as often as v2 does (4.2 and 4.4
passes), at lower rates over more steps.
* **Counting is mixed.** Val is +0.9 and test −2.4. All answers parse.
* **Longer training would not help.** v3 at step 40,000 is within about
1 point of step 50,000 on every caption, pointing, olmOCR-Bench and
CC-OCR metric (OmniDocBench was not run at 40k). v2's 24k, 28k and 32k
checkpoints were also within about 1 point of each other.
* **The released checkpoint** was trained on 0.6 caption and 0.3
pointing. It still leads on caption (+0.9 avg over v3) and PixMo-Points
(+3.3), but its SA-Co 4k score is 28 points lower: it handles only 48%
of absent-object queries correctly, against v3's 85%. It has no OCR
training. Its scores reproduce mm_olmo's own eval of it: PixMo-Points
81.5 vs 81.6, SA-Co 4k 55.7 vs 55.5. Its caption prompt here is
`long_caption:` rather than the `long_caption 65:` it was trained on;
mm_olmo with that prompt gets avg 58.1 and recall 45.6.
* **What these evals do not measure** is the academic QA group (9.1% of
v3's loss). Its effect, if any, shows after stage 2 or midtraining.

## Which stage-2 sets go into stage 1

**Rule: the training set of a benchmark the stage-2 checkpoints are
evaluated on stays stage-2 data.** The stage-2 image evals (mm_olmo
`eval_molmo2.py` `IMAGE_TASKS` / `TEST_IMAGE_TASKS`) are VQAv2, TextVQA,
ChartQA, DocVQA, InfographicVQA, AI2D, A-OKVQA, MMMU, RealWorldQA,
MathVista, Point-Bench, CountBenchQA and PixMo-Count.
`STAGE2_EVAL_TRAIN_SETS` lists the sets this rule keeps out, and both
the dataset class and the training script refuse them:

| Stays in stage 2 | Train images | Benchmark |
|---|---|---|
| `coco_2014_vqa_multi` | 82,783 | VQAv2 |
| `doc_qa` | 39,463 | DocVQA |
| `text_vqa` | 34,602 | TextVQA |
| `chart_qa_weighted` | 28,299 | ChartQA |
| `info_qa` | 23,946 | InfographicVQA |
| `a_okvqa_mc` / `a_okvqa_da` | 17,056 | A-OKVQA |
| `ai2_diagram_v2_mix_transparent` | 15,042 | AI2D |
| `tally_qa` | 127,867 (after the filter below) | VQAv2, through shared
val2014 images |

The rest of stage 2's single-image academic data becomes the stage-1
group. The group's rate is split by sqrt(size), with stage 2's row caps
(`image_only_v9` `root_size_factor`) on the three templated chart sets.
Without the caps, those sets would take 44.0% of the group instead of
18.8%:

| Source | Train images | Weighted as | Share of group | Share of v3
mixture |
|---|---|---|---|---|
| `cosyn_chart_exp` | 116,814 | 116,814 | 18.83% | 2.64% |
| `cosyn_document` | 71,282 | 71,282 | 14.71% | 2.06% |
| `cosyn_math_exp` | 66,714 | 66,714 | 14.23% | 1.99% |
| `cosyn_table_exp` | 46,518 | 46,518 | 11.88% | 1.66% |
| `cosyn_diagram_exp` | 34,963 | 34,963 | 10.30% | 1.44% |
| `cosyn_music_exp` | 11,969 | 11,969 | 6.03% | 0.84% |
| `cosyn_chemical_exp` | 8,942 | 8,942 | 5.21% | 0.73% |
| `plot_qa` | 157,070 | 20,000 | 7.79% | 1.09% |
| `dv_qa` | 200,000 | 10,000 | 5.51% | 0.77% |
| `figure_qa` | 100,000 | 10,000 | 5.51% | 0.77% |

* **PlotQA trains 20 of its questions per image per epoch**, drawn
afresh each epoch (`STAGE1_DEFAULT_MAX_QUESTIONS`; an explicit
`max_questions` still wins). Its images carry 131 questions on average,
and most full examples exceed the 2,560-token stage-1 sequence. With 20
questions, none of 300 sampled images overflowed (max 2,437 tokens).
* **Left out:** OKVQA, ST-VQA, ScienceQA and TabMWP (6k–25k images each,
too small to matter), and every multi-image source.
* **CoSyn is closest to the line.** Its chart, document and table
categories were built to improve ChartQA, DocVQA and InfographicVQA. It
is not their training split, so the rule allows it. It is the set to
drop first if the rule should be read more strictly.
* **Overlap with the OCR group:** 267,359 of CoSyn's 357,202 images are
also in the OCR group's figure-caption sources, so for those the group
adds QA on images v3 already describes. The images a v3 run sees only
through this PR: 546,913 (CoSyn's other 89,843, DVQA, FigureQA, PlotQA),
plus PixMo-Clocks.

## PixMo-Clocks: a group of its own

800,269 synthetic clock faces, all asking the same question. They teach
one narrow skill, so the group gets its own rate (`--clock_rate`; 0.03
in v3) instead of a share of the QA group. Clocks may later leave stage
2, which would leave stage 1 as the only place the model learns to read
them. v3 trains about 271k clock examples (0.34 passes). That is roughly
40–70% of what the released Molmo2-4B stage 2 trained, at 2.0% of v3's
tokens and 0.08% of its loss.

The user turn is `clocks: What time is being shown?` and the answer is
the time (`The time shown is 3:02 PM`). The question stays in because,
without stage 2, it would be the only clock question the model ever
sees. Naming `pixmo_clocks` in `--academic_sources` is refused with a
pointer to `--clock_rate`.

## The v3 recipe

`--recipe=v3` adds the academic and clock groups to v2 and raises OCR.
It runs 50,000 steps (`RECIPE_MAX_STEPS`; an explicit
`--trainer.max_duration.value` still wins). The rates were chosen
against the sources themselves: 80 sampled examples per source (all 27,
built as the script builds them), packed by the script's 2D-knapsack
packer (2,560 tokens, 27 crops). That gives 1.41 examples per sequence,
so 50k steps are 9.0M examples.

| | v2 (32k steps) | **v3 (50k steps)** |
|---|---|---|
| Rate: caption / pointing / OCR / academic / clocks | 0.50 / 0.25 /
0.25 / 0 / 0 | **0.33 / 0.16 / 0.34 / 0.14 / 0.03** |
| Loss share: caption | 55.1% | 39.2% |
| Loss share: pointing and counting | 18.5% | 12.8% |
| Loss share: OCR | 26.5% | 38.9% |
| Loss share: academic QA | | 9.1% |
| Passes over PixMo-Cap (715k) | 4.0 | 4.2 |
| Passes over the pointing sources (325k) | 4.4 | 4.4 |
| Passes over the OCR sources (3.09M) | 0.46 | **0.99** |
| Passes over the academic group (814k) | | 1.55 |
| Synthetic share of examples / loss | 22.6% / 20.7% | 44.0% / 38.5% |

* **OCR 0.34 gives one pass over the OCR group**: 3.07M OCR examples for
its 3.09M rows. The pass is uneven within the group, which is still
split by task and then sqrt(size). The figure captions get about 1 pass,
olmOCR documents 2.1, the small olmOCR subsets, TextOCR and the receipts
7–10, and NVIDIA's 1.46M synthetic images 0.32.
* **Most of the synthetic rise is OCR** (figure captions, NVIDIA,
receipts). CoSyn is 95% of the academic group's loss because its answers
carry explanations. DVQA, FigureQA, PlotQA and the clocks together are
about 0.5% of the loss.
* **For midtraining these are shares of the multimodal part.** If that
part grows, every pass count grows with it.

## Prompt

Stage-1 sources send a `"<style>:"` tag and no template. An academic
source sends the tag followed by the bare question:

| Source | User turn | Answer |
|---|---|---|
| `plot_qa` | `plot_qa: Is the sum of the use of imf credit in dod in
2003 and 2007 greater than ...?` | `Yes` |
| `dv_qa` | `dv_qa: What percentage of people like the least preferred
object in the whole chart?` | `10` |
| `cosyn_chart_exp` | `cosyn_chart_exp: What's the average investment in
Transportation between 2003 and 2022?` | `<explanation> Answer:
<answer>` |
| `pixmo_clocks` | `clocks: What time is being shown?` | `The time shown
is 3:02 PM` |

Two `SftFormatter` fixes for the stage-1 family
(`prompt_templates="none"`, `system_prompt="style_and_length_v2"`),
which had only been used with pointing data:

* **Every style is tagged.** Before, only the pointing styles got
`"<style>:"`. mm_olmo tags every style under this family; the length
number it adds to non-pointing styles is dropped here, as #875 dropped
it from the caption tag. That matches mm_olmo's molmo3 stage-1 family
(`style_and_length_v3`). The pointing sources are unaffected.
* **No chain-of-thought instruction under `"none"`**, as in mm_olmo
(`data_formatter.py:1933-1934`); the `*_exp` tag is what asks for the
explanation. The stage-2 family keeps the instruction.

Multiple choice under `"none"` raises `NotImplementedError` (mm_olmo's
`format_options` layout is not ported); no stage-1 source is multiple
choice.

## TallyQA: drop its COCO val2017 images

TallyQA's train split holds the 5,000-image COCO val2017 set, both under
2014 file names and through Visual Genome (`image_data.json` `coco_id`).
Those images are dropped; the rest of val2014 is kept.

| TallyQA train | Images | Questions |
|---|---|---|
| Total | 132,981 | 249,318 |
| COCO val2017 images under val2014 names | 4,052 | |
| Visual Genome images that are COCO val2017 images | 1,062 | |
| **Dropped** | **5,114** | **9,578** |
| **Kept** | **127,867** | **239,740** |

The ids come from COCO's `annotations/captions_val2017.json`. The filter
is in the registry's TallyQA loader (train split only), so
`image_only_v9` gets it too: TallyQA's sqrt(size) weight in stage 2
falls by 1.9% relative to the other academic sources. A missing held-out
file fails the build rather than skipping the check.

## Launch note: torchvision

`pixmo_clocks` imports torchvision only when it formats a clock image,
so v1/v2 runs don't need it. A run that trains clocks does. In the
`akshitab/olmo-core-tch2100cu130-2026-07-03` image, the package install
upgrades torch to 2.13.0 and leaves torchvision at 0.25.0, which fails
to import ("operator torchvision::nms does not exist"). The v3 run added
`torchvision==0.28.0` to `post_setup`. Stage 2 trains clocks too, so it
needs the same pin on that image.

## Verification

* `src/test/data/multimodal/`: **324 passed, 7 skipped** on CPU (torch
2.10, rebased branch). The skips are `h5py` / `pypdfium2`, not installed
here. `stage1_academic_test.py` (38 tests) covers:
  * the v3 recipe and its 50k steps, and PlotQA's default cap;
* the clock group: prompt, refusal as an academic source, rate
validation;
  * the prompt family and per-epoch question sampling;
* the TallyQA filter, on synthetic files and against weka (pins 127,867
kept images and 5,000 val2017 ids);
  * refusal of every stage-2 eval training set;
  * the group weights (CoSyn 81.2%, templated charts 18.8%).
* Real data: every v3 source built with the Qwen3 tokenizer as the
script builds it, and 80 examples encoded from each of the 27 for the
recipe numbers.
* black 23.12 and isort 5.13 pass. ruff 0.15.9 (the pinned version)
passes. mypy adds no errors: the changed files have 5 errors, against 7
on `vision`.

## Usage

```
python src/scripts/train/Molmo2-Stage1.py launch RUN --recipe=v3                 # 50k steps
python src/scripts/train/Molmo2-Stage1.py launch RUN --recipe=v3 --clock_rate=0.02
python src/scripts/train/Molmo2-Stage1.py launch RUN --recipe=v3 \
    --academic_sources=[cosyn_chart_exp,cosyn_document,cosyn_table_exp]
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

2 participants