Add SeaCache support for Cosmos3 pipelines - #14663
Conversation
|
Claude-Opus 4.8 Self-review:
|
| location | status | reason |
|---|---|---|
sea_cache.py:555 _prepare_cosmos3_vision_metadata + first_block branch in _build_indicator |
Likely-dead under default | only runs when indicator_source="first_block"; default is raw_vision_latents |
SeaCacheConfig.metadata_callback / raw_vision_callback |
Likely-dead | no caller passes them; Cosmos3 uses native adapters |
_helpers.py hidden_states_norm_module_name |
Used only by first_block | tied to the non-default indicator |
Process reminders (AI-contribution guidelines)
- Uncommitted/untracked files in your worktree are NOT in the pushed diff but shouldn't get added:
check_cosmos3_transfer_workflow.py,run_cosmos3_modular_transfer.sh,assets/,examples/cosmos3/inference_cosmos3_modular_distilled.py, and an unstagedencoders.pyedit. The dev scripts/assets are ephemeral (per review-rules "Ephemeral context") — keep them out of the PR. - Add a coordination link (issue where a maintainer acknowledged this work) to the PR description.
- Add test commands + pasted results to the PR. Suggested:
pytest tests/hooks/test_sea_cache.py tests/models/transformers/test_models_transformer_cosmos3.py tests/pipelines/cosmos/test_cosmos3.py tests/modular_pipelines/cosmos/ -q.
Verdict: NEEDS CHANGES
Primary asks: split the three features (#1), trim defensive/unused paths (#2, #3). Tests are strong — real Cosmos3 model at tiny config, per-context cache isolation, fail-open, and dtype coverage all exercised, consistent with testing.md
sayakpaul
left a comment
There was a problem hiding this comment.
Thanks! The design looks mostly good. My major comment is that we're adding utilities to enable caching at the pipeline-level which is not something we typically do in the library.
| [`Cosmos3OmniPipeline`], [`Cosmos3OmniModularPipeline`], and [`Cosmos3DistilledModularPipeline`] enable SeaCache | ||
| automatically when inference starts. The default [`SeaCacheConfig`] filters raw vision latents, linearly extrapolates | ||
| the cached residual, uses `threshold=0.25`, and allows at most two consecutive cached steps before forcing a full | ||
| transformer execution. |
There was a problem hiding this comment.
It is not clear if SeaCache is specific to the Cosmos3 family or if it can generally be applied to other pipelines as well. If the latter is true, then let's make it clearer.
|
|
||
| class TestCosmos3OmniTransformerModel(Cosmos3OmniTransformerTesterConfig, ModelTesterMixin): | ||
| @pytest.mark.parametrize("indicator_source", ["first_block", "raw_vision_latents"]) | ||
| def test_cosmos3_supports_sea_cache_without_changing_state_dict_keys(self, indicator_source): |
There was a problem hiding this comment.
We should add the caching tests similar to:
|
Hi @yzhautouskay, thanks for the PR! It does not appear to link an issue it fixes. If this PR addresses an existing issue, please add a closing keyword (e.g. Please note that PRs without a linked issue are likely to be automatically closed 10 days after this notice. Once the PR links an issue (or gets the |
| add_resolution_template: bool = True, | ||
| add_duration_template: bool = True, | ||
| enable_safety_check: bool = True, | ||
| use_fp32_sampling_state: bool = True, |
There was a problem hiding this comment.
ohhh can we just drop this flag and always upcost to fp32 if it improve the accuracy, i mean how much additional memory it would cost? should not be much , no?
|
@yiyixuxu @sayakpaul Thanks for the review! I addressed moving caching to the transformer level instead of pipeline, and refactored tests Few thing I will address next:
|
What does this PR do?
0.25, and at most2consecutive cached steps. This provides 2-3x speedup depending on inference params with on-par quality.Before submitting
self-reviewskill on the diff?documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
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.