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.
|
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 |
|
@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:
|
sayakpaul
left a comment
There was a problem hiding this comment.
Thanks for the updates! This looks much better!
| This model-level API works with [`Cosmos3OmniPipeline`], [`Cosmos3OmniModularPipeline`], and | ||
| [`Cosmos3DistilledModularPipeline`]. SeaCache is an approximate optimization and may change generated outputs. Call | ||
| `pipe.transformer.disable_cache()` when you need every denoising step to execute the full transformer. |
There was a problem hiding this comment.
Nice, thanks for the note! From a quick skim of the paper, it doesn't look like it needs to be Cosmos3 specific no?
There was a problem hiding this comment.
I will try running SeaCache with other models, and will update the docs accordingly
|
/diffusers-bot pytest tests/models -k "seacache" |
|
✅ |
9009730 to
211d1d1
Compare
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.