Skip to content

[cosmos3] Cosmos3-Nano GRPO support: train pipeline config, VideoAlign reward, T2V recipe - #25

Draft
zhihengy wants to merge 1 commit into
mainfrom
feat/cosmos3
Draft

[cosmos3] Cosmos3-Nano GRPO support: train pipeline config, VideoAlign reward, T2V recipe#25
zhihengy wants to merge 1 commit into
mainfrom
feat/cosmos3

Conversation

@zhihengy

@zhihengy zhihengy commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

What

End-to-end GRPO post-training support for nvidia/Cosmos3-Nano (16B MoT: 8B UND + 8B GEN):

  • Cosmos3TrainPipelineConfig: replicates the diffusers packed-sequence forward (text+vision joint sequence, mRoPE via diffusers helpers), UND tower frozen by param-name fragments (it sits inside the training graph), LoRA targets = GEN attention only. Cosmos3ModelBackend loads transformer+scheduler only.
  • Token-level conditioning: CondKwargs gains text_ids/text_mask/fps — Cosmos3 has no separate text encoder; shipping tokens verbatim eliminates the text-replay-consistency failure class.
  • VideoAlign (KlingTeam/VideoReward) reward worker: VQ/MQ/TA z-score sum, runs in a pinned interpreter (transformers 4.45.x) via Ray runtime_env.py_executable; rolling per-dimension logging (TA collapse is the canonical hacking mode and is invisible in the Overall sum).
  • Recipes: run-diffusion-grpo-cosmos3-videoalign-4gpu.sh (3 colocate + 1 reward GPU, 16-step SDE, 17f 832x480, LoRA r64) and _smoke_cosmos3_t2i.sh (2-GPU pipeline smoke).

Companion sglang-d branch: feat/cosmos3-rl-rollout (rollout SDE-Euler on the serving sigma grid + trajectory sigmas + fused-param weight-sync fix).

Validation

  • T2I pipeline smoke (3 rollouts): ratio_abs_minus_1 stable at 1–2.5e-5 (10x below clip range), cross-engine weight-sync checksums equal.
  • T2V e2e run on wandb (miles-diffusion-grpo/diffusion_grpo_cosmos3_videoalign_*): rollout 768x17f in ~15 min on 3 engines, VideoAlign reward mean -1.1 ± 1.8, first steps healthy.

Draft: long-run reward trend still being monitored; batched multi-sample generation per request deliberately deferred (packed forward is single-sample).

…I recipe

Rebased onto the loss-hub/input-dtype-policy refactor as one commit (the
pre-refactor history is preserved on backup/feat-cosmos3-pre-rebase; most
intermediate commits were add-then-drop pairs already split to other PRs).

- Cosmos3TrainPipelineConfig: packed single-sample forward over the MoT
  DiT (UND/GEN towers), token-level conditioning (text_ids/text_mask/fps
  on CondKwargs), GEN-only training with UND frozen, timestep-scale
  handled in-model.
- Boundary dtypes moved to the refactor's input_dtype_policy:
  latents=default, cond=passthrough (the packed forward casts its own
  inputs; mRoPE position ids ~15000 would be scrambled by a bf16 boundary
  cast), timestep=fp32 (karras grid is non-integer; bf16 rounds
  993.25 -> 992). Replaces the pre-refactor fsdp_cast_forward_inputs /
  cast_timesteps_to_forward_dtype flags.
- use_cfg: guidance <= 1 runs single-branch, matching sglang do_cfg
  (now in loss_hub.flow_grpo).
- --fsdp-frozen-params-dtype: frozen base stays at checkpoint-native
  dtype; only LoRA params get fp32 master copies.
- Engine: multi-GPU engines pin the full contiguous CVD slice; num_gpus
  owns the rollout allocation with tp/sp from --sglang-* passthrough.
- Weight sync: send one copy of the all-gathered payload (size-1
  contract; the engine shards internally).

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant