Skip to content

Add native OLMoDDP training and expert-parallel runtime - #868

Closed
RustinS wants to merge 16 commits into
visionfrom
rustins/native-olmo-ddp-runtime
Closed

RustinS wants to merge 16 commits into
visionfrom
rustins/native-olmo-ddp-runtime

Conversation

@RustinS

@RustinS RustinS commented Sep 16, 2026 •

Copy link
Copy Markdown

Add native OLMoDDP training and expert-parallel runtime

Summary

Add the reusable model, optimizer, and distributed runtime needed to train MoE models through OLMo-core's native configuration and training interfaces.

  • Introduce OLMoDDPModel, its transformer block/config, and OLMoDDPTrainModuleConfig with native checkpoint loading and resume support.
  • Add parameter-group data parallelism and sharded AdamW state, including FP32 gradient accumulation/master weights and optimizer-selected reduce-scatter.
  • Add the MoE-v2 router/expert stack, synchronized expert dispatch, and NVSHMEM rowwise dispatch with their supporting permutation and grouped-matmul kernels. Optional precision and transport backends remain explicitly configurable.
  • Integrate the runtime with pipeline schedules, training callbacks, per-group scheduling, loss normalization, and valid-token routing statistics.
  • Package CUDA build sources, provide explicit/lazy extension builds, and add optional NVTX instrumentation. Default Triton caches are separated by job, host, and rank; explicit cache overrides remain supported.
  • Document the native DDP model, train-module, optimizer, and parallel-wrapper APIs.

This is infrastructure, not a new training recipe. Existing dense transformer configuration and exports must remain compatible with the target branch; selecting the new runtime is explicit.

Scope

Included: shared kernels, MoE/DDP and optimizer components, distributed training/checkpoint integration, pipeline support, focused tests, and API documentation.

Excluded: vision model adapters, alignment and mixed-midtraining recipes, data inventories/calibration, evaluation implementations, model-specific scaling-ladder recipes, experiment artifacts, and Beaker workspace/image/launch-policy changes. No router RMS repair, training-data changes, or benchmark/throughput claims are part of this PR.

Validation

The standalone candidate is tested independently of the vision-alignment worktree:

  • Native runtime/config/optimizer/build/pipeline CPU suite: 122 passed; inherited target embedding, dropout-RNG, transformer and LM-head regression suite: 60 passed. Additional model/LM-head guard checks passed. These invocations overlap and are not summed.
  • 25 CPU tests passed for trainer bookkeeping, pipeline schedules, and chunk-reorder dispatch.
  • Trainer/callback integration checks: 39 passed.
  • Native model forward/backward and synchronized expert-parallel GPU checks: 2 passed.
  • Rowwise expert-parallel forward/backward parity against the unsharded reference: 1 passed.
  • Multi-group DDP reduction checks across CPU/GPU backends: 7 passed.
  • The NVSHMEM extension built through CMake for the local B300 (sm_103) environment.
  • Native public exports and aliases resolve with optional TE, grouped-GEMM, NVTX and Triton imports blocked.
  • The built wheel matches all 287 candidate Python files and 21 CUDA/CMake build files, retains all 44 existing target vision/data files unchanged, contains no local binaries or new alignment/eval modules, and passes direct ZIP-import checks without installation.
  • All 184 changed Python files pass Ruff, Black and isort; the complete patch passes git diff --check and applies cleanly to the target commit. Normalized executable AST comparison confirms that the comment/dead-code cleanup preserves active statements.

Local GPU validation uses PyTorch 2.11 / CUDA 13. The target Docker environment uses PyTorch 2.10 / CUDA 12 and has not been validated by these runs. The full optional-backend matrix and full-repository type checking are not claimed. A full-repository Ruff run also reports six failures in unchanged target-branch files; these are outside this diff.

Pipeline compatibility follow-up (bf615ffcb): preserve the default PyTorch Interleaved1F1B path and the other existing schedules, including constructor loss callbacks, variadic inputs, and (output, losses) results. Custom implementations remain opt-in and retain their own output contract. All six PyTorch schedule enums have configuration/constructor coverage; real two-rank CPU runs of 1F1B, Interleaved1F1B, and GPipe match unsplit outputs, losses, and parameter gradients. The follow-up passes 80 compatibility checks, 25 config/native-module checks, and two custom NCCL/NCCL-RMA execution checks. Changed-file style checks pass, and the rebuilt wheel matches all 287 Python sources.

The prepared diff against vision at 2dad929acb742faaa566a173f3484ff760c3ca07 is 210 files, +62,339/-375 lines, including tests and API docs. Generated extension binaries are excluded and ignored. The separate validation notes include commands, individual receipts, and final wheel-content checks; no results from the larger alignment worktree are substituted for candidate tests.

Runtime constraints

Attention-sink follow-up (759e49820): sinks with tensor or context parallelism now fail explicitly before setup/collectives. Ulysses requires both head-aligned sink parameters and masks after sequence exchange, so parallel sink support is not claimed. Thirteen sink tests and two existing distributed TP/Ulysses controls passed; sink-disabled training and the alignment recipe are unchanged.

Separate inherited issue: under local Torch 2.11, the original transformer's full-batch-normalized pipeline loss is averaged across microbatches again by Torch's default scale_grads=True. A bounded GPipe reproduction gives gradient/reference ratios 1, 0.5, and 0.25 for 1, 2, and 4 microbatches. This predates this branch; the compatibility correction intentionally preserves the prior numerical behavior. It needs a separate train-module CE-gradient fix/test, not a change to the generic wrapper's default for microbatch-mean losses.

Rowwise expert parallelism requires a compatible CUDA/NVSHMEM extension; synchronized expert parallelism does not. Compiler caches should be node-local. The unsupported TE chunk-reorder path and unsupported expert-parallel schedule combinations continue to fail explicitly. Optional backend availability is not a guarantee that every backend/precision/topology combination has been qualified.

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

ℹ️ 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 +742 to +744
else:
raise OLMoConfigurationError(
f"pipeline schedule {schedule_name.value!r} is not supported by this train 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.

P1 Badge Restore support for standard pipeline schedules

Any existing pipeline configuration using the default TransformerPipelineParallelConfig.schedule (Interleaved1F1B), or another previously supported PyTorch schedule such as 1F1B or GPipe, now reaches this branch during TransformerPipelineTrainModule.pre_train() and raises before training starts. Since selecting a custom schedule and custom stage implementation was not previously required, this breaks otherwise unchanged pipeline-training configurations; retain the prior PyTorch schedule path while adding the custom implementations.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in bf615ff. Standard PyTorch schedules retain their existing schedule/stage path; custom implementations are selected explicitly. The follow-up verification at ee252e6 includes the standard-schedule compatibility tests and two-rank CPU pipeline training controls.

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

ℹ️ 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 +454 to +458
sink_logits = sinks.to(dtype=attn_weights.dtype, device=attn_weights.device)
sink_logits = sink_logits.view(1, -1, 1, 1).expand(
attn_weights.shape[0],
-1,
attn_weights.shape[-2],

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 Shard sink logits with tensor-parallel heads

When attention_sinks=True is combined with tensor parallelism, Attention.apply_tp() shards the Q projection by head but leaves the new sinks parameter replicated at its global n_heads length. Consequently attn_weights has only the rank-local head dimension while sink_logits retains the global dimension, and this concatenation fails on the first forward pass. Shard/select the sink logits alongside w_q (and similarly account for Ulysses head sharding) or reject these parallel configurations.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in 759e498 by explicitly rejecting attention sinks with tensor or context parallelism before unsupported execution. The backend also guards direct CP use. This does not claim distributed sink support; sink-disabled parallel configurations retain the existing path. Guard regressions pass in the current targeted suite.

@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: 759e498205

ℹ️ 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 +520 to +525
if loss_weights is not None:
if self._cp_load_balancer is not None:
raise OLMoConfigurationError(
"Per-token loss weights are not supported with context parallelism"
)
lm_head_kwargs["loss_weights"] = move_to_device(loss_weights, self.device)

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 Shard per-token loss weights under tensor parallelism

When tensor parallelism is enabled and loss_weights is supplied, this forwards the full (B, S) tensor to the LM head, while LMHead.apply_tp() sequence-shards the hidden states and labels but has no layout rule for loss_weights. Each rank therefore reaches weighted_cross_entropy_loss() with B*S/TP losses and B*S weights, causing the dot product to fail on the first weighted forward pass. Shard loss_weights alongside labels, or reject this combination as is already done for context parallelism.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Confirmed with a two-rank CPU/Gloo reproduction, then addressed in ee252e6. Weighted loss with TP now raises OLMoConfigurationError in both Transformer input preparation and direct LMHead.forward, matching the existing unsupported-CP policy. A two-rank regression checks the explicit error and verifies unweighted TP forward/backward still works, with and without head normalization. This deliberately does not introduce partially validated distributed weighted-loss semantics.

Comment on lines 461 to 465
return TransformerPipelineTrainModule(
model=model,
device=device,
eval_only=eval_only,
**kwargs,

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 eval-only pipeline modules until inference works

With pp_config set, build(..., eval_only=True) now constructs a TransformerPipelineTrainModule without optimizers, but that module's eval_batch() unconditionally raises that inference is unsupported, and EvaluatorCallback.post_attach() does not accept pipeline train modules. Consequently the advertised eval-only workflow, including Trainer.eval_checkpoints(), cannot run for any standard pipeline configuration; either implement pipeline evaluation or reject eval_only=True here before constructing an unusable module.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in ee252e6. eval_only=True with PP is rejected before building the module or distributed mesh. Coverage includes TransformerTrainModuleConfig, the legacy TransformerPipelineTrainModuleConfig, and direct construction. Standard PP training remains supported and its two-rank CPU controls pass.

Comment on lines +907 to +910
for raw_path in self.checkpoints_to_eval:
path = normalize_path(raw_path)
candidate_paths = sorted(glob_directory(path)) if "*" in path else [path]
if not candidate_paths:

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 Expand every supported checkpoint glob pattern

The new option is documented as accepting checkpoint globs, but expansion is only triggered when the string contains *. Valid patterns using ? or bracket expressions, such as step000? or step00[12]0, are instead treated as literal paths and end in FileNotFoundError, even though glob_directory() supports normal glob syntax. Detect glob metacharacters generally rather than checking only for *.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The shared glob_directory helper explicitly supports only * and **; its implementation also treats ? and bracket expressions literally. Therefore broadening this call's detection alone would not enable the proposed patterns. ee252e6 clarifies the supported wildcards in both Trainer and TrainerConfig documentation. Shared glob semantics are intentionally unchanged.

Reject weighted tensor-parallel loss and eval-only pipeline modules before unsupported execution. Document the existing checkpoint wildcard syntax and cover the guards with focused regressions and distributed training controls.

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

ℹ️ 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 +161 to +164
if hasattr(train_module, "save_state_dict_direct"):
raise OLMoConfigurationError(
f"{type(train_module).__name__} does not support async checkpointing. "
"Set save_async=False for this train 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.

P1 Badge Disable async saves automatically for direct-checkpoint modules

With the standard GPU launcher, the process group uses cpu:gloo,cuda:nccl, so CheckpointerCallback.pre_train() defaults save_async to true. A newly added OLMoDDPTrainModule exposes save_state_dict_direct, causing this branch to raise during the default step-0 checkpoint before training begins unless every configuration explicitly sets save_async=False. Detect this capability when selecting the callback default, or transparently fall back to synchronous saving.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 741b1f0. The callback now chooses asynchronous saving by default only when both the backend and train module support it. Direct-checkpoint modules default to synchronous saves; explicit save_async=False is preserved, and explicit unsupported True raises before process-group creation or checkpoint writes. The lower-level async safety guard remains. Tests cover fresh/resumed runs, CPU-capable/non-CPU backends, both module interfaces, and None/False/True settings. The 43-test infra verification also includes real two-rank CPU synchronous and asynchronous checkpoint save/load controls.

Comment on lines +101 to +102
def post_attach(self):
if not isinstance(self.trainer.train_module, TransformerTrainModule):
if not isinstance(self.trainer.train_module, (TransformerTrainModule, OLMoDDPTrainModule)):

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 pipeline OLMoDDP modules from evaluator callbacks

When an OLMoDDPTrainModule has pipeline parallelism enabled, this check accepts it, but eval_batch() returns None on every non-final pipeline stage. perform_eval() then unconditionally asserts that every rank received an LMOutputWithLoss, so the first evaluation crashes those ranks. Either exclude pipeline-enabled OLMoDDP modules here or distribute the final-stage evaluation output to the other pipeline ranks.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 741b1f0. EvaluatorCallback.post_attach() explicitly rejects PP-enabled OLMoDDP on every pipeline rank, before evaluation starts. Non-PP OLMoDDP and standard TransformerTrainModule remain accepted; unsupported module types remain rejected. Focused callback regressions pass, and the fix is integrated into alignment head d265f90 with 157 passing callback, multimodal-evaluation, and alignment-configuration checks. This does not claim distributed pipeline-evaluation support.

Default direct-checkpoint modules to synchronous saving and reject explicitly unsupported async saves before creating process groups. Reject pipeline-enabled OLMoDDP in evaluator callbacks before evaluation starts. Preserve supported checkpointing and non-pipeline evaluation paths.

@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: 741b1f0517

ℹ️ 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 +175 to +177
elif isinstance(self.trainer.train_module, OLMoDDPTrainModule):
optimizers = [self.trainer.train_module.optim]
scheduler = self.trainer.train_module.scheduler

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 Refresh the PP schedule after changing the OLMoDDP batch size

When an OLMoDDPTrainModule uses pipeline parallelism and this callback reaches a later batch-size transition, the data loader is updated but the pipeline schedule retains the num_microbatches computed once in OLMoDDPTrainModule.on_attach(). Consequently increasing the global batch size increases the actual per-microbatch token count instead of the accumulation count, violating rank_microbatch_size and potentially exceeding the model/kernel buffers warmed for that size. Rebuild/reset the PP schedule's microbatch count at each transition, or reject this callback for PP-enabled OLMoDDP modules.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in af0fc66. Enabled, changing batch-size schedules are now rejected for native OLMoDDP pipeline modules before batch-size/LR mutation. The same guard runs during attachment, checkpoint restoration, and batch loading. Disabled callbacks and empty/single-point initialization remain supported; non-PP batch/LR scheduling is unchanged. Tests cover fresh/resumed states and verify the batch, optimizer groups, and schedule count remain untouched on rejection. This deliberately rejects an unsupported combination instead of introducing an unvalidated schedule/buffer rebuild. The 126-test infra suite passes, including standard pipeline controls.

f"'{self.__class__.__name__}' only supports transformer train modules "
f"('{TransformerTrainModule.__name__}', '{OLMoDDPTrainModule.__name__}')"
)
if isinstance(train_module, OLMoDDPTrainModule) and train_module.pp_enabled:

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 context-parallel OLMoDDP evaluators on attach

For an OLMoDDPTrainModule configured with context parallelism but not pipeline parallelism, this validation accepts the evaluator, yet OLMoDDPTrainModule.eval_batch() unconditionally raises that context-parallel evaluation is unsupported. Any startup, periodic, final, or checkpoint evaluation therefore fails only after evaluation begins; include cp_enabled in this capability check so the unsupported configuration is rejected consistently.

Useful? React with 👍 / 👎.

@RustinS RustinS Sep 17, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in af0fc66. EvaluatorCallback.post_attach now rejects context-parallel OLMoDDP modules, matching the existing pipeline-parallel guard and eval_batch capability. Focused coverage checks CP rejection while preserving non-CP/non-PP evaluation. No context-parallel inference support is claimed. The fix is also integrated into alignment head c6c884e.

Comment on lines +763 to +764
if schedule_name == PipelineScheduleType.custom_1F1B:
raise NotImplementedError("Custom 1F1B schedule is not implemented yet.")

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 Remove or implement the exposed Custom1F1B schedule

PipelineScheduleType.custom_1F1B is exposed as a valid single-stage schedule and passes the new custom-stage compatibility checks, but constructing its PipelineSchedule always raises here. Thus a standard transformer configuration selecting Custom1F1B successfully builds its stages and then fails during pre_train() before the first batch; either implement the schedule or reject/remove this enum choice during configuration validation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in af0fc66. Generic TransformerPipelineParallelConfig now rejects Custom1F1B with OLMoConfigurationError before accessing/splitting the model or allocating stages, with supported alternatives in the error. Tests exercise both custom-stage settings and confirm no model/stage access occurs. Standard PyTorch schedules and the implemented custom schedules retain their existing paths.

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

ℹ️ 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 +718 to +720
dp_ws = get_world_size(self.trainer.dp_process_group)
rank_batch_size = self.trainer.global_batch_size // dp_ws
num_microbatches = rank_batch_size // self.rank_microbatch_size

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 Reject non-divisible native pipeline batches

When OLMoDDP pipeline training uses a global batch size that is not divisible by rank_microbatch_size * dp_ws, this floors the microbatch count instead of rejecting the configuration. The custom schedule then uses torch.tensor_split, producing larger leading chunks, while CustomPipelineStage.prepare_step() allocates every receive buffer using the floored size; adjacent stages therefore disagree on P2P tensor shapes and the initial dry run can fail or hang. Validate the same divisibility invariant enforced by TransformerPipelineTrainModule.pre_train() before constructing this schedule.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in 3fb6687 (current infra head 7460543). Native PP now requires positive global/rank-microbatch sizes and exact divisibility of global_batch_size by rank_microbatch_size * DP world size before constructing the schedule or warming communication buffers. This mirrors standard pipeline training's divisibility contract and prevents a zero/floored microbatch count. Regression cases cover valid batches, multiple DP sizes, non-divisible batches, batches smaller than a microbatch, and nonpositive sizes; rejected cases assert neither schedule construction nor buffer prewarming occurs. Integrated alignment verification passes 319 tests, including standard two-rank pipeline controls.

Comment on lines +915 to +922
for candidate_path in candidate_paths:
if self.checkpointer.dir_is_checkpoint(candidate_path):
expanded_paths.append(candidate_path)
else:
expanded_paths.extend(
checkpoint_path
for _, checkpoint_path in sorted(
self.checkpointer.find_checkpoints(candidate_path),

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 Filter files from recursive checkpoint glob results

For a documented recursive wildcard such as checkpoints_to_eval=["/runs/**"], glob_directory() returns both directories and files. Every matched file that is not itself a checkpoint is passed to find_checkpoints(), which calls list_directory() and ultimately Path.iterdir() on that file, raising NotADirectoryError; the outer handler then aborts the entire evaluation even if valid checkpoint directories were also matched. Filter non-directories or treat them as non-matches before attempting checkpoint discovery.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in 3fb6687 and 7460543 (current infra head 7460543). Checkpoint globs now request directories only through glob_directory(include_files=False), using the existing local/object-store listing filters. Other glob callers retain the existing include-files default, and explicit-path error handling is unchanged. Follow-up full-checkpoint coverage also exposed duplicate discovery of stepN and stepN/model_and_optim; a wildcard expansion now skips descendants of a checkpoint already selected, while explicit model-state requests remain supported. Tests cover marker-only and full checkpoints, nested directories, file matches, deduplication/step ordering, missing paths, explicit-file errors, and mocked gs/s3/r2/weka filter delegation. Real cloud-mutating tests were not run. The integrated 319-test suite passes.

@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: 7460543c41

ℹ️ 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 +1060 to +1064
x0, x1 = h.chunk(2, dim=0) # assume even batch size
labels0, labels1 = None, None
if labels is not None:
labels0, labels1 = labels.chunk(2, dim=0)
del labels

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 Split per-token LM-head arguments between TBO halves

When two-batch overlap is enabled with loss_weights or response_mask, _prepare_inputs() places the full-batch tensor in lm_head_kwargs, but this code splits only the hidden states and labels before passing the same kwargs to both half-batch LM-head calls. The first half therefore receives B/2 logits with B weights/mask entries, causing either the weighted-loss dot product or response-mask shape validation to fail. Split every batch-shaped LM-head argument alongside labels and pass separate kwargs for each half.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in ef9030c. The TBO forward path now splits loss_weights, response_mask, and tensor-valued logits_to_keep along the instance dimension and passes independent kwargs dictionaries to the two LM-head calls. Scalar normalization and integer position selection stay shared. CPU regression tests exercise the actual TBO/LM-head path with expert communication stubbed, checking full-batch parity for logits, summed weighted CE/z-loss, and gradients, plus inference and position selection. The existing direct-TBO mean-reduction limitation with unequal nonignored counts is separate; this change preserves the training path, which uses sum with shared normalization.

Comment thread src/olmo_core/nn/ddp/model.py Outdated
return_logits=return_logits,
**kwargs,
)
assert input_ids.size(0) % 2 == 0, "When TBO is enabled, the batch size must be even."

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 TBO using the instance dimension

TBO requires an even input_ids.size(0), but the train-module setup only reasons about rank_microbatch_size in tokens, so configurations such as rank_microbatch_size == max_sequence_length pass construction and prewarming yet produce a one-instance microbatch and hit this assertion on the first forward. Validate that each generated microbatch has an even number of instances, including any remainder microbatch, before training starts.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in ef9030c. Configuration now validates the number of instances before device initialization. Training checks actual instance geometry, including variable sequence lengths, short batches, odd remainders, and pipeline chunk sizes, before processing any microbatch. Evaluation checks its actual batch and explicitly rejects pipeline+TBO evaluation because that schedule uses one instance per microbatch. The model also raises a clear configuration error for empty/odd input batches; the prewarm token-capacity guard remains separate. Regression coverage includes valid configurations and TBO-disabled controls.

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

ℹ️ 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".

@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: 60bd333f92

ℹ️ 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/train/trainer.py Resolved

@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: 01d89b23a0

ℹ️ 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".

@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: 2ff1ad04d7

ℹ️ 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".

@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: 4d5de13f79

ℹ️ 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 +1389 to +1391
checkpoint_key = self._resolve_model_checkpoint_key(name, checkpoint_keys)
if checkpoint_key is None:
continue

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 Reject checkpoints with unresolved model parameters

When an eval-only or model-only load encounters a missing or differently named parameter, this silently skips it and continues evaluating with that parameter's freshly initialized value. Since the direct checkpoint path rejects load_key_mapping and custom strictness options, a partial or incompatible checkpoint can therefore produce plausible but invalid evaluation results instead of failing; only explicitly handled frozen/optimizer-owned parameters should be exempted, and other unresolved model keys should raise an error.

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: cdce5522a0

ℹ️ 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 +2698 to +2703
if self.pp_enabled:
kwargs: Dict[str, Any] = {}
if has_doc_lens:
kwargs["doc_lens"] = batch["doc_lens"]
kwargs["max_doc_lens"] = batch["max_doc_lens"]
return input_ids, labels, kwargs

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 Preserve loss weights in pipeline batch preparation

When pp_config is enabled and a batch contains loss_weights, this branch initializes fresh kwargs and copies only document-length metadata, silently dropping the weights before the final pipeline stage. Since OLMoDDPModel/LMHead otherwise support weighted loss and the non-pipeline path forwards the batch kwargs, the same configuration under PP optimizes ordinary cross-entropy instead of the requested weighted objective; forward and microbatch-split loss_weights, or reject this combination.

Useful? React with 👍 / 👎.

Comment on lines +408 to +412
unexpected_keys = set(kwargs) - supported_keys
if unexpected_keys:
raise ValueError(
f"Unsupported kwargs for pipeline splitting: {sorted(unexpected_keys)}"
)

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 Split intra-document metadata in custom pipeline schedules

When native pipeline training receives a packed batch containing doc_lens and max_doc_lens, _prepare_batch() explicitly forwards both into PipelineSchedule.step(), but this allowlist rejects them as unexpected kwargs. Such a run therefore aborts on its first forward pass despite intra-document masking being accepted by the train module; add splitting/broadcast semantics for these fields or reject the mode before training starts.

Useful? React with 👍 / 👎.

Comment on lines +277 to +280
if self == InitMethod.llama:
std = std / (2 * num_blocks) ** 0.5
elif self == InitMethod.llama_depth:
std = std / (2 * (block_idx + 1)) ** 0.5

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 Honor fan-in initialization for MoE-v2 weights

When OLMoDDPModelConfig.init_method is fan_in, this method falls through without adjusting std, so every MoE-v2 router, up/gate matrix, and down matrix uses the shared init_std (normally 0.02). That contradicts the accepted InitMethod.fan_in semantics and the existing dense/legacy-MoE initializers, which use 1/sqrt(d_in) separately for each matrix, producing materially different initial activation scales; add the corresponding per-matrix fan-in handling here.

Useful? React with 👍 / 👎.

jason718 added a commit that referenced this pull request Sep 30, 2026
Minimal extension points so a module that wraps an OLMoDDPModel (e.g. a
multimodal model with a vision encoder and connector around the LM) can be
trained by OLMoDDPTrainModule without changing text-only behavior:

- OLMoDDPModel.forward: optional `input_embeddings` (precomputed embeddings
  in place of forward_embed) and `router_loss_div_factor` (a separate
  divisor for router auxiliary losses); both default to None.
- OLMoDDPModel.apply_dp: optional `root_module` so the wrapper's extra
  parameters join the multi-group DDP wrapper.
- OLMoDDPTrainModule: `_is_olmo_ddp_compatible` opt-in check, a
  `_batch_auxiliary_loss_kwargs` hook (empty by default) applied at both
  model calls, and identity adapters around the direct checkpoint load.
- OLMoDDPTrainModuleConfig._build_train_module: build hook for subclasses.
- internal.experiment: `parse_cli_args`, `train()` returns the trainer, a
  dry-run parameter print guard for non-transformer models, and a generic
  self-contained dataset branch after the numpy and composable ones.

Extracted from RustinS's #868; everything else in that PR is not carried.
jason718 added a commit that referenced this pull request Oct 1, 2026
…odel

A downstream (text-only) evaluation batch carries labels but no loss_masks;
the wrapper raised instead of evaluating it. Given labels alone the forward
now defers to the language model's per-token loss (ignore_index, reduction,
z-loss, divisor and return_logits forwarded), so OLMoDDPTrainModule.eval_batch
works unchanged on the multimodal model. The delegating test is replaced by
one that runs the real tiny model through eval_batch with reduction "none".

Document two limitations of this layer in the model docstring and the
changelog: the router token mask of #868 is not carried (router load-balancing
and z-loss statistics include padding tokens), and frozen expert weights
under expert parallelism cannot be checkpointed. The multi-GPU checkpoint
round-trip test now expects the NotImplementedError for frozen experts under
EP and round-trips a model with trainable experts instead.
jason718 added a commit that referenced this pull request Oct 1, 2026
…ment runs

Two behaviors that #868 had added to the shared callbacks now live in
multimodal subclasses, as the move table planned:

- MultimodalEvaluatorCallback remembers the last step evaluated under the
  "eval" prefix (cleared on train start and checkpoint load) so eval_on_finish
  does not re-evaluate a step the interval or startup evaluation just covered.
  MultimodalEvaluatorCallbackConfig.build returns it.
- MultimodalCheckpointerCallback seeds its permanent-checkpoint list from the
  checkpoints an earlier run left behind (steps up to the current one) and
  trims to max_checkpoints, so a resumed phase keeps the same bounded set;
  remove=never still removes nothing.

The alignment recipe uses both. Its config's from_dict override now matches
the Config signature.
jason718 added a commit that referenced this pull request Oct 1, 2026
Minimal extension points so a module that wraps an OLMoDDPModel (e.g. a
multimodal model with a vision encoder and connector around the LM) can be
trained by OLMoDDPTrainModule without changing text-only behavior:

- OLMoDDPModel.forward: optional `input_embeddings` (precomputed embeddings
  in place of forward_embed) and `router_loss_div_factor` (a separate
  divisor for router auxiliary losses); both default to None.
- OLMoDDPModel.apply_dp: optional `root_module` so the wrapper's extra
  parameters join the multi-group DDP wrapper.
- OLMoDDPTrainModule: `_is_olmo_ddp_compatible` opt-in check, a
  `_batch_auxiliary_loss_kwargs` hook (empty by default) applied at both
  model calls, and identity adapters around the direct checkpoint load.
- OLMoDDPTrainModuleConfig._build_train_module: build hook for subclasses.
- internal.experiment: `parse_cli_args`, `train()` returns the trainer, a
  dry-run parameter print guard for non-transformer models, and a generic
  self-contained dataset branch after the numpy and composable ones.

Extracted from RustinS's #868; everything else in that PR is not carried.
jason718 added a commit that referenced this pull request Oct 1, 2026
…ster sync

A multimodal model trains a vision encoder, a connector and a language model
whose gradients live on different scales, and it loads pretrained weights into
the model after the optimizer has materialized its FP32 masters. Add a subclass
of OLMoDDPOptimizer (plus a config subclass) that the alignment recipe builds:

- opt-in gradient clipping per logical scheduler group, with the per-group
  norms and clip coefficients exposed for logging;
- per-component gradient-norm diagnostics from fnmatch patterns;
- a configurable foreach chunk size;
- partial model-to-master synchronization (whole parameters or selected rows)
  and a partial master check, used after loading a vision tower or
  reinitializing image-token embedding rows.

The shared optimizer is not modified; the logic comes from RustinS's #868/#869
where it lived in moe_optimizer.py.
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 1, 2026
…odel

A downstream (text-only) evaluation batch carries labels but no loss_masks;
the wrapper raised instead of evaluating it. Given labels alone the forward
now defers to the language model's per-token loss (ignore_index, reduction,
z-loss, divisor and return_logits forwarded), so OLMoDDPTrainModule.eval_batch
works unchanged on the multimodal model. The delegating test is replaced by
one that runs the real tiny model through eval_batch with reduction "none".

Document two limitations of this layer in the model docstring and the
changelog: the router token mask of #868 is not carried (router load-balancing
and z-loss statistics include padding tokens), and frozen expert weights
under expert parallelism cannot be checkpointed. The multi-GPU checkpoint
round-trip test now expects the NotImplementedError for frozen experts under
EP and round-trips a model with trainable experts instead.
jason718 added a commit that referenced this pull request Oct 1, 2026
…ment runs

Two behaviors that #868 had added to the shared callbacks now live in
multimodal subclasses, as the move table planned:

- MultimodalEvaluatorCallback remembers the last step evaluated under the
  "eval" prefix (cleared on train start and checkpoint load) so eval_on_finish
  does not re-evaluate a step the interval or startup evaluation just covered.
  MultimodalEvaluatorCallbackConfig.build returns it.
- MultimodalCheckpointerCallback seeds its permanent-checkpoint list from the
  checkpoints an earlier run left behind (steps up to the current one) and
  trims to max_checkpoints, so a resumed phase keeps the same bounded set;
  remove=never still removes nothing.

The alignment recipe uses both. Its config's from_dict override now matches
the Config signature.
jason718 added a commit that referenced this pull request Oct 2, 2026
Minimal extension points so a module that wraps an OLMoDDPModel (e.g. a
multimodal model with a vision encoder and connector around the LM) can be
trained by OLMoDDPTrainModule without changing text-only behavior:

- OLMoDDPModel.forward: optional `input_embeddings` (precomputed embeddings
  in place of forward_embed) and `router_loss_div_factor` (a separate
  divisor for router auxiliary losses); both default to None.
- OLMoDDPModel.apply_dp: optional `root_module` so the wrapper's extra
  parameters join the multi-group DDP wrapper.
- OLMoDDPTrainModule: `_is_olmo_ddp_compatible` opt-in check, a
  `_batch_auxiliary_loss_kwargs` hook (empty by default) applied at both
  model calls, and identity adapters around the direct checkpoint load.
- OLMoDDPTrainModuleConfig._build_train_module: build hook for subclasses.
- internal.experiment: `parse_cli_args`, `train()` returns the trainer, a
  dry-run parameter print guard for non-transformer models, and a generic
  self-contained dataset branch after the numpy and composable ones.

Extracted from RustinS's #868; everything else in that PR is not carried.

(cherry picked from commit 299e442)
jason718 added a commit that referenced this pull request Oct 2, 2026
A MultimodalLM around an OLMoDDPModel that opts into OLMoDDPTrainModule through the #886
hooks: embeddings go in through `input_embeddings`, router auxiliary losses get their own
divisor, apply_dp wraps the whole model, and the weighted response-only loss (plus the LM's
z-loss) is computed from the response logits. Text-only batches defer to the LM's plain loss.
For recurrent LMs (Kimi Delta Attention) packed examples are isolated through document
boundaries derived from example_ids instead of attention masks; pixels are cast to the vision
tower's dtype. The router token mask of #868 is not carried (documented).
jason718 added a commit that referenced this pull request Oct 2, 2026
Minimal extension points so a module that wraps an OLMoDDPModel (e.g. a
multimodal model with a vision encoder and connector around the LM) can be
trained by OLMoDDPTrainModule without changing text-only behavior:

- OLMoDDPModel.forward: optional `input_embeddings` (precomputed embeddings
  in place of forward_embed) and `router_loss_div_factor` (a separate
  divisor for router auxiliary losses); both default to None.
- OLMoDDPModel.apply_dp: optional `root_module` so the wrapper's extra
  parameters join the multi-group DDP wrapper.
- OLMoDDPTrainModule: `_is_olmo_ddp_compatible` opt-in check, a
  `_batch_auxiliary_loss_kwargs` hook (empty by default) applied at both
  model calls, and identity adapters around the direct checkpoint load.
- OLMoDDPTrainModuleConfig._build_train_module: build hook for subclasses.
- internal.experiment: `parse_cli_args`, `train()` returns the trainer, a
  dry-run parameter print guard for non-transformer models, and a generic
  self-contained dataset branch after the numpy and composable ones.

Extracted from RustinS's #868; everything else in that PR is not carried.

(cherry picked from commit 299e442)
jason718 added a commit that referenced this pull request Oct 2, 2026
A MultimodalLM around an OLMoDDPModel that opts into OLMoDDPTrainModule through the #886
hooks: embeddings go in through `input_embeddings`, router auxiliary losses get their own
divisor, apply_dp wraps the whole model, and the weighted response-only loss (plus the LM's
z-loss) is computed from the response logits. Text-only batches defer to the LM's plain loss.
For recurrent LMs (Kimi Delta Attention) packed examples are isolated through document
boundaries derived from example_ids instead of attention masks; pixels are cast to the vision
tower's dtype. The router token mask of #868 is not carried (documented).
@jason718
jason718 marked this pull request as draft October 2, 2026 18:30
jason718 added a commit that referenced this pull request Oct 2, 2026
Minimal extension points so a module that wraps an OLMoDDPModel (e.g. a
multimodal model with a vision encoder and connector around the LM) can be
trained by OLMoDDPTrainModule without changing text-only behavior:

- OLMoDDPModel.forward: optional `input_embeddings` (precomputed embeddings
  in place of forward_embed) and `router_loss_div_factor` (a separate
  divisor for router auxiliary losses); both default to None.
- OLMoDDPModel.apply_dp: optional `root_module` so the wrapper's extra
  parameters join the multi-group DDP wrapper.
- OLMoDDPTrainModule: `_is_olmo_ddp_compatible` opt-in check, a
  `_batch_auxiliary_loss_kwargs` hook (empty by default) applied at both
  model calls, and identity adapters around the direct checkpoint load.
- OLMoDDPTrainModuleConfig._build_train_module: build hook for subclasses.
- internal.experiment: `parse_cli_args`, `train()` returns the trainer, a
  dry-run parameter print guard for non-transformer models, and a generic
  self-contained dataset branch after the numpy and composable ones.

Extracted from RustinS's #868; everything else in that PR is not carried.

(cherry picked from commit 299e442)
jason718 added a commit that referenced this pull request Oct 2, 2026
A MultimodalLM around an OLMoDDPModel that opts into OLMoDDPTrainModule through the #886
hooks: embeddings go in through `input_embeddings`, router auxiliary losses get their own
divisor, apply_dp wraps the whole model, and the weighted response-only loss (plus the LM's
z-loss) is computed from the response logits. Text-only batches defer to the LM's plain loss.
For recurrent LMs (Kimi Delta Attention) packed examples are isolated through document
boundaries derived from example_ids instead of attention masks; pixels are cast to the vision
tower's dtype. The router token mask of #868 is not carried (documented).
jason718 added a commit that referenced this pull request Oct 3, 2026
Minimal extension points so a module that wraps an OLMoDDPModel (e.g. a
multimodal model with a vision encoder and connector around the LM) can be
trained by OLMoDDPTrainModule without changing text-only behavior:

- OLMoDDPModel.forward: optional `input_embeddings` (precomputed embeddings
  in place of forward_embed) and `router_loss_div_factor` (a separate
  divisor for router auxiliary losses); both default to None.
- OLMoDDPModel.apply_dp: optional `root_module` so the wrapper's extra
  parameters join the multi-group DDP wrapper.
- OLMoDDPTrainModule: `_is_olmo_ddp_compatible` opt-in check, a
  `_batch_auxiliary_loss_kwargs` hook (empty by default) applied at both
  model calls, and identity adapters around the direct checkpoint load.
- OLMoDDPTrainModuleConfig._build_train_module: build hook for subclasses.
- internal.experiment: `parse_cli_args`, `train()` returns the trainer, a
  dry-run parameter print guard for non-transformer models, and a generic
  self-contained dataset branch after the numpy and composable ones.

Extracted from RustinS's #868; everything else in that PR is not carried.

(cherry picked from commit 299e442)
jason718 added a commit that referenced this pull request Oct 3, 2026
A MultimodalLM around an OLMoDDPModel that opts into OLMoDDPTrainModule through the #886
hooks: embeddings go in through `input_embeddings`, router auxiliary losses get their own
divisor, apply_dp wraps the whole model, and the weighted response-only loss (plus the LM's
z-loss) is computed from the response logits. Text-only batches defer to the LM's plain loss.
For recurrent LMs (Kimi Delta Attention) packed examples are isolated through document
boundaries derived from example_ids instead of attention masks; pixels are cast to the vision
tower's dtype. The router token mask of #868 is not carried (documented).
jason718 added a commit that referenced this pull request Oct 5, 2026
Minimal extension points so a module that wraps an OLMoDDPModel (e.g. a
multimodal model with a vision encoder and connector around the LM) can be
trained by OLMoDDPTrainModule without changing text-only behavior:

- OLMoDDPModel.forward: optional `input_embeddings` (precomputed embeddings
  in place of forward_embed) and `router_loss_div_factor` (a separate
  divisor for router auxiliary losses); both default to None.
- OLMoDDPModel.apply_dp: optional `root_module` so the wrapper's extra
  parameters join the multi-group DDP wrapper.
- OLMoDDPTrainModule: `_is_olmo_ddp_compatible` opt-in check, a
  `_batch_auxiliary_loss_kwargs` hook (empty by default) applied at both
  model calls, and identity adapters around the direct checkpoint load.
- OLMoDDPTrainModuleConfig._build_train_module: build hook for subclasses.
- internal.experiment: `parse_cli_args`, `train()` returns the trainer, a
  dry-run parameter print guard for non-transformer models, and a generic
  self-contained dataset branch after the numpy and composable ones.

Extracted from RustinS's #868; everything else in that PR is not carried.

(cherry picked from commit 299e442)
jason718 added a commit that referenced this pull request Oct 5, 2026
A MultimodalLM around an OLMoDDPModel that opts into OLMoDDPTrainModule through the #886
hooks: embeddings go in through `input_embeddings`, router auxiliary losses get their own
divisor, apply_dp wraps the whole model, and the weighted response-only loss (plus the LM's
z-loss) is computed from the response logits. Text-only batches defer to the LM's plain loss.
For recurrent LMs (Kimi Delta Attention) packed examples are isolated through document
boundaries derived from example_ids instead of attention masks; pixels are cast to the vision
tower's dtype. The router token mask of #868 is not carried (documented).
jason718 added a commit that referenced this pull request Oct 5, 2026
A MultimodalLM around an OLMoDDPModel that opts into OLMoDDPTrainModule through the #886
hooks: embeddings go in through `input_embeddings`, router auxiliary losses get their own
divisor, apply_dp wraps the whole model, and the weighted response-only loss (plus the LM's
z-loss) is computed from the response logits. Text-only batches defer to the LM's plain loss.
For recurrent LMs (Kimi Delta Attention) packed examples are isolated through document
boundaries derived from example_ids instead of attention masks; pixels are cast to the vision
tower's dtype. The router token mask of #868 is not carried (documented).
jason718 added a commit that referenced this pull request Oct 5, 2026
A MultimodalLM around an OLMoDDPModel that opts into OLMoDDPTrainModule through the #886
hooks: embeddings go in through `input_embeddings`, router auxiliary losses get their own
divisor, apply_dp wraps the whole model, and the weighted response-only loss (plus the LM's
z-loss) is computed from the response logits. Text-only batches defer to the LM's plain loss.
For recurrent LMs (Kimi Delta Attention) packed examples are isolated through document
boundaries derived from example_ids instead of attention masks; pixels are cast to the vision
tower's dtype. The router token mask of #868 is not carried (documented).
@jason718 jason718 closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants