(
self,
coefficients: list[float],
num_steps: int,
rel_l1_thresh: float = 0.0,
num_skip_start_steps: int = 0,
offload: bool = True,
)
| 25 | 2. Liu, Feng, et al. "Timestep Embedding Tells: It's Time to Cache for Video Diffusion Model." arXiv preprint arXiv:2411.19108 (2024). |
| 26 | """ |
| 27 | def __init__( |
| 28 | self, |
| 29 | coefficients: list[float], |
| 30 | num_steps: int, |
| 31 | rel_l1_thresh: float = 0.0, |
| 32 | num_skip_start_steps: int = 0, |
| 33 | offload: bool = True, |
| 34 | ): |
| 35 | if num_steps < 1: |
| 36 | raise ValueError(f"`num_steps` must be greater than 0 but is {num_steps}.") |
| 37 | if rel_l1_thresh < 0: |
| 38 | raise ValueError(f"`rel_l1_thresh` must be greater than or equal to 0 but is {rel_l1_thresh}.") |
| 39 | if num_skip_start_steps < 0 or num_skip_start_steps > num_steps: |
| 40 | raise ValueError( |
| 41 | "`num_skip_start_steps` must be great than or equal to 0 and " |
| 42 | f"less than or equal to `num_steps={num_steps}` but is {num_skip_start_steps}." |
| 43 | ) |
| 44 | self.coefficients = coefficients |
| 45 | self.num_steps = num_steps |
| 46 | self.rel_l1_thresh = rel_l1_thresh |
| 47 | self.num_skip_start_steps = num_skip_start_steps |
| 48 | self.offload = offload |
| 49 | self.rescale_func = np.poly1d(self.coefficients) |
| 50 | |
| 51 | self.cnt = 0 |
| 52 | self.should_calc = True |
| 53 | self.accumulated_rel_l1_distance = 0 |
| 54 | self.previous_modulated_input = None |
| 55 | # Some pipelines concatenate the unconditional and text guide in forward. |
| 56 | self.previous_residual = None |
| 57 | # Some pipelines perform forward propagation separately on the unconditional and text guide. |
| 58 | self.previous_residual_cond = None |
| 59 | self.previous_residual_uncond = None |
| 60 | |
| 61 | @staticmethod |
| 62 | def compute_rel_l1_distance(prev: torch.Tensor, cur: torch.Tensor) -> torch.Tensor: |
nothing calls this directly
no outgoing calls
no test coverage detected