(self, dit: WanModel, x, t_mod)
| 486 | self.coefficients = self.coefficients_dict[model_id] |
| 487 | |
| 488 | def check(self, dit: WanModel, x, t_mod): |
| 489 | modulated_inp = t_mod.clone() |
| 490 | if self.step == 0 or self.step == self.num_inference_steps - 1: |
| 491 | should_calc = True |
| 492 | self.accumulated_rel_l1_distance = 0 |
| 493 | else: |
| 494 | coefficients = self.coefficients |
| 495 | rescale_func = np.poly1d(coefficients) |
| 496 | self.accumulated_rel_l1_distance += rescale_func(((modulated_inp-self.previous_modulated_input).abs().mean() / self.previous_modulated_input.abs().mean()).cpu().item()) |
| 497 | if self.accumulated_rel_l1_distance < self.rel_l1_thresh: |
| 498 | should_calc = False |
| 499 | else: |
| 500 | should_calc = True |
| 501 | self.accumulated_rel_l1_distance = 0 |
| 502 | self.previous_modulated_input = modulated_inp |
| 503 | self.step += 1 |
| 504 | if self.step == self.num_inference_steps: |
| 505 | self.step = 0 |
| 506 | if should_calc: |
| 507 | self.previous_hidden_states = x.clone() |
| 508 | return not should_calc |
| 509 | |
| 510 | def store(self, hidden_states): |
| 511 | self.previous_residual = hidden_states - self.previous_hidden_states |
no test coverage detected