Conversation
|
/tag-and-rerun-ci |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a foundational architectural change by refactoring the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a generic DiffusionCache base class, refactoring TeaCache from a mixin to a TeaCacheStrategy. This is a strong architectural improvement that enhances modularity and will make it easier to add other caching mechanisms like MagCache in the future. However, a high-severity Denial of Service (DoS) vulnerability was identified in the TeaCacheStrategy.get_context implementation. This is due to an assertion verifying the presence of teacache_params in sampling_params, which are not currently defined or initialized in the SamplingParams class. This allows an attacker to crash the model runner process by simply enabling TeaCache in a generation request. Please address this by ensuring proper parameter initialization and graceful error handling. Additionally, there is a suggestion to prevent a potential division-by-zero error.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/tag-and-rerun-ci |
|
also cc @DefTruth for this one |
|
@mickqian Nvidia CI passed and PR is approved, ready for merge — SGLDHelper bot |
|
To do:
|
|
/rerun-failed-ci |
3 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
2 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/tag-and-rerun-ci |
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
6 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/tag-and-rerun-ci |
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
3 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
3 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
Make
Teacacheuse a genericDiffusionCacheclass so it is easier to add other timestep caching diffusion techniques such as Magcache. This is a prerequisite for #18498.The Problem
Previously, TeaCache was implemented using mixins that tightly coupled the caching logic to individual model classes. This led to several issues:
TeaCacheMixin, and others toTeaCacheContext. This made it difficult to manage across different generation requests.WanTeaCacheParamsvsTeaCacheParams), making the user-facing API confusing.TeaCacheto a new model required nearly ~100 lines of boilerplate code.HunyuanVideosupport was incomplete/broken due to these architectural limitations.Key Improvements
We split the logic into three distinct components:
TeaCacheParams:User-provided settings (thresholds, offsets) defined in a request at the start of a generation.TeaCacheState:Internal state (cached tensors, accumulated L1 distances) that is updated after every forward pass. Crucially, the step counter is now attached here rather than the model.TeaCacheStrategy:The actual implementation that takes inTeaCacheParamsandTeaCacheStateto decide when to skip a computation.Previously,
Cacheable-DiTinheritedTeaCacheMixin. To support multiple caching stratigies,Cacheable-DiTcannot inherit from all the different caching mixins bevause we only know which cache we want during the forward pass, not when we init and inherit fom cachable-dit. So we move the cache toCacheable-DiT.cacheand initializd it during init_cache().TeaCacheStrategyis better abstracted, supporting HunyuanVideo required only 5 lines of code, compared to ~100 lines before.WanTeaCacheParamsintoTeaCacheParams.Old PR description
Motivation
Make
Teacacheuse a genericDiffusionCacheclass so it is easier to add other timestep caching diffusion techniques such as Magcache. This is a prerequisite for #18498.Modifications
DiffusionCacheclass maintains a state to tracks the persistent information and a context for non-persistent information needed to determine if we should cache or not.TeaCachepreviously had a lot of copy and pasted code to handle both positive and negative cfg classes. We abstract this away with a state for each cfg.We also support a
cache.calibratemethod to compute the values needed for caching. Magcache implements this in #18498 and we can implement this for teacahe later.We also add the parameter for teacache from the original paper into the config sampling params for
Wan-AI/Wan2.1-T2V-1.3B-Diffusers.The logic to compute skipping the forward pass was split in _compute_teacache_decision and _compute_l1_and_decide and now it is unified in should_skip_forward.
Accuracy Tests
Benchmarking and Profiling
Baseline (this branch)
[03-05 14:14:32] Completed batch processing. Generated 1 outputs in 150.78 seconds
fight-base.mp4
Baseline (main)
[03-05 14:25:39] Completed batch processing. Generated 1 outputs in 150.56 seconds
fight-base-main.mp4
Teacache (this branch)
[03-05 12:45:47] Completed batch processing. Generated 1 outputs in 104.04 seconds
fight-teacache.mp4
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci