[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
+22
-7
@@ -83,6 +83,19 @@ _MODEL_COEFFICIENTS = {
|
||||
],
|
||||
# LongCat Image transformer coefficients
|
||||
"LongCatImageTransformer2DModel": [652.5980, -424.1615, 84.5526, -4.5923, 0.1694],
|
||||
# MiniMax-H3 FL2VA coefficients.
|
||||
"MiniMaxH3DiTModel": [
|
||||
2.283704065852778e03,
|
||||
-7.775977277886368e02,
|
||||
9.408414741359490e01,
|
||||
-4.232669906169421e00,
|
||||
2.173782527946167e-01,
|
||||
],
|
||||
}
|
||||
|
||||
_DEFAULT_REL_L1_THRESH = 0.2
|
||||
_MODEL_DEFAULT_REL_L1_THRESH = {
|
||||
"MiniMaxH3DiTModel": 0.17,
|
||||
}
|
||||
|
||||
|
||||
@@ -97,10 +110,8 @@ class TeaCacheConfig:
|
||||
|
||||
Args:
|
||||
rel_l1_thresh: Threshold for accumulated relative L1 distance. When below threshold,
|
||||
cached residual is reused. Values in [0.1, 0.3] work best:
|
||||
- 0.2: ~1.5x speedup with minimal quality loss
|
||||
- 0.4: ~1.8x speedup with slight quality loss
|
||||
- 0.6: ~2.0x speedup with noticeable quality loss
|
||||
cached residual is reused. If None, uses the model-specific default or 0.2
|
||||
when no model-specific default is registered.
|
||||
coefficients: Polynomial coefficients for rescaling L1 distance. If None, uses
|
||||
model-specific defaults based on transformer_type.
|
||||
transformer_type: Transformer class name (e.g., "QwenImageTransformer2DModel").
|
||||
@@ -108,14 +119,18 @@ class TeaCacheConfig:
|
||||
Defaults to "QwenImageTransformer2DModel".
|
||||
"""
|
||||
|
||||
rel_l1_thresh: float = 0.2
|
||||
rel_l1_thresh: float | None = None
|
||||
coefficients: list[float] | None = None
|
||||
transformer_type: str = "QwenImageTransformer2DModel"
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
"""Validate and set default coefficients."""
|
||||
if self.rel_l1_thresh <= 0:
|
||||
raise ValueError(f"rel_l1_thresh must be positive, got {self.rel_l1_thresh}")
|
||||
threshold = self.rel_l1_thresh
|
||||
if threshold is None:
|
||||
threshold = _MODEL_DEFAULT_REL_L1_THRESH.get(self.transformer_type, _DEFAULT_REL_L1_THRESH)
|
||||
if threshold <= 0:
|
||||
raise ValueError(f"rel_l1_thresh must be positive, got {threshold}")
|
||||
self.rel_l1_thresh = threshold
|
||||
|
||||
if self.coefficients is None:
|
||||
# Use model-specific coefficients, explicitly check if the type exists or not
|
||||
|
||||
Reference in new issue
Block a user