[MiniMax-H3] TeaCache support and Cache-DiT validation (#5840)
Signed-off-by: dpeng123 <diyapeng123@gmail.com> Signed-off-by: lishunyang12 <lishunyang12@163.com> Co-authored-by: lishunyang12 <lishunyang12@163.com>
This commit is contained in:
1 parent
fc8946fcf5
commit
45629a8e26
10 files changed
+669
-15
No files matched your search
+29
-1
@@ -73,6 +73,34 @@ def enable_sensenova_u1_teacache(pipeline: Any, config: DiffusionCacheConfig) ->
|
||||
)
|
||||
|
||||
|
||||
def enable_minimax_h3_teacache(pipeline: Any, config: DiffusionCacheConfig) -> None:
|
||||
"""Enable TeaCache for the calibrated MiniMax-H3 FL2VA partition."""
|
||||
partition = getattr(pipeline, "partition", None)
|
||||
if partition == "ref2va":
|
||||
raise ValueError(
|
||||
"TeaCache only supports the MiniMax-H3 FL2VA partition; Ref2VA TeaCache has not been calibrated"
|
||||
)
|
||||
if partition not in {"fl2va", "combined"}:
|
||||
raise ValueError(f"Unsupported MiniMax-H3 partition for TeaCache: {partition!r}")
|
||||
|
||||
teacache_config = TeaCacheConfig(
|
||||
transformer_type="MiniMaxH3DiTModel",
|
||||
rel_l1_thresh=config.rel_l1_thresh,
|
||||
coefficients=config.coefficients,
|
||||
)
|
||||
apply_teacache_hook(pipeline.transformer, teacache_config)
|
||||
|
||||
if partition == "combined":
|
||||
logger.warning(
|
||||
"TeaCache is enabled only for MiniMax-H3 FL2VA; "
|
||||
"Ref2VA requests on this combined pipeline will run without TeaCache"
|
||||
)
|
||||
logger.info(
|
||||
f"TeaCache applied with rel_l1_thresh={teacache_config.rel_l1_thresh}, "
|
||||
"transformer_class=MiniMaxH3DiTModel, partition=FL2VA"
|
||||
)
|
||||
|
||||
|
||||
def enable_flux2_klein_teacache(pipeline: Any, config: DiffusionCacheConfig) -> None:
|
||||
"""
|
||||
Enable TeaCache for Flux2 Klein model.
|
||||
@@ -96,6 +124,7 @@ CUSTOM_TEACACHE_ENABLERS = {
|
||||
"BagelPipeline": enable_bagel_teacache,
|
||||
"Flux2KleinPipeline": enable_flux2_klein_teacache,
|
||||
"HunyuanImage3Pipeline": enable_hunyuan_image3_teacache,
|
||||
"MiniMaxH3Pipeline": enable_minimax_h3_teacache,
|
||||
"SenseNovaU1Pipeline": enable_sensenova_u1_teacache,
|
||||
}
|
||||
|
||||
@@ -145,7 +174,6 @@ class TeaCacheBackend(CacheBackend):
|
||||
|
||||
# Create TeaCacheConfig from DiffusionCacheConfig with transformer_type
|
||||
# Access parameters via attribute access: config.rel_l1_thresh
|
||||
# rel_l1_thresh already has a default value of 0.2 in DiffusionCacheConfig
|
||||
try:
|
||||
teacache_config = TeaCacheConfig(
|
||||
transformer_type=transformer_type,
|
||||
|
||||
Reference in new issue
Block a user