Skip to content

Add mixed midtraining after vision alignment - #874

Closed
RustinS wants to merge 3 commits into
rustins/native-vision-alignmentfrom
rustins/native-mixed-midtraining
Closed

RustinS wants to merge 3 commits into
rustins/native-vision-alignmentfrom
rustins/native-mixed-midtraining

Conversation

@RustinS

@RustinS RustinS commented Sep 19, 2026

Copy link
Copy Markdown

Stack

Depends on #869 (vision alignment). This PR is based on rustins/native-vision-alignment
so its diff contains only mixed midtraining. The intended landing branch is vision;
retarget after the alignment dependency lands there. No changes to the infrastructure
or alignment PRs are included.

Summary

  • Add Mixed-Midtraining.py through the standard internal experiment runner, with a
    joint-alignment checkpoint as a model-only handoff and ordinary full-state resume.
  • Reuse the alignment model, tokenizer, multimodal sources, packing, loss normalization,
    distributed runtime and standalone evaluations.
  • Default to the 61-source text mixture and eight visual source groups, including OCR,
    scalar and grounded counting, pointing and filtered alignment replay. Preserve prepared
    selections and exclusions; do not add Tulu to the visual mixture.
  • Allocate 90% text / 10% vision expected supervised-loss weight. Set
    --recipe.text_loss_share=1.0 for T100; source configurations and visual shares remain
    configurable with calibrated means.
  • Train vision, connector and LM with MB2/pack64, 8K context, 128 global sequences,
    two eight-GPU nodes and EP8. Use a 50B-position cosine horizon and 200-step warmup.
    Preserve the parent router settings without introducing an RMS repair.
  • Use the native CLI parser and config replacement methods. Reject contradictory loss
    overrides and whole-recipe overrides that would bypass component construction.

The scope is nine files: two recipe/data modules, one entrypoint, two test files,
configuration documentation/calibration, a guide and its index entry. Profiler prototypes,
historical launch wrappers, checkpoints and evaluation result files are excluded.

Validation

161 CPU tests passed against the stacked source:

CUDA_VISIBLE_DEVICES='' PYTHONPATH=src python -m pytest -q \
  src/test/internal/vision_midtraining_test.py \
  src/test/internal/vision_midtraining_data_test.py \
  src/test/data/multimodal/mixture_weights_test.py \
  src/test/data/multimodal/grouped_mixture_test.py \
  src/test/data/multimodal/text_only_collator_test.py

Ruff, Black, isort and whitespace checks pass. Tests cover mixed/T100 defaults,
serialization, schedule/allocation consistency, source selection and duplicate point-style
expansion, calibration, overrides, grouped-loader resume and text-only collation.

The recipe has matched 2,000-attempted-step mixed/T100 runs and a completed frozen-vision
ablation with unchanged fast-text, decoded and sampled academic evaluations. Unfrozen vision
leads on five of six academic panels; frozen leads on VQAv2 and the small scalar-count
diagnostic. Frozen comparison evaluation.
These are bounded validation panels, not full official benchmarks, a certification of
unseen-data generalization, or validation of the complete 50B horizon. Counting and pointing
remain weaknesses. No new GPU training was run for this cleanup.

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

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

save_interval=10_000,
ephemeral_save_interval=500,
save_async=False,
pre_train_checkpoint=True,

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 Skip the pre-train save after resuming step zero

If a run is preempted after the initial step0 checkpoint finishes but before the first batch, the trainer restores that checkpoint from save_folder with global_step == 0, and this forced pre_train_checkpoint=True makes the callback immediately save step0 again. Because save_overwrite=False, the second save raises FileExistsError, so this otherwise valid full-state resume cannot proceed. Leave this as None or otherwise suppress the pre-train save when a checkpoint was loaded.

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 5cc1619. Removed the forced pre_train_checkpoint=True so the standard checkpoint-aware default skips the save after loading step0. Overwrite protection and periodic checkpointing remain unchanged. The default also skips the redundant step-zero snapshot after loading the alignment parent.

Added a regression using the actual recipe callback for both mixed training (text_loss_share=0.9) and T100 (1.0), checking that a loaded step0 is discovered without another synchronous or asynchronous save. Both cases failed before the fix. Validation: 190 relevant CPU tests passed; Black, isort, Ruff, and git diff --check passed.

@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: 5cc1619a81

ℹ️ 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 +594 to +597
config.trainer.load_strategy != LoadStrategy.always
or config.trainer.load_optim_state is not False
or config.trainer.load_trainer_state is not False
):

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 no-checkpoints before the model handoff

When a short performance run sets --trainer.no_checkpoints=true, this validation still accepts the configuration, but Trainer.fit() gates the entire checkpoint-loading block on not self.no_checkpoints. The run therefore skips recipe.parent_checkpoint and silently trains the randomly initialized multimodal model instead of the aligned weights. Reject this flag for this recipe, or disable only the checkpoint-writing callback so the required model-only load still occurs.

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 dc99e51. Mixed-recipe validation now rejects trainer.no_checkpoints=true with an error directing users to trainer.callbacks.checkpointer.enabled=false. The latter disables only checkpoint writes and preserves parent/save-folder loading; the guide now documents it explicitly. Shared Trainer behavior is unchanged.

Added parameterized regressions for mixed training (text_loss_share=0.9) and T100 (1.0): reject no_checkpoints and accept write-only disabling while retaining the required model-only handoff configuration. Both rejection cases failed before the fix. Validation: 194 relevant CPU tests passed; Black, isort, Ruff, and git diff --check passed.

@jason718
jason718 marked this pull request as draft October 5, 2026 20:31
jason718 added a commit that referenced this pull request Oct 6, 2026
…es to vision

The recipe, data module, entry point, calibration, guide and tests from
rustins/native-mixed-midtraining. Two adaptations to the merged alignment code:
the joint-alignment source builders register on import of vision_alignment_phases,
and the caption source sets style_length_conditioning=True explicitly (vision's
PixMoCapDatasetConfig default is False).

Co-authored-by: RustinS <[email protected]>
@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