| 2086 | compute_dtype = torch.float32 |
| 2087 | |
| 2088 | def check_module(denoiser): |
| 2089 | # This will also check if the peft layers are in torch.float8_e4m3fn dtype (unlike test_layerwise_casting_inference_denoiser) |
| 2090 | for name, module in denoiser.named_modules(): |
| 2091 | if not isinstance(module, _GO_LC_SUPPORTED_PYTORCH_LAYERS): |
| 2092 | continue |
| 2093 | dtype_to_check = storage_dtype |
| 2094 | if any(re.search(pattern, name) for pattern in patterns_to_check): |
| 2095 | dtype_to_check = compute_dtype |
| 2096 | if getattr(module, "weight", None) is not None: |
| 2097 | self.assertEqual(module.weight.dtype, dtype_to_check) |
| 2098 | if getattr(module, "bias", None) is not None: |
| 2099 | self.assertEqual(module.bias.dtype, dtype_to_check) |
| 2100 | if isinstance(module, BaseTunerLayer): |
| 2101 | self.assertTrue(getattr(module, "_diffusers_hook", None) is not None) |
| 2102 | self.assertTrue(module._diffusers_hook.get_hook(_PEFT_AUTOCAST_DISABLE_HOOK) is not None) |
| 2103 | |
| 2104 | # 1. Test forward with add_adapter |
| 2105 | components, _, denoiser_lora_config = self.get_dummy_components() |