Repository navigation
[Cosmos3] Read checkpoint mixed-precision policy through wrapped transformers - #15480
Merged
yiyixuxu merged 2 commits intoDec 4, 2026
Conversation
Contributor
Author
|
CC @piotrm-nvidia since he's our colleague who reported the related issue |
yiyixuxu
reviewed
Dec 3, 2026
…sformers Look up load_config on the module instance instead of its class. torch.compile's OptimizedModule and other attribute-forwarding wrappers expose the original module's load_config, so the checkpoint policy resolves through them.
ConstBob
force-pushed
the
fix/cosmos3-mixed-precision-wrapped-transformer
branch
from
December 3, 2026 18:39
5e77385 to
f66aa2e
Compare
yiyixuxu
reviewed
Dec 3, 2026
Move the regression test into test_cosmos3.py as a single pipeline test that uses the real Cosmos3OmniTransformer.
piotrm-nvidia
approved these changes
Dec 4, 2026
piotrm-nvidia
left a comment
There was a problem hiding this comment.
Thanks @ConstBob! I tested this PR with FlexTensor, which wraps the transformer. It works: the Cosmos3-Nano FP8 video is identical to the run without the wrapper. It also lets me simplify my example code.
Drafted with AI assistance; reviewed and verified by me.
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
yiyixuxu
approved these changes
Dec 4, 2026
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.
What does this PR do?
The on-disk policy lookup used
type(module).load_config. Atorch.compilewrapper (OptimizedModule) does not have that method, so the policy silently fell back to all-W8A8. Look upload_configon the module instance instead of its class.Other wrappers that forward attribute access have the same problem, so the lookup now uses
getattr(module, "load_config", None).Fixes #15169
Impact: with
nvidia/Cosmos3-Nano-FP8(revision722946a6), wrappingpipe.transformerwithtorch.compilechanged the resolved policy fromfp8tonone, so the first and last 3 steps ran W8A8 instead of W8A16. With this change the wrapped output matches the unwrapped default output exactly. Without the policy (mixed_precision_format="none") the output differs.Tests
tests/pipelines/cosmos/test_cosmos3.py::TestCosmos3OmniPipeline::test_mixed_precision_policy_resolves_through_torch_compilebuilds the realCosmos3OmniTransformerfrom the dummy components, writes a ModelOpt FP8 step policy into its config, and checks thattorch.compileresolves the same policy as the bare model.I ran these locally with the tiny tokenizer download stubbed, because this sandbox cannot reach the Hub. The test itself is unchanged.
End-to-end on
nvidia/Cosmos3-Nano-FP8(256x448, 17 frames, 8 steps, seed 123, block-level group offload,torch.compile(..., backend="eager"), torch 2.13, modelopt 0.44):pipe.transformerfp8, first/last 3mixed_precision_format="none"nonebasetorch.compilefp8, first/last 3Max abs diff of the output: bare default vs compiled = 0.0, bare default vs bare
none= 1.0.Self-review notes
Ran the
self-reviewskill on the diff before the test was moved intotest_cosmos3.py. No blocking findings, no dead code, no stale docs. Left for review:torch.compileonly. The attribute-forwarding wrapper goes through the same lookup, but it is not tested separately.Before submitting
self-reviewskill on the diff?documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@sayakpaul @yiyixuxu
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.