Skip to content

Run vision alignment on OLMo 3.5 by inheriting the text mid-training settings; document mode for KDA - #897

Merged
jason718 merged 7 commits into
jasonr/native-vision-alignment-on-886from
jasonr/olmo35-vision-support
Oct 2, 2026
Merged

jason718 merged 7 commits into
jasonr/native-vision-alignment-on-886from
jasonr/olmo35-vision-support

Conversation

@jason718

@jason718 jason718 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

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-training config.json (the resolved config of scaling-ladders ladders/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 single MULTIMODAL_OVERRIDES table 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.
  • Without text_config the LM config is read from the checkpoint's config.json through 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.
  • Document mode for recurrent LMs: when any block is Kimi Delta Attention (no attention-mask support), packed examples are isolated through doc_lens/max_doc_lens derived from example_ids (no masks, no position_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.
  • KDA stays on the fla kernels in document mode (use_experimental_kernels=False in the override table): kernel_fun.kda.ops.is_supported bool-evaluates cu_seqlens and crashes with document boundaries; text mid-training never passes them. Pending an upstream kernel_fun fix.
  • Launch defaults: workspace ai2/oe-olmo3p5-mt (budget ai2/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, no torch.compile recompiles after step 20, ~5 s/step, 97 GiB active / 103.5 GiB reserved per GPU, checkpoints at steps 100 and 150.

evaluation (64 examples/source) startup step 150
pixmo_caption validation CE 2.7736 2.1665
caption matched-correct / matched-wrong CE (gap) 2.8348 / 2.8209 (−0.014) 2.2383 / 2.5036 (0.265)
caption first-8-token gap (wrong − correct) −0.070 1.265
caption blank-image CE 2.8048 2.3946
pixmo_transcript validation CE 2.8554 2.4357
transcript matched gap / first-8 gap 0.001 / −0.039 0.233 / 0.635

Resume test: relaunching the same run with max_duration 170 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 uses MultimodalBeakerCallback (#889) so a resumed W&B run accepts the new Beaker experiment URL, and the pixel-dtype cast lives in #889.

Tests

  • recipe suites (vision_alignment_olmo35_test.py new, vision_alignment_{,bridge_,joint_}test.py updated): 135 passed
  • multimodal_document_mode_test.py: 8 CPU tests + 1 GPU KDA isolation test
  • broader CPU suite (internal, nn/vision, train_module/transformer, train/callbacks): 556 passed, 13 skipped
  • ruff / black / isort clean; mypy: no new errors (62 pre-existing repo-wide on the base too)

🤖 Generated with Claude Code

@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: 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".

Comment thread src/olmo_core/nn/vision/multimodal.py Outdated
Comment on lines +652 to +656
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."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@jason718
jason718 force-pushed the jasonr/olmo35-vision-support branch from 4bdb8bf to 101d79b Compare October 1, 2026 03:21

@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: 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".

Comment on lines +482 to +492
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

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 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 👍 / 👎.

@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: 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".

Comment on lines +484 to +488
for name in (
"z_loss_multiplier",
"compile_model",
"max_grad_norm",
"reset_optimizer_states_on_load",

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 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 👍 / 👎.

Comment on lines +943 to +944
launch.beaker_image = text_launch.beaker_image
launch.post_setup = text_launch.post_setup

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 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 👍 / 👎.

@jason718
jason718 force-pushed the jasonr/olmo35-vision-support branch from 5e34d97 to 65ef250 Compare October 1, 2026 05:17

@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: 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".

Comment on lines +327 to +328
for name in ("d_model", "n_layers", "vocab_size", "tie_word_embeddings"):
if getattr(lm, name) != getattr(pretrained, name):

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 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 👍 / 👎.

Comment on lines +823 to +827
inherited_callbacks = {
name: callback
for name, callback in text_trainer.callbacks.items()
if name not in ("checkpointer", "wandb", "slack_notifier", "beaker")
}

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 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 👍 / 👎.

@jason718 jason718 self-assigned this Oct 1, 2026
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.
@jason718
jason718 force-pushed the jasonr/native-vision-alignment-on-886 branch from 1b2e506 to 9c511db Compare October 1, 2026 17:45
@jason718
jason718 force-pushed the jasonr/olmo35-vision-support branch from e06a72c to 5878dcf Compare October 1, 2026 17:45

@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: 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".

Comment on lines +485 to +491
for name in (
"z_loss_multiplier",
"compile_model",
"max_grad_norm",
"reset_optimizer_states_on_load",
"reset_optimizer_states_on_resume",
"label_ignore_index",

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 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 👍 / 👎.

Comment on lines +483 to +493
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

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 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 👍 / 👎.

@jason718
jason718 merged commit 5878dcf into jasonr/native-vision-alignment-on-886 Oct 2, 2026
1 check passed
@jason718
jason718 deleted the jasonr/olmo35-vision-support branch October 2, 2026 05:15
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.

1 participant