Skip to content

olmo_core_vlm: evaluate each checkpoint with the tokenizer split it trained on - #535

Merged
jason718 merged 1 commit into
jasonr/olmo-core-vlm-olmo35from
rustins/multimodal-tokenizer-json
Nov 20, 2026
Merged

jason718 merged 1 commit into
jasonr/olmo-core-vlm-olmo35from
rustins/multimodal-tokenizer-json

Conversation

@RustinS

@RustinS RustinS commented Nov 3, 2026

Copy link
Copy Markdown

Into jasonr/olmo-core-vlm-olmo35 (#458), on its head 2f383bc7. Companion: allenai/Olmo-core#944, into jasonr/olmo35-mixed-midtraining (allenai/Olmo-core#916). 3 files, +32/-2.

OLMo-core's multimodal mixture now loads the tokenizer exactly as tokenizer.json defines it (dataset.tokenizer_json_split, on by default; companion OLMo-core PR). Earlier runs used AutoTokenizer, which builds GPT2Tokenizer for Dolma2 and splits text with GPT-2's regex: the same IDs, but different tokens (.\n\n is three tokens instead of one).

The provider reads dataset.tokenizer_json_split from the checkpoint's config. When it is true it loads the tokenizer with OLMo-core's load_tokenizer_losslessly, as training did. Otherwise, including every config saved before the setting existed, it keeps AutoTokenizer and the tokens those runs trained on.

Checked end to end on two 20B checkpoints, one per split: the predictions match their earlier evals. Count answers match on all 8 probe questions, and every capped olmOCR-Bench output is an exact prefix of the uncapped one. A unit test covers the decision for true, false and missing values.

🤖 Generated with Claude Code

https://claude.ai/code/session_0159PTUsp2w3YTANVDZ4BUss

…rained on

OLMo-core's MultimodalMixtureConfig now loads the tokenizer exactly as tokenizer.json defines it
(dataset.tokenizer_json_split, on by default). Earlier runs used AutoTokenizer, which builds
GPT2Tokenizer for Dolma2 and splits text with GPT-2's regex: the same IDs, but different tokens.

The provider reads dataset.tokenizer_json_split from the checkpoint's config. When it is true it
loads the tokenizer with OLMo-core's load_tokenizer_losslessly, as training did; otherwise, including
every config saved before the setting existed, it keeps AutoTokenizer and the tokens those runs
trained on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0159PTUsp2w3YTANVDZ4BUss
@RustinS
RustinS requested a review from a team as a code owner November 3, 2026 18:23
jason718 pushed a commit to allenai/Olmo-core that referenced this pull request Nov 6, 2026
…and recalibrate (#944)

Into `jasonr/olmo35-mixed-midtraining` (#916), on its head `4fb33e922`.
Companion: allenai/olmo-eval#535, into `jasonr/olmo-core-vlm-olmo35`
(allenai/olmo-eval#458). Nine commits: the fix, the recalibration it
requires, and seven follow-ups from the Codex review (frozen panels,
resumed runs and their loss calibration, resuming a checkpoint whose
config was not saved yet and recording its recovered split,
academic-eval result definitions). 19 files, +687/-145.

### Problem
`MultimodalMixtureConfig.build_tokenizer` loaded the tokenizer with
`AutoTokenizer`. For Dolma2 that builds `GPT2Tokenizer`, the class its
`tokenizer_config.json` names, and that class splits text with GPT-2's
regex instead of the `Split` regex in `tokenizer.json`. The vocabulary
and IDs are the same, but the tokens are not:

| Text | `tokenizer.json`, as the text mixtures were tokenized |
Multimodal runs until now |
|---|---|---|
| `2024` | `202` `4` | `20` `24` |
| `.\n\n` | `.ĊĊ` | `.` `Ċ` `Ċ` |
| `long_caption:` | `long` `_caption` `:` | `long` `_` `caption` `:` |

So every multimodal run, v3 to v7, trained its vision text on a
different tokenization from its text data: about 6% of the loss-weighted
vision tokens of the stage-1 v6 mixture differ. Removing
`use_fast=False` does not help, because the class, not the slow/fast
choice, replaces the pre-tokenizer. The in-repo academic eval had the
same issue (`GPT2Tokenizer.from_pretrained`).

### Change
- `build_tokenizer` uses `load_tokenizer_losslessly`, the loader the HF
export already uses: it loads `tokenizer.json` with the generic fast
class and validates the backend with `validate_tokenizer_backend`.
Vocabulary, special-token IDs and the Molmo2 image-token IDs are
unchanged, so checkpoints stay compatible.
- `MultimodalMixtureConfig.tokenizer_json_split` (default `True`)
records the choice in every run's config. `False` reproduces the old
load, only to resume or reproduce an earlier run. Evaluation follows the
saved value, and a config saved before this change means the old split:
`vision_academic` here, `olmo_core_vlm` in olmo-eval
(allenai/olmo-eval#535). The provider calls
`load_tokenizer_losslessly(path, revision=...)`, which the eval commit
`8f8ae5df4` already has, and reads the new field as a plain dict entry,
so evaluating on that commit still works.
- `load_tokenizer_losslessly` gains `cache_dir`, for
`tokenizer_cache_dir`.
- `vision_academic` records `tokenizer_json_split: true` in its result
definition for checkpoints that use the new split, so results saved by
the earlier evaluator are refused instead of merged (unchanged
definitions for earlier checkpoints).
- A saved config without the field means the old split
(`saved_tokenizer_json_split`). Decoded-diagnostic panels frozen before
this change keep that split when loaded, and `vision_decoded` scores
each checkpoint with the split it trained on and records it in the
result manifest (third commit, from the Codex review).

### Recalibration (second commit)
The mean loss weights were measured with the old split. Each table was
remeasured with the probe its docstring describes (128 rows, the
recipe's seed, Dolma2 at the pinned revision), once per split. The old
split reproduced every replaced constant exactly before the new value
replaced it.

| Table | New vs old |
|---|---|
| `ALIGNMENT_MEAN_LOSS_WEIGHTS` bridge, perception | -1.1% to 0% |
| `ALIGNMENT_ONE_ANNOTATION_MEAN_LOSS_WEIGHTS` | -0.1% to 0% |
| `STAGE1_V3_MEAN_LOSS_WEIGHTS`, `STAGE1_V3_DOCUMENTS_MEAN_LOSS_WEIGHTS`
| -6.1% to 0% |
| `STAGE1_V7_NEMOTRON_MEAN_LOSS_WEIGHTS` | -6.9% to -0.8% |
| `STAGE1_V7_GUI_SYN_MEAN_LOSS_WEIGHT` | -0.4% |
| `DEFAULT_VISUAL_MEAN_LOSS_WEIGHTS`, `visual_calibration_v1.json` |
-2.6% to 0% |
| `STAGE1_POSITIONS_PER_LOSS_TOKEN`, Nemotron and GUISyn | +0.3% to
+3.3% |

Derived values follow: `STAGE1_V6_REFERENCE_VISUAL_LOSS_MASS` is about
15.9B tokens (was 16.3B), and v7's derived loss targets move by up to
4%. In v7's base split, olmOCR documents now reaches its 5-pass cap
instead of falling just under it, and PixMo-Points' passes over the hero
are 24.7 (was 25.4). The tests and docstrings that quote these numbers
are updated.

**Left as they are, for a look:** today's builders do not reproduce two
sets of constants even with the old split, so they predate the current
code and the probe cannot recalibrate them.
- `ALIGNMENT_MEAN_LOSS_WEIGHTS["joint"]`: the joint builder now gives
perception's sources and perception's means.
- The 29 v6 entries of `STAGE1_POSITIONS_PER_LOSS_TOKEN`: for example,
TextOCR measures 22.2 against 26.7. The Nemotron and GUISyn entries,
measured the same way a day later, reproduce exactly.

### Evidence
A paired test at 20B on the v6 256K hero workload, 1,200 steps from D4,
two data seeds per arm: A (old split), B (fix), C (fix with a realigned
parent). The fix has no measurable effect on vision (fast stage-1 evals,
captions re-judged) or on text (9 bundles on seed 0, `easy` and `lc` on
seed 1). It is a correctness fix: training now matches the tokenizer the
text data and the exported model use.

### Compatibility
- A pre-fix run resumed on this code keeps its tokenization:
`vision_alignment.train` (also used by mixed mid-training) reads the
resume checkpoint's saved config and, if it predates the setting, keeps
the earlier split and the loss calibration saved with it, meaning its
mean loss weights, loss targets and the train module's loss targets
(also when `--dataset.tokenizer_json_split=false` is set, since the
means in code are calibrated for the new split), or stops with an error
if those do not cover the mixture's sources. It reads the newest
checkpoint that has a `config.json`, so the alignment pipeline's
recovery of a checkpoint saved before its config still works, and that
recovery writes the recovered split and means into the repaired
`config.json` (from the Codex review).
- Existing checkpoints evaluate exactly as before.

### Tests
- New: both load paths, the default, and a regression test with a
tokenizer that declares `GPT2Tokenizer` but splits digits in groups of
three (it fails under the old load). `vision_academic` follows the saved
value.
- `src/test/internal`, `src/test/data/multimodal`,
`vision_academic_test.py` and `nn/hf/tokenizer_test.py` on the training
image: the only failures also fail on the base commit
(`batch_prefetch_test` epoch mode and the two hero-phase override-table
tests).


🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_0159PTUsp2w3YTANVDZ4BUss

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@gregorybchris

Copy link
Copy Markdown
Collaborator

This review was generated by an agent following REVIEW_GUIDE.md. It is not from a human reviewer. Reply in the PR thread and a maintainer will follow up.

Looks good overall! Following the checkpoint's saved tokenizer split preserves training parity; one refresh-option regression should be fixed before merging.

Blocking

  1. src/olmo_eval/inference/providers/olmo_core_vlm/provider.py:219 — Preserve force_download=True on the lossless path.

    I reproduced this through the provider constructor with CPU-only loader spies: with dataset.tokenizer_json_split=True and force_download=True, neither cached_file nor PreTrainedTokenizerFast.from_pretrained receives the refresh option. With the flag false or missing, AutoTokenizer.from_pretrained receives force_download=True. The exact pinned OLMo-core helper at 42e65ea6 accepts only revision, so the new branch silently loses the requested refresh and can reuse cached tokenizer files. That weakens reproducibility when an eval explicitly requests fresh tokenizer artifacts.

    Please preserve tokenizer refresh before lossless loading, or support it through the loader. Add a regression test through provider construction that checks refresh behavior for true, false, and missing checkpoint flags while preserving the revision and tokenizer split.

Verification: the five existing TestDocumentLayoutDetection tests pass, and the CPU constructor reproduction confirms the loader arguments above. GPU/checkpoint validation was not run; optional PyTorch is unavailable locally.

Before merge

Please fix the refresh regression and add the provider regression test. You may merge into the intended base once those changes are in and CI is green.

@jason718
jason718 merged commit 652389a into jasonr/olmo-core-vlm-olmo35 Nov 20, 2026
1 check passed
@jason718
jason718 deleted the rustins/multimodal-tokenizer-json branch November 20, 2026 05:47
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.

3 participants