[cosmos3] Bitwise train/rollout parity: FSDP precision spec + cosmos3_bitwise rollout patch group - #109
Open
zhihengy wants to merge 8 commits into
Open
[cosmos3] Bitwise train/rollout parity: FSDP precision spec + cosmos3_bitwise rollout patch group#109zhihengy wants to merge 8 commits into
zhihengy wants to merge 8 commits into
Conversation
zhihengy
force-pushed
the
feat/cosmos3-bitwise-align
branch
from
August 10, 2026 03:52
a326ddb to
f9d5371
Compare
zhihengy
force-pushed
the
feat/cosmos3-bitwise-align
branch
2 times, most recently
from
August 12, 2026 10:22
7479e7d to
76ace00
Compare
Rockdu
reviewed
Aug 13, 2026
| --lora-rank 64 \ | ||
| --lora-alpha 128 \ | ||
| --diffusion-init-lora-weight gaussian \ | ||
| --lora-ipc-weight-sync \ |
Collaborator
There was a problem hiding this comment.
seems like this old bash script is conflicting with the latest one
zhihengy
force-pushed
the
feat/cosmos3-bitwise-align
branch
from
August 17, 2026 22:34
6c2fe43 to
bffbb7e
Compare
Registers the bitwise 4-GPU recipe in stage-c-5-gpu-h200 (opt-in via run-ci-e2e, nightly). --deterministic-mode joins the recipe so the standard compares strictly; the model_output parity metrics must be exactly 0 under the cosmos3_bitwise patch group + dynamic LoRA merge. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Recorded offline on 4xH200 in a replica of the CI image environment (torch 2.11.0+cu129, sglang main 0065fbfae1, diffusers 0.39.0): the model_output parity series are exactly 0 on both optimizer steps. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…e-align
Conflicts: the LoRA merge-mode warning in arguments.py (both sides added
it for their own patch group — unified over {qwen_image, cosmos3_bitwise});
the registered-groups test (sgld was renamed qwen_image by #108).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Cosmos3OmniTransformer.forward defaults to a Cosmos3OmniTransformerOutput since f53d5520 (the requirements pin); unpacking that object yields only the non-None fields and T2I has neither sound nor action, so the 3-tuple unpack got 1 value. return_dict=False returns the unchanged tuple. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
zhihengy
force-pushed
the
feat/cosmos3-bitwise-align
branch
from
August 18, 2026 16:41
b4a43ac to
2976fe1
Compare
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #25 (
feat/cosmos3).Summary
Makes the Cosmos3 GRPO training forward (miles/diffusers/FSDP2) produce bit-identical tensors to the rollout engine (sglang-d), verified across every aligned module output: 103/103 comparable tensor pairs bit-exact (both CFG branches, UND+GEN towers, first and last denoise steps,
embed_tokensthroughproj_out).Train side
time_embedderfp32 island: diffusers declares_keep_in_fp32_modules = ["time_embedder"]and sglang-d pins it to fp32 at load; the blanket bf16 gather silently downgraded it on the train side. The familyFSDPParallelPlan.param_dtype_patterns(the refactor(fsdp)(5/5): compile per-model precision plans onto the dtype patch #106 mechanism) gathers it at fp32, the wrapper runs it with autocast disabled, and identical sinusoid rows are deduplicated before the MLP (cuBLAS fp32 GEMMs are not bitwise M-invariant, measured on the 4096x4096 MLP; sglang-d runs M=1 per request).F.rms_norm: eager diffusers RMSNorm rounds to bf16 before the weight mul (two roundings); sglang-d keeps fp32 through the mul. Upgrade the train side (never downgrade) so both run the identical op.Rollout side (
--rollout-patch-group cosmos3_bitwise, per the #97 CLI selection; the recipe sets it)TORCH_SDPAattention backend (matches the train-side SDPA path).F.rms_norm.MergedColumnParallelLinear(to_qkv,gate_up_proj) into per-sliceF.linearGEMMs — fused column blocks are not bitwise equal to the standalone GEMMs diffusers runs. Slices come fromoutput_sizes(with tp=1 init order,output_partition_sizescollapses to one fused slice); the patch fails loud rather than silently falling back fused.SiluAndMuland split (unfused) qk-norm/RoPE path.Validation
pair_metricsshowsmax_abs_diff = 0for all 103 aligned pairs; 3 remaining records are benign scalar-vs-broadcast shape mismatches with byte-identical values.PrecisionSpecmechanism; now rebased onto main's own precision machinery (refactor(fsdp)(5/5): compile per-model precision plans onto the dtype patch #106param_dtype_patterns+ParamDtypeMixedPrecisionPolicy) and the refactor(diffusion): move rollout patch group selection to a CLI arg #97 CLI patch-group selection — same fp32 gather island, no parallel implementation. The dump comparison should be re-run on this base before merge.Test plan
ci-sglang-pr: 0065fbfae1d22626203c158b9e8c0e8f7126c4cd