Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 7.3k
Add SeaCache support for Cosmos3 pipelines#14663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
575abce5e2e41cd699832cabada1a95249861ac99bd89c5ee5cf0e5368bc00694078191dd8308c4030250a943d32342b72211d1d148dadff09e11b798877310af081414bba9fFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -68,6 +68,52 @@ config = FasterCacheConfig( | ||
| pipeline.transformer.enable_cache(config) | ||
| ``` | ||
| ## SeaCache | ||
| [SeaCache](https://huggingface.co/papers/2602.18993) compares Spectral-Evolution-Aware (SEA) indicators between | ||
| successive denoising steps. When the accumulated indicator change remains below a threshold, it skips the expensive | ||
| transformer block stack and predicts its output from cached residuals. The indicator is computed from the raw vision | ||
| latents, including clean conditioning frames for image-to-video generation. | ||
| The implementation provides built-in adapters for the following models: | ||
| - **Cosmos 3** is the primary optimized and benchmarked integration. It caches the complete decoder stack through a | ||
| post-normalization boundary and supports eager inference and regional compilation. | ||
| - **Wan T2V** uses the generic repeated-block path in eager mode. This integration demonstrates how another | ||
| single-stream video transformer can provide raw vision latents to SeaCache; it is not a claim that the same cache | ||
| parameters are optimal for Wan or that other Wan variants are supported. | ||
| Other video transformers can integrate with the generic path when they use `CacheMixin`, expose a recognized repeated | ||
| block list, and register the block input/output layout in `TransformerBlockRegistry`. The pipeline must enter a | ||
| `cache_context` for every transformer call, using separate context names for independent trajectories such as | ||
| conditional and unconditional guidance. Pass a `raw_vision_callback` that returns the noisy vision latents, in addition | ||
| to the scheduler metadata callbacks shown below. Validate output quality and tune the cache parameters for each model | ||
| and scheduler; support and benchmark results do not transfer automatically from Cosmos 3. | ||
| ### Cosmos 3 | ||
| SeaCache is disabled by default. Enable it on the transformer and provide callbacks for the active scheduler step, | ||
| sigma, and number of inference steps: | ||
| ```python | ||
| from diffusers import Cosmos3OmniPipeline, SeaCacheConfig | ||
| pipe = Cosmos3OmniPipeline.from_pretrained("nvidia/Cosmos3-Nano") | ||
| pipe.transformer.enable_cache( | ||
| SeaCacheConfig( | ||
| threshold=0.2, | ||
| max_consecutive_cached=2, | ||
| current_step_callback=lambda: pipe.current_step_index, | ||
| current_sigma_callback=lambda: pipe.current_sigma, | ||
| num_inference_steps_callback=lambda: pipe.num_timesteps, | ||
| ) | ||
| ) | ||
| ``` | ||
| 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. | ||
Comment on lines
+113
to
+115
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, thanks for the note! From a quick skim of the paper, it doesn't look like it needs to be Cosmos3 specific no? ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will try running SeaCache with other models, and will update the docs accordingly ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added Wan T2V support in 14bba9f as a minimal example of integrating another model. So docs now clarify that Cosmos3 remains the optimized and benchmarked integration, but is not intended to be the only supported model | ||
| ## FirstBlockCache | ||
| [FirstBlock Cache](https://huggingface.co/docs/diffusers/main/en/api/cache#diffusers.FirstBlockCacheConfig) checks how much the early layers of the denoiser changes from one timestep to the next. If the change is small, the model skips the expensive later layers and reuses the previous output. | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.