-
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?
Changes from all commits
575abce
5e2e41c
d699832
cabada1
a952498
61ac99b
d89c5ee
5cf0e53
68bc006
9407819
1dd8308
c403025
0a943d3
2342b72
211d1d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,34 @@ 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. | ||
|
|
||
| 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
+95
to
+97
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?
Contributor
Author
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 |
||
|
|
||
| ## 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.