Repository navigation
Run vision alignment on OLMo 3.5 by inheriting the text mid-training settings; document mode for KDA - #897
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4bdb8bf27c
ℹ️ 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 subsegment_ids is not None: | ||
| raise ValueError( | ||
| "Sibling-branch packing (`subsegment_ids`) needs an attention mask, which " | ||
| "the LM's recurrent sequence mixers cannot apply; pack one document per " | ||
| "example instead." |
There was a problem hiding this comment.
Don't reject every ordinary packed KDA batch
With the alignment recipe's pack=True, pack_examples() unconditionally creates subsegment_ids (including all-zero values for sources with no sibling branches), and the collator forwards them. Therefore every OLMo 3.5/KDA alignment batch reaches this guard and raises before document boundaries are constructed; only actual nontrivial sibling-branch IDs need rejection. Treat a uniform vector as ordinary packing or have packing omit it.
Useful? React with 👍 / 👎.
4bdb8bf to
101d79b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 101d79be79
ℹ️ 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".
| module_settings: dict[str, Any] = { | ||
| name: text_module[name] | ||
| for name in ( | ||
| "z_loss_multiplier", | ||
| "compile_model", | ||
| "max_grad_norm", | ||
| "reset_optimizer_states_on_load", | ||
| "reset_optimizer_states_on_resume", | ||
| "label_ignore_index", | ||
| ) | ||
| if name in text_module |
There was a problem hiding this comment.
Carry over activation checkpointing from the text config
When a supplied text config has a non-None train_module.ac_config, this allowlist silently drops it. MultimodalOLMoDDPTrainModuleConfig supports that inherited field and its module applies it to the LM, so alignment no longer preserves the text run's activation-checkpointing/recomputation policy; such configurations can consume substantially more memory and OOM. Copy ac_config (or inherit all compatible train-module fields) when constructing module_settings.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5e34d97f7a
ℹ️ 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".
| for name in ( | ||
| "z_loss_multiplier", | ||
| "compile_model", | ||
| "max_grad_norm", | ||
| "reset_optimizer_states_on_load", |
There was a problem hiding this comment.
Preserve the text run's Float8 configuration
When recipe.text_config enables train_module.float8_config, this allowlist drops it, so the resulting MultimodalOLMoDDPTrainModuleConfig falls back to None and the DDP initializer never applies the text run's FP8 conversion to the LM. This silently changes memory use, performance, and numerics for any alignment run based on an FP8 text mid-training configuration; carry the compatible float8_config field through (or reject it explicitly if unsupported).
Useful? React with 👍 / 👎.
| launch.beaker_image = text_launch.beaker_image | ||
| launch.post_setup = text_launch.post_setup |
There was a problem hiding this comment.
Preserve pre_setup from the text launch
For a text configuration that uses launch.pre_setup, this branch copies only post_setup, so the alignment job omits commands that the text run executes before package installation. Such setup hooks can prepare system dependencies or mounts required by the inherited image, causing the launched alignment job to run in a different—and potentially unusable—environment; copy text_launch.pre_setup as well.
AGENTS.md reference: AGENTS.md:L153-L153
Useful? React with 👍 / 👎.
5e34d97 to
65ef250
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e06a72cead
ℹ️ 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".
| for name in ("d_model", "n_layers", "vocab_size", "tie_word_embeddings"): | ||
| if getattr(lm, name) != getattr(pretrained, name): |
There was a problem hiding this comment.
Validate the full inherited LM topology
Checking only these four scalar fields lets a recipe.text_config from a differently structured model pass validation whenever its width, depth, vocabulary size, and tying happen to match. For example, changing a block's sequence mixer or MoE dimensions leaves this check satisfied, but bridge initialization then builds that incompatible LM and attempts to load the selected checkpoint's parameter state into it, producing missing-key/shape errors (or an invalid load). Compare the resolved block/model topology as well, while excluding the few intentional runtime-only differences.
Useful? React with 👍 / 👎.
| inherited_callbacks = { | ||
| name: callback | ||
| for name, callback in text_trainer.callbacks.items() | ||
| if name not in ("checkpointer", "wandb", "slack_notifier", "beaker") | ||
| } |
There was a problem hiding this comment.
Do not inherit incompatible GAP monitor callbacks
When a supplied text config enables gap_monitor, this comprehension carries GAPMonitorCallback into the alignment trainer. Its post_attach() explicitly raises unless the train module is a TransformerTrainModule, whereas this recipe builds MultimodalOLMoDDPTrainModule (an OLMoDDPTrainModule), so the alignment job fails during trainer attachment before any training starts. Filter this callback or add multimodal support before inheriting it.
Useful? React with 👍 / 👎.
Language models with Kimi Delta Attention layers cannot apply an attention mask; KDA resets its state at document boundaries (cu_doc_lens) and the attention layers of such models take the same boundaries through their variable-length kernels. When the LM has a KDA layer, MultimodalLM now derives one document per packed example from the loader's example_ids (padding in its own document), passes doc_lens/max_doc_lens to the LM, sends no attention masks or positions, and rejects sibling-branch packing, which needs a mask. Attention-only LMs keep the mask path unchanged.
… recipe recipe.text_config points at the resolved config of the text mid-training run the pretraining checkpoint belongs to. The LM config and every text-side setting are inherited from it: optimizer (eps, sigma_factor, compile, weight decay, betas, clipping), train module (z-loss, compile_model, DP/EP configs, optimizer-state reset), trainer bookkeeping and monitoring callbacks, loader workers, and the launch image, install step, resources and environment. MULTIMODAL_OVERRIDES lists exactly what an alignment phase changes; a test builds all three phases from a trimmed OLMo 3.5 mid-training config and asserts the differing keys match the table. Without a text config the LM config comes from the checkpoint's config.json through the legacy normalizer with EMO cleared, as text mid-training does. The s002 runtime forcing (flex attention, rowwise EP, capacity factor 8, shared dispatch buffers, recomputation, EP degree 8) is removed: execution settings are the text run's own. Document mode turns the experimental kernel_fun KDA kernels off: they do not take packed documents and their support check evaluates the cu_seqlens tensor as a bool. Launch defaults move to workspace ai2/oe-olmo3p5-mt with its default budget and the jasonr_* secrets.
The packer always emits subsegment_ids (a constant id per example without branches), so document mode now rejects only examples that really carry sibling branches; the first bridge smoke on OLMo 3.5 failed on this guard in its startup evaluation.
…keep their W&B run
…ard requires them)
1b2e506 to
9c511db
Compare
e06a72c to
5878dcf
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5878dcf3f8
ℹ️ 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".
| for name in ( | ||
| "z_loss_multiplier", | ||
| "compile_model", | ||
| "max_grad_norm", | ||
| "reset_optimizer_states_on_load", | ||
| "reset_optimizer_states_on_resume", | ||
| "label_ignore_index", |
There was a problem hiding this comment.
Preserve Q/K gain expansion when loading a text checkpoint
When recipe.text_config sets expand_shared_qk_norm_on_load=True, this allowlist drops it and the multimodal config falls back to False. Bridge initialization loads the native text checkpoint through load_state_dict_direct(..., load_optim_state=False), while the multimodal loader only prepares aliased shared-Q/K gain expansion when this flag is true. Checkpoints that require expansion from a shared gain vector to per-head Q/K norm tensors will therefore fail to initialize (or receive incompatible tensor state) despite the source text run explicitly requesting that compatibility path.
Useful? React with 👍 / 👎.
| module_settings: dict[str, Any] = { | ||
| name: text_module[name] | ||
| for name in ( | ||
| "z_loss_multiplier", | ||
| "compile_model", | ||
| "max_grad_norm", | ||
| "reset_optimizer_states_on_load", | ||
| "reset_optimizer_states_on_resume", | ||
| "label_ignore_index", | ||
| ) | ||
| if name in text_module |
There was a problem hiding this comment.
Reject unsupported text parallelism instead of silently dropping it
A text configuration with tp_config, cp_config, or pp_config reaches this path, but none of those settings is inherited or validated. MultimodalOLMoDDPTrainModule explicitly rejects these parallelism modes, so silently omitting them launches the alignment run with ordinary DP instead of reporting that the requested text setup is unsupported; this changes the memory/parallelism regime and can lead to an OOM or an unintentionally different experiment. Validate that these fields are unset, or fail with the module's unsupported-mode error.
Useful? React with 👍 / 👎.
5878dcf
into
jasonr/native-vision-alignment-on-886
Summary
Makes the vision alignment recipe (#889) run on the OLMo 3.5 "small hero" checkpoint (
/weka/olmo-3p5-checkpoints/protected/olmo35-small-hero-20260907/emo/8T) by inheriting the text team's mid-training settings instead of hard-coding the s002-era runtime. Multimodal-only files; shared code is byte-identical to #886/#889.recipe.text_config: path to a text mid-trainingconfig.json(the resolved config ofscaling-laddersladders/olmoe3/workloads/midtraining.py). The LM model config, optimizer (eps 1e-8, sigma_factor 6, compile, weight decay 0.1, betas, max_grad_norm), train-module settings (z-loss 1e-5, compile_model, DDP fp32 reduce/accumulate,ep_config=None,reset_optimizer_states_on_load), checkpointer bookkeeping, data-loader workers and the launch defaults (image, post_setup, env, shared memory, one node) come from it; a singleMULTIMODAL_OVERRIDEStable lists everything the alignment phases change (per-phase LRs/schedulers/warmups, per-group clipping, 128 x seq global batch, 4 x seq microbatch (joint 2 x seq), 500/50 checkpoint cadence, 50M foreach chunk, freeze lists, image-token rows, response-only logits, evaluator and init callbacks). A unit test builds bridge → perception → joint from a trimmed fixture of the pin's config and asserts the differing keys equal the table.text_configthe LM config is read from the checkpoint'sconfig.jsonthrough the legacy latent-MoE normalizer with EMO cleared (what text mid-training does). The s002 forcing (flex backend, rowwise EP, capacity factor 8, recompute, EP degree 8) is gone on both paths.doc_lens/max_doc_lensderived fromexample_ids(no masks, noposition_ids; sibling-branch packing rejected). Verified on a B300 with the 8T weights: packed-vs-standalone per-token CE diff 0.00000, negative control leaks 0.062, eager and compiled.flakernels in document mode (use_experimental_kernels=Falsein the override table):kernel_fun.kda.ops.is_supportedbool-evaluatescu_seqlensand crashes with document boundaries; text mid-training never passes them. Pending an upstream kernel_fun fix.ai2/oe-olmo3p5-mt(budgetai2/oe-other),jasonr_*secrets, no AWS secrets,follow=False,min_runtime=8h,ai2/holmes.Bridge smoke on the 8T checkpoint (1 node x 8 B300, Beaker
01M3TRTWNZ8SZ3EW77P72Z6MD4)150 steps with
recipe.text_config= the text team's resolved mid-training config and the bridge phase overrides: train CE 2.803 → 2.281, 0 skipped steps, grad norm 3.39 → 0.105, notorch.compilerecompiles after step 20, ~5 s/step, 97 GiB active / 103.5 GiB reserved per GPU, checkpoints at steps 100 and 150.Resume test: relaunching the same run with
max_duration170 loaded the step-150 checkpoint and optimizer state, resumed the W&B run, trained steps 151-170 (0 skipped steps) and saved step 170; final caption validation CE 2.1477, image gap 0.284.Three follow-up commits came out of the smoke: the document-mode guard now rejects only examples that really carry sibling branches (the packer always emits
subsegment_ids, a constant id per branch-free example), the recipe usesMultimodalBeakerCallback(#889) so a resumed W&B run accepts the new Beaker experiment URL, and the pixel-dtype cast lives in #889.Tests
vision_alignment_olmo35_test.pynew,vision_alignment_{,bridge_,joint_}test.pyupdated): 135 passedmultimodal_document_mode_test.py: 8 CPU tests + 1 GPU KDA isolation testinternal,nn/vision,train_module/transformer,train/callbacks): 556 passed, 13 skipped🤖 Generated with Claude Code