Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
4db9ea6
[omni, model] feat: add OmniModelRuntime and ModuleRuntime
Coach257 Sep 23, 2026
791703c
[omni, test] test: cover omni arg resolution with fake_model launcher…
Coach257 Sep 23, 2026
803aae7
[omni, model] feat: resolve accelerated omni module classes and load …
Coach257 Sep 23, 2026
7ab1836
[omni, data] feat: add SeedOmni data transform and SeedOmniCollator
Coach257 Sep 23, 2026
97c867b
[omni, trainer] feat: launch OmniModel training and inference through…
Coach257 Sep 23, 2026
02fdb1e
[omni, model] fix: store ModuleRuntime training args as train_args
Coach257 Sep 23, 2026
555b851
[omni, trainer] fix: average gradients over accumulation micro-batches
Coach257 Sep 23, 2026
1b88c2a
[omni, model] fix: run omni runtime nodes the way the eager OmniModel…
Coach257 Sep 23, 2026
995f839
[omni, model] fix: build each ModuleRuntime from the config OmniConfi…
Coach257 Sep 23, 2026
bfb5ec1
[omni, model] fix: keep module wrappers on the runtime side of OmniMo…
Coach257 Sep 23, 2026
a3df075
[omni, data] chore: drop packed preprocessing from the SeedOmni runtime
Coach257 Sep 24, 2026
5be6fc4
[omni] refactor: import omni arguments from their own modules
Coach257 Sep 24, 2026
6e4e46c
[omni] chore: drop the relocated-key hints from the argument parser
Coach257 Sep 24, 2026
7008b06
[omni, model] refactor: let ModuleRuntime decide its own ParallelStat…
Coach257 Sep 24, 2026
b55356d
[omni, config] fix: turn gradient checkpointing off in the fake_model…
Coach257 Sep 24, 2026
9950742
[omni, docs] chore: call it SeedOmni, not SeedOmni V2
Coach257 Sep 24, 2026
3af6603
[data, omni] fix: declare the video bundle's real frame rate and keep…
Coach257 Sep 24, 2026
4957db9
[omni, model] fix: refuse fsdp_mode='eager' in the generic model runtime
Coach257 Sep 24, 2026
5514cf7
[omni] fix: keep every training scenario when resolving from an omni …
Coach257 Sep 24, 2026
521a730
[omni] fix: drop the weights_path alias for a module's model_path
Coach257 Sep 24, 2026
4522af5
[data, omni] fix: time out image URL downloads
Coach257 Sep 24, 2026
94dd1ae
[omni, model] fix: let only the top-level fsdp_scope decide the compo…
Coach257 Sep 24, 2026
e3a25d0
[omni, model] fix: wrap LoRA before loading weights in distributed in…
Coach257 Sep 24, 2026
1e58bee
[omni, model] fix: drop ModuleRuntime.checkpoint_subfolder
Coach257 Sep 24, 2026
452e1a4
[omni, model] fix: serve a module without graph mixins as the eager m…
Coach257 Sep 24, 2026
49d9493
[omni, trainer] fix: reduce per-node losses over the same keys on eve…
Coach257 Sep 24, 2026
504cb76
[omni, trainer] fix: keep distributed inference from writing training…
Coach257 Sep 24, 2026
7860f7e
[omni, trainer] fix: move a distributed inference request onto the ra…
Coach257 Sep 24, 2026
a3791c1
[omni, trainer] fix: fetch the batch before counting the step
Coach257 Sep 24, 2026
0a0f480
[omni, model] fix: export a DDP-wrapped module's weights
Coach257 Sep 24, 2026
6607190
[omni, trainer] style: drop section-divider comments
Coach257 Sep 24, 2026
046d92d
[data, omni] fix: register the seedomni data transform from its trainer
Coach257 Sep 24, 2026
730a1e0
[data, omni] fix: name the packages the video gate checks
Coach257 Sep 28, 2026
e991146
[omni] test: skip clip tests where torchcodec cannot load
Coach257 Sep 28, 2026
0b1d87a
[omni] refactor: write optional argument fields as Optional[X], drop …
Coach257 Sep 28, 2026
73917b6
[omni] chore: drop __inherit__ YAML inheritance from the omni parser
Coach257 Sep 28, 2026
8f5d55e
[omni] refactor: drop unimplemented offline-cache workflow knobs
Coach257 Sep 28, 2026
5a27028
[omni] refactor: keep only seedomni data knobs in OmniDataArguments
Coach257 Sep 28, 2026
c43f248
[omni] refactor: drop test-only runtime-args builders
Coach257 Sep 28, 2026
b39d7fe
[omni] refactor: name the runtime-args builders build_omni_{module,mo…
Coach257 Sep 28, 2026
b9204d6
[omni] refactor: name the runtime builders build_omni_{module,model}_…
Coach257 Sep 28, 2026
1dfea19
[omni, data] refactor: move SeedOmniCollator into veomni/data/seed_omni
Coach257 Sep 28, 2026
2828aa5
[omni, data] chore: drop the legacy-return check in seedomni conv_pre…
Coach257 Sep 28, 2026
c2f8f4c
[omni, data] refactor: import seedomni registration and collator sepa…
Coach257 Sep 28, 2026
10c2018
[omni] refactor: clip the composed model through OmniModelRuntime.cli…
Coach257 Sep 28, 2026
ca9909a
[omni] chore: type the omni grad clippers' inputs
Coach257 Sep 28, 2026
8b28c03
[omni, trainer] fix: reset per-module async activation offload every …
Coach257 Sep 28, 2026
6f6bf30
[omni, trainer] fix: drain async DCP saves before OmniTrainer exits
Coach257 Sep 28, 2026
be550bb
[omni, trainer] chore: drop OmniTrainer.model_config
Coach257 Sep 28, 2026
a0db0eb
[omni, trainer] refactor: own the composed optimizer and lr-scheduler…
Coach257 Sep 28, 2026
8638af8
[omni, trainer] refactor: write the omni-root assets from OmniModelRu…
Coach257 Sep 28, 2026
615a1fd
[omni, trainer] refactor: name OmniTrainer's build and step hooks aft…
Coach257 Sep 28, 2026
4eff8ea
[omni, trainer] fix: refuse the MoE router monitor in OmniTrainer
Coach257 Sep 28, 2026
7269905
[omni, trainer] refactor: leave an all-frozen OmniModelRuntime withou…
Coach257 Sep 28, 2026
b95b973
[omni, model] fix: apply async activation offload to modules that def…
Coach257 Sep 28, 2026
538caaa
[omni] refactor: name the omni runtime argument classes once
Coach257 Sep 28, 2026
f33dd3b
[omni] refactor: drop the _hf_module_model_config wrapper
Coach257 Sep 28, 2026
78bbff5
[omni] refactor: trim omni_arguments_types __all__ to names used else…
Coach257 Sep 28, 2026
d2a3a19
[omni] refactor: reject the MoE router monitor in OmniArguments
Coach257 Sep 28, 2026
858f525
[omni] refactor: replace ModuleRuntime._defer_parallelize with wrap_o…
Coach257 Sep 28, 2026
68214db
[omni] refactor: call unwrap_module_chain directly in ModuleRuntime
Coach257 Sep 28, 2026
9a315b8
[omni] refactor: replace ModuleRuntime._eager with an is_eager property
Coach257 Sep 28, 2026
6b0065b
[omni] refactor: check eager modules under fsdp_scope='model' only at…
Coach257 Sep 28, 2026
fdd1488
[omni] refactor: make ModuleRuntime's global_accelerator required
Coach257 Sep 28, 2026
d42e5d4
[omni] refactor: drop the unused ModuleRuntime.customized_build_paral…
Coach257 Sep 28, 2026
44ebade
[omni] refactor: rename finish_deferred_parallelize to build_after_om…
Coach257 Sep 28, 2026
18753d4
[omni] refactor: make ModuleRuntime.model_assets a live property
Coach257 Sep 28, 2026
c0947ff
[omni] refactor: write omni-root module sidecars from ModuleRuntime.m…
Coach257 Sep 28, 2026
4a37136
[omni] refactor: name OmniModelRuntime's module lookup get_module, dr…
Coach257 Sep 28, 2026
a86bcf0
[omni] refactor: re-export accelerated names through subpackage __ini…
Coach257 Sep 29, 2026
e90dd3c
[ckpt, omni] refactor: move per-module path nesting out of ModelCheck…
Coach257 Sep 29, 2026
1c00435
[omni] feat: print ConversationItem as a multi-line block with media …
Coach257 Sep 29, 2026
1c39fc3
[model] chore: restore main's name for the customized setup_lora hook…
Coach257 Sep 29, 2026
ddcb839
[omni, trainer] refactor: schedule omni checkpoints with the shared C…
Coach257 Sep 29, 2026
cb58e76
[omni, ci] test: group seed_omni tests into scope subfolders
Coach257 Sep 29, 2026
083161d
[omni] refactor: drop ConversationItem.source and mark placeholders w…
Coach257 Sep 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .agents/knowledge/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,14 @@ veomni/
│ ├── dit_trainer.py DitTrainer: diffusion transformer training
│ ├── text_dpo_trainer.py DPO training for text models
│ ├── base_rl_trainer.py Base RL trainer for RLHF
│ └── callbacks/ Training callbacks (checkpoint, evaluate, trace, etc.)
│ ├── omni/ SeedOmni V2 orchestrators (not BaseTrainer subclasses):
│ │ OmniTrainer drives OmniModelRuntime's per-module
│ │ ModuleRuntimes; OmniInferencer runs the infer graph
│ │ (eager, or FSDP/DDP via the runtime). Launched by
│ │ tasks/omni/{train,infer}_omni.py
│ └── callbacks/ Training callbacks (checkpoint, evaluate, trace, etc.;
│ omni_callbacks/ holds the per-module DCP/HF, root
│ assets, step metrics and graph profile callbacks)
└── utils/ Shared utilities (logging, device, constants, helpers)
```

Expand Down
12 changes: 12 additions & 0 deletions configs/seed_omni/fake_model/infer/graph_infer_gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Launcher-style generation FSM: one state running the whole chain, then done.
# The convert-time form of the same graph lives in ../graph_infer.yaml, keyed by
# scenario; a launcher names the scenario in `model.model_config.infer_graph`.
initial: run

states:
run:
body:
- { from: fake_module_a, to: fake_module_b }
- { from: fake_module_b, to: end }
transitions:
- { condition: { type: default }, next_state: done }
10 changes: 10 additions & 0 deletions configs/seed_omni/fake_model/infer/graph_infer_und.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Understanding-only variant: the second module never runs, so a launcher with
# both scenarios has two genuinely different FSMs to select between.
initial: run

states:
run:
body:
- { from: fake_module_a, to: end }
transitions:
- { condition: { type: default }, next_state: done }
12 changes: 12 additions & 0 deletions configs/seed_omni/fake_model/infer/modules_infer_eager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Single-process eager inference: no wrapper on any module.
fake_module_a:
model_path: fake_module_a
accelerator:
fsdp_config:
fsdp_mode: eager

fake_module_b:
model_path: fake_module_b
accelerator:
fsdp_config:
fsdp_mode: eager
17 changes: 17 additions & 0 deletions configs/seed_omni/fake_model/infer/modules_infer_fsdp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Distributed inference: the chain keeps its training wraps, so a module that
# pins `fsdp_mode` here is not forced to eager by `for_inference=True`.
fake_module_a:
model_path: fake_module_a
broadcast_model_weights_from_rank0: false # only meaningful for fsdp2
accelerator:
init_device: cuda # ddp doesn't need meta-init's broadcast dance
fsdp_config:
fsdp_mode: ddp
gradient_checkpointing:
enable: false

fake_module_b:
model_path: fake_module_b
accelerator:
fsdp_config:
fsdp_mode: fsdp2
75 changes: 75 additions & 0 deletions configs/seed_omni/fake_model/train/base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# fake_module_a -> fake_module_b SeedOmni V2 launcher: the smallest config that
# drives OmniTrainer / OmniInferencer end to end. The modules are single linear
# maps, so this exercises the launch path, not a model.
#
# Prerequisites (any directory works; the paths below are only defaults):
# echo '{"model_type": "fake_omni", "hidden_size": 8}' > /tmp/fake_omni_src/config.json
# python scripts/seed_omni/convert_model.py \
# --model_path /tmp/fake_omni_src --output_dir /tmp/fake_omni
# # data: tulu-format jsonl, one sample per line, e.g.
# # {"source_name": "tulu-3-sft-mixture", "conversations": {"messages": [
# # {"role": "user", "content": "hi"}, {"role": "assistant", "content": "hello"}]}}
#
# Train (2 GPUs):
# bash train.sh tasks/omni/train_omni.py configs/seed_omni/fake_model/train/base.yaml \
# --data.train_path /tmp/fake_omni_data.jsonl
#
# Infer (single-process eager, or distributed with modules_infer_fsdp.yaml):
# python tasks/omni/infer_omni.py configs/seed_omni/fake_model/train/base.yaml \
# --model.model_config.modules configs/seed_omni/fake_model/infer/modules_infer_eager.yaml \
# --infer.prompt "hi"
model:
model_path: /tmp/fake_omni
model_config:
modules: configs/seed_omni/fake_model/train/modules_train.yaml
train_graph: configs/seed_omni/fake_model/train/graph_train.yaml
infer_graph:
infer_gen: configs/seed_omni/fake_model/infer/graph_infer_gen.yaml
infer_und: configs/seed_omni/fake_model/infer/graph_infer_und.yaml
infer_type: infer_gen

accelerator:
init_device: meta
fsdp_config:
fsdp_mode: fsdp2
mixed_precision:
enable: true
param_dtype: bfloat16
reduce_dtype: float32

optimizer:
type: adamw
lr: 1.0e-3
lr_warmup_ratio: 0.0
lr_decay_style: constant
weight_decay: 0.0
max_grad_norm: 1.0


data:
data_type: seedomni
train_path: /tmp/fake_omni_data.jsonl
datasets_type: mapping
dataloader:
type: native
num_workers: 0
drop_last: true


train:
seed: 42
num_train_epochs: 1
global_batch_size: 4
micro_batch_size: 1
dyn_bsz: false

checkpoint:
output_dir: outputs/fake_omni
save_steps: 2
save_epochs: 0
save_hf_weights: true
hf_save_steps: 0
hf_save_epochs: 0

infer:
output_dir: outputs/fake_omni_infer
5 changes: 5 additions & 0 deletions configs/seed_omni/fake_model/train/graph_train.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Launcher-style training DAG: a top-level edge list (bare module → .forward).
# The convert-time form of the same graph lives in ../graph_train.yaml, keyed by
# scenario; a launcher names the scenario in `model.model_config.train_type`.
- {from: fake_module_a, to: fake_module_b}
- {from: fake_module_b, to: end}
22 changes: 22 additions & 0 deletions configs/seed_omni/fake_model/train/modules_train.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Per-module training overlay for the fake_module_a -> fake_module_b chain.
#
# Deep-merged onto the launcher's top-level `model.*` block, so each entry only
# states what differs. The two modules deliberately pick different wraps: this
# is the smallest config that exercises per-module accelerator resolution.
fake_module_a:
model_path: fake_module_a
broadcast_model_weights_from_rank0: false # only meaningful for fsdp2
ops_implementation:
attn_implementation: eager
accelerator:
init_device: cuda # ddp doesn't need meta-init's broadcast dance
fsdp_config:
fsdp_mode: ddp

fake_module_b:
model_path: fake_module_b
ops_implementation:
attn_implementation: flash_attention_2
accelerator:
fsdp_config:
fsdp_mode: fsdp2
7 changes: 7 additions & 0 deletions configs/seed_omni/fake_model/train/modules_train_packed.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# modules_train.yaml plus a module-owned `processor_config`, which rides along
# to the exported OmniConfig while staying out of the model's own overrides.
__inherit__: modules_train.yaml

fake_module_a:
processor_config:
packed_preprocess: true
46 changes: 46 additions & 0 deletions tasks/omni/infer_omni.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""SeedOmni V2 inference via the VeOmni runtime (split checkpoint + generation FSM).

This is the **framework** inference path:

* ``model`` / per-module entries resolve to
:class:`~veomni.arguments.omni_arguments_types.OmniModelRuntimeArguments`
and :class:`~veomni.arguments.omni_arguments_types.OmniModuleRuntimeArguments`.
* When every module is ``fsdp_mode: eager``, :class:`~veomni.trainer.omni.omni_inferencer.OmniInferencer`
loads a composed :class:`~veomni.models.seed_omni.modeling_omni.OmniModel` from the split checkpoint.
* When any module opts into FSDP2 / DDP / ExtraParallel, the handle becomes
:class:`~veomni.models.seed_omni.accelerated.omni_model.omni_model_runtime.OmniModelRuntime`.

For **native eager** inference on a split checkpoint (simple process + generate, no
VeOmni runtime / YAML launcher), use ``tasks/omni/infer_omni_native.py`` instead.

Examples
--------
Single-process eager (``resolve_model(for_inference=True)`` forces eager unless the
``modules:`` overlay pins another ``fsdp_mode``):

python tasks/omni/infer_omni.py configs/seed_omni/fake_model/train/base.yaml \\
--model.model_config.modules configs/seed_omni/fake_model/infer/modules_infer_eager.yaml \\
--infer.prompt "hi"

Distributed inference (modules keep their DDP / FSDP2 wraps):

bash train.sh tasks/omni/infer_omni.py configs/seed_omni/fake_model/train/base.yaml \\
--model.model_config.modules configs/seed_omni/fake_model/infer/modules_infer_fsdp.yaml \\
--infer.prompt "hi"
"""

from veomni.arguments import OmniArguments, parse_omni_args
from veomni.trainer.omni import OmniInferencer


def main() -> None:
args = parse_omni_args(
OmniArguments,
preload_path_fields=("model.model_config.modules",),
)
inferencer = OmniInferencer(args)
inferencer.generate()


if __name__ == "__main__":
main()
8 changes: 8 additions & 0 deletions tasks/omni/train_omni.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from veomni.arguments import OmniArguments, parse_omni_args
from veomni.trainer.omni import OmniTrainer


if __name__ == "__main__":
args = parse_omni_args(OmniArguments, preload_path_fields=("model.model_config.modules",))
trainer = OmniTrainer(args)
trainer.train()
102 changes: 102 additions & 0 deletions tests/seed_omni/test_module_runtime_checkpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
"""``ModuleRuntime.skip_hf_weight_load`` — the frozen-module resume carve-out.

A full non-LoRA resume normally skips the initial HF weight materialization to
avoid a second memory peak. A fully-frozen OmniModule gets no checkpoint manager
(``ModuleRuntime.build_checkpoint``), so nothing would ever restore its weights —
it has to veto the skip and load the released HF ones.
"""

from types import SimpleNamespace
from unittest.mock import MagicMock

import pytest
import torch
import torch.nn as nn

from veomni.distributed.torch_compile import CompileConfig
from veomni.models.seed_omni.accelerated.omni_module.omni_module_runtime import ModuleRuntime


_RESUME_PATH = "/tmp/checkpoint/global_step_10"


def _build_module_runtime(model: nn.Module, *, load_path: str | None = _RESUME_PATH) -> ModuleRuntime:
runtime = ModuleRuntime.__new__(ModuleRuntime)
runtime.model = model
runtime.model_name = "test_module"
runtime.args = SimpleNamespace(model_path="/tmp/hf-model", lora_config=None)
runtime.train_args = SimpleNamespace(checkpoint=SimpleNamespace(load_path=load_path))
runtime._has_trainable_parameters = None
return runtime


@pytest.mark.parametrize(
("model", "expected"),
[
(nn.Linear(2, 2), True),
(nn.Module(), True),
],
)
def test_module_allows_skip_hf_weight_load(model: nn.Module, expected: bool) -> None:
assert _build_module_runtime(model).skip_hf_weight_load is expected


def test_frozen_module_with_persistent_state_must_load_hf_weights() -> None:
model = nn.Linear(2, 2)
model.requires_grad_(False)

assert _build_module_runtime(model).skip_hf_weight_load is False


def test_buffer_only_module_with_persistent_state_must_load_hf_weights() -> None:
model = nn.Module()
model.register_buffer("running_scale", torch.ones(1))

assert _build_module_runtime(model).skip_hf_weight_load is False


def test_without_resume_path_hf_weights_are_always_loaded() -> None:
"""No checkpoint to restore from ⇒ the HF pass is the only weight source."""
assert _build_module_runtime(nn.Linear(2, 2), load_path=None).skip_hf_weight_load is False


def test_parallelize_forwards_module_skip_decision(monkeypatch: pytest.MonkeyPatch) -> None:
parallelize = MagicMock(side_effect=lambda model, **kwargs: model)
# ``VeOmniModelRuntime._build_parallelized_model`` imports the builder inside
# the call, so the patch has to land on the defining module.
monkeypatch.setattr(
"veomni.distributed.torch_parallelize.build_parallelize_model",
parallelize,
)

model = nn.Linear(2, 2)
model.requires_grad_(False)
runtime = _build_module_runtime(model)
runtime.args = SimpleNamespace(
model_path="/tmp/hf-model",
lora_config=None,
fqn_to_index_mapping=None,
basic_modules=[],
optimizer=SimpleNamespace(type="adamw", muon_expert_zero_comm=False),
broadcast_model_weights_from_rank0=False,
ep_sharded_stream_load=False,
accelerator=SimpleNamespace(
init_device="meta",
torch_compile=CompileConfig(),
gradient_checkpointing=SimpleNamespace(enable=False, enable_reentrant=False, early_stop=True),
fsdp_config=SimpleNamespace(
reshard_after_forward=True,
mixed_precision=SimpleNamespace(enable=False),
forward_prefetch=False,
offload=False,
offload_pin_memory=False,
low_precision_reduce_scatter_comm=False,
max_load_broadcast_size=20.0,
),
offload_config=SimpleNamespace(enable_async_activation=False),
),
)

runtime._build_parallelized_model()

assert parallelize.call_args.kwargs["should_skip_hf_weight_load"] is False
Loading
Loading