Repository navigation
Multimodal: load the tokenizer exactly as tokenizer.json defines it, and recalibrate - #944
Conversation
MultimodalMixtureConfig.build_tokenizer loaded the tokenizer with AutoTokenizer, which for Dolma2
builds GPT2Tokenizer (its tokenizer_config.json class) and splits text with GPT-2's regex instead
of the Split regex in tokenizer.json. Every multimodal run tokenized its vision text differently
from the text mixtures, which were tokenized with tokenizer.json: the same vocabulary and IDs, but
different tokens (".\n\n" is three tokens instead of one, " 2024" is " 20" "24" instead of " 202"
"4", "long_caption:" is "long" "_" "caption" ":" instead of "long" "_caption" ":"), about 6% of the
loss-weighted vision tokens of the stage-1 v6 mixture. Removing use_fast=False does not help: the
class, not the slow/fast choice, replaces the pre-tokenizer.
build_tokenizer now uses load_tokenizer_losslessly, the loader the HF export already uses: it loads
tokenizer.json with the generic fast class and validates the backend against tokenizer.json
(validate_tokenizer_backend). The 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, for resuming or reproducing an earlier run; evaluation
follows the saved value, and a config saved before this change means the old split. The in-repo
academic eval (vision_academic) now follows the checkpoint's value too. load_tokenizer_losslessly
gains cache_dir for tokenizer_cache_dir.
The mean loss weights measured with the old split are recalibrated in a follow-up commit.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0159PTUsp2w3YTANVDZ4BUss
…on's split The mean loss weights were measured with GPT2Tokenizer's split; tokenizer.json's split, now the default, gives fewer response tokens for some sources. Each table was remeasured with the probe its docstring describes (estimate_mean_loss_weights, 128 rows, the recipe's seed, Dolma2 at the pinned revision), once with the earlier split and once with the fix. The earlier split reproduced every replaced constant exactly before the fixed value replaced it. Fixed split vs earlier split: - ALIGNMENT_MEAN_LOSS_WEIGHTS bridge and perception: -1.1% to 0% - ALIGNMENT_ONE_ANNOTATION_MEAN_LOSS_WEIGHTS: -0.1% to 0% - STAGE1_V3_MEAN_LOSS_WEIGHTS and the STAGE1_V3_DOCUMENTS_MEAN_LOSS_WEIGHTS overrides: -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 and visual_calibration_v1.json: -2.6% to 0% - STAGE1_POSITIONS_PER_LOSS_TOKEN, Nemotron and GUISyn: +0.3% to +3.3% Left as they are, because today's builders do not reproduce them even with the earlier split (they predate the current code): ALIGNMENT_MEAN_LOSS_WEIGHTS["joint"] (the builder now gives perception's sources) and the 29 v6 entries of STAGE1_POSITIONS_PER_LOSS_TOKEN. 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%. olmOCR documents now reaches its 5-pass cap in v7's base split instead of falling just under it, and PixMo-Points' base-split passes over the hero are 24.7 (was 25.4); the tests and docstrings that quote these numbers are updated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0159PTUsp2w3YTANVDZ4BUss
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3933350e51
ℹ️ 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".
| """Embedding-table size, including any reserved rows for image tokens.""" | ||
| tokenizer_revision: str | None = None | ||
| tokenizer_cache_dir: str | None = None | ||
| tokenizer_json_split: bool = True |
There was a problem hiding this comment.
Preserve the legacy split for deserialized evaluator configs
When vision_decoded.load_frozen_evaluator() reads a panel file created before this field existed, MultimodalEvaluatorCallbackConfig.from_dict() constructs its nested mixture with this new True default. checkpoint_configs() only compares the tokenizer identifier and revision, so an existing checkpoint and frozen panel are silently rebuilt with the new tokenizer split, changing prompt and reference token IDs and invalidating comparisons with the original diagnostic results. Missing serialized values need to resolve to False on this deserialization path, or the evaluator must derive and validate the split from the evaluated checkpoint.
Useful? React with 👍 / 👎.
…he checkpoint's load_frozen_evaluator rebuilds a saved panel's evaluator with MultimodalEvaluatorCallbackConfig .from_dict, so a panel saved before tokenizer_json_split existed picked up the new default (True) and vision_decoded tokenized prompts and references of earlier checkpoints with a split they never trained on; checkpoint_configs compared only the tokenizer identifier and revision. - saved_tokenizer_json_split(dataset): the one rule for saved configs (a missing value means the earlier GPT2Tokenizer split), used by vision_academic and vision_decoded. - load_frozen_evaluator: a panel without the setting loads with False, the split it was built with. - checkpoint_configs: sets the evaluator's split to the evaluated checkpoint's own and records it in the model manifest, so each checkpoint is scored as it trained, whichever panel is used. Found by the Codex review of this PR.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dd332dfecf
ℹ️ 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".
| """Embedding-table size, including any reserved rows for image tokens.""" | ||
| tokenizer_revision: str | None = None | ||
| tokenizer_cache_dir: str | None = None | ||
| tokenizer_json_split: bool = True |
There was a problem hiding this comment.
Preserve the tokenizer split when resuming legacy runs
When an alignment or midtraining job created before this field is restarted with its original command, the recipe reconstructs MultimodalMixtureConfig rather than deserializing the checkpoint's dataset config, so this new default silently selects the tokenizer.json split instead of the split that produced the checkpoint. The updated calibration constants also change the resulting sampling weights; current packed-loader states will therefore reject the resume, while older states permitted without fingerprint validation can continue with a changed token stream. Consult the resume checkpoint's saved dataset setting (where absence means False) and retain its matching calibration rather than applying the new-run default.
Useful? React with 👍 / 👎.
…ained with The alignment and mixed mid-training recipes rebuild the mixture from code, so a run started before tokenizer_json_split existed would resume with the new default split and the recalibrated means: a changed token stream, or a packed-loader state that refuses the new sampling weights. keep_resumed_tokenizer_split runs in vision_alignment.train (which mixed mid-training also uses) before the data is built. When the save folder holds a checkpoint, the run keeps that checkpoint's split (saved_tokenizer_json_split: a missing value means the earlier split) and, where that differs from the config's, the mean loss weights saved with it; if those do not cover exactly the mixture's sources it raises instead. The in-loop evaluator always tokenizes as training does. Found by the Codex review of this PR.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 39348b17d8
ℹ️ 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".
| except FileNotFoundError: | ||
| latest = None | ||
| if latest is not None: | ||
| saved = _read_checkpoint_config(latest).get("dataset") |
There was a problem hiding this comment.
Skip configless checkpoints during split recovery
When an alignment pipeline restarts after checkpoint state finished saving but config.json did not, _train_stage() explicitly treats that as recoverable and plans to reconstruct the missing metadata; however, this unconditional read selects that same latest checkpoint and raises FileNotFoundError before the trainer can load it or repair it. This breaks the documented recovery path for a completed, potentially expensive stage; derive the split from the latest earlier checkpoint that has a config, or allow the pipeline's config-recovery flow to proceed.
Useful? React with 👍 / 👎.
…with a config A save can finish before its config callback, and the alignment pipeline resumes such a final checkpoint on purpose and writes its config.json afterwards. keep_resumed_tokenizer_split read config.json from the latest checkpoint unconditionally and raised before that recovery could run. It now reads the newest checkpoint that has a config, and keeps the config's split (with a warning) when none has one. Found by the Codex review of this PR.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 129dc55620
ℹ️ 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".
| tokenizer, token_ids = _load_tokenizer( | ||
| cache, vocab_size, tokenizer_json_split=_checkpoint_tokenizer_json_split(saved) | ||
| ) |
There was a problem hiding this comment.
Version persisted results by tokenizer split
If any task JSON for a tokenizer_json_split=True checkpoint was produced by the previous evaluator, this line now tokenizes that checkpoint differently while _definition() remains identical: its config hash captures the checkpoint field but not which evaluator behavior interpreted it. Consequently, _load_task_result() accepts the old GPT2-split task and merge_results() can combine it with newly generated tokenizer.json-split tasks. Include the selected split or a revised evaluation protocol version in the persisted definition.
Useful? React with 👍 / 👎.
Saved task results are reused when their definition matches, and the definition did not record which split tokenized the prompts. For a checkpoint whose config sets tokenizer_json_split, results saved by the earlier evaluator (GPT2Tokenizer split) would have been reused and merged with new tokenizer.json-split results. The definition's execution section now records tokenizer_json_split: true for such checkpoints, so those results mismatch and are refused; it is left out otherwise, so earlier checkpoints' definitions and saved results are unchanged. Found by the Codex review of this PR.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5e644905c8
ℹ️ 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".
| dataset.tokenizer_json_split = split | ||
| dataset.mean_loss_weight = {name: float(value) for name, value in means.items()} |
There was a problem hiding this comment.
Persist the recovered split in endpoint metadata
When the sequential alignment pipeline repairs a finalized endpoint whose config.json is missing, _train_stage() snapshots missing_config before calling train(). These assignments then recover the legacy split and calibration only in the live config, while the pre-recovery snapshot is written to the endpoint afterward. The repaired checkpoint therefore falsely records the new tokenizer split and means, causing subsequent evaluation or resume to tokenize it differently from how it trained. Rebuild the recovery payload after this mutation, or recover the split before _train_stage() snapshots the config.
Useful? React with 👍 / 👎.
…ng a missing config _train_stage snapshots the config to write as a final checkpoint's missing config.json before calling train(), which recovered a resumed run's tokenizer split and means only in the live config. The repaired checkpoint would then record the new split and means for a run that trained on the earlier ones. _train_stage now recovers them before taking the snapshot (the call in train() is then a no-op). A saved checkpoint config without a dataset section gives nothing to recover and is skipped. Found by the Codex review of this PR.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0da964296a
ℹ️ 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".
| if split != dataset.tokenizer_json_split: | ||
| means = saved.get("mean_loss_weight") |
There was a problem hiding this comment.
Restore saved calibration when the split already matches
When resuming a legacy checkpoint after explicitly setting --dataset.tokenizer_json_split=false (the documented compatibility setting), split already equals the live value, so this conditional skips restoring the checkpoint's legacy mean_loss_weight values and leaves the newly recalibrated defaults in place. The trainer then either rejects the changed loader state or continues the old run with different sampling weights; restore and validate the saved means whenever resuming a legacy-split checkpoint, not only when this boolean changes.
Useful? React with 👍 / 👎.
…it is already off keep_resumed_tokenizer_split restored the saved mean loss weights only when the split changed, so resuming an earlier-split run with --dataset.tokenizer_json_split=false kept the code's means, which are calibrated for the new split, and resumed with different sampling weights. A checkpoint on the earlier split now always keeps its saved means (validated against the mixture's sources); a checkpoint on the new split resumes with that split. Found by the Codex review of this PR.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 12481fe13e
ℹ️ 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".
| latest, | ||
| ) | ||
| dataset.tokenizer_json_split = False | ||
| dataset.mean_loss_weight = means |
There was a problem hiding this comment.
Recompute loss targets after restoring legacy means
When resuming a legacy mixed-midtraining checkpoint with example-weighted visual sources, this assignment restores the saved means only after vision_midtraining._configure_loss() has derived dataset.target_loss_mass and train_module.source_loss_mass_targets from the newly recalibrated means (lines 944-963). The loader therefore computes new targets / old means instead of retaining the checkpoint's original example weights, which can reject the saved loader state or resume with a changed data stream; restore the saved targets as well and synchronize the train-module targets, or recompute both from the recovered means.
Useful? React with 👍 / 👎.
💡 Codex ReviewWhen resuming a legacy mixed-midtraining checkpoint with example-weighted visual sources, this assignment restores the saved means only after ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
…means Mixed mid-training derives dataset.target_loss_mass and the train module's source_loss_mass_targets from the mean loss weights, so restoring only the saved means left targets calibrated for the new split, and the loader computed new targets over old means. A checkpoint on the earlier split now restores its saved mean loss weights, loss targets and, where the recipe sets them, the train module's loss targets, each required to cover exactly the mixture's sources. Found by the Codex review of this PR.
Into
jasonr/olmo35-mixed-midtraining(#916), on its head4fb33e922. Companion: allenai/olmo-eval#535, intojasonr/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_tokenizerloaded the tokenizer withAutoTokenizer. For Dolma2 that buildsGPT2Tokenizer, the class itstokenizer_config.jsonnames, and that class splits text with GPT-2's regex instead of theSplitregex intokenizer.json. The vocabulary and IDs are the same, but the tokens are not:tokenizer.json, as the text mixtures were tokenized202420242024.\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=Falsedoes 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_tokenizerusesload_tokenizer_losslessly, the loader the HF export already uses: it loadstokenizer.jsonwith the generic fast class and validates the backend withvalidate_tokenizer_backend. Vocabulary, special-token IDs and the Molmo2 image-token IDs are unchanged, so checkpoints stay compatible.MultimodalMixtureConfig.tokenizer_json_split(defaultTrue) records the choice in every run's config.Falsereproduces 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_academichere,olmo_core_vlmin olmo-eval (olmo_core_vlm: evaluate each checkpoint with the tokenizer split it trained on olmo-eval#535). The provider callsload_tokenizer_losslessly(path, revision=...), which the eval commit8f8ae5df4already has, and reads the new field as a plain dict entry, so evaluating on that commit still works.load_tokenizer_losslesslygainscache_dir, fortokenizer_cache_dir.vision_academicrecordstokenizer_json_split: truein 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).saved_tokenizer_json_split). Decoded-diagnostic panels frozen before this change keep that split when loaded, andvision_decodedscores 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.
ALIGNMENT_MEAN_LOSS_WEIGHTSbridge, perceptionALIGNMENT_ONE_ANNOTATION_MEAN_LOSS_WEIGHTSSTAGE1_V3_MEAN_LOSS_WEIGHTS,STAGE1_V3_DOCUMENTS_MEAN_LOSS_WEIGHTSSTAGE1_V7_NEMOTRON_MEAN_LOSS_WEIGHTSSTAGE1_V7_GUI_SYN_MEAN_LOSS_WEIGHTDEFAULT_VISUAL_MEAN_LOSS_WEIGHTS,visual_calibration_v1.jsonSTAGE1_POSITIONS_PER_LOSS_TOKEN, Nemotron and GUISynDerived values follow:
STAGE1_V6_REFERENCE_VISUAL_LOSS_MASSis 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.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,
easyandlcon seed 1). It is a correctness fix: training now matches the tokenizer the text data and the exported model use.Compatibility
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=falseis 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 aconfig.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 repairedconfig.json(from the Codex review).Tests
GPT2Tokenizerbut splits digits in groups of three (it fails under the old load).vision_academicfollows the saved value.src/test/internal,src/test/data/multimodal,vision_academic_test.pyandnn/hf/tokenizer_test.pyon the training image: the only failures also fail on the base commit (batch_prefetch_testepoch mode and the two hero-phase override-table tests).🤖 Generated with Claude Code
https://claude.ai/code/session_0159PTUsp2w3YTANVDZ4BUss