(model)
| 251 | def test_offloading_forward_pass(self): |
| 252 | @torch.no_grad() |
| 253 | def run_forward(model): |
| 254 | gc.collect() |
| 255 | backend_empty_cache(torch_device) |
| 256 | backend_reset_peak_memory_stats(torch_device) |
| 257 | self.assertTrue( |
| 258 | all( |
| 259 | module._diffusers_hook.get_hook("group_offloading") is not None |
| 260 | for module in model.modules() |
| 261 | if hasattr(module, "_diffusers_hook") |
| 262 | ) |
| 263 | ) |
| 264 | model.eval() |
| 265 | output = model(self.input)[0].cpu() |
| 266 | max_memory_allocated = backend_max_memory_allocated(torch_device) |
| 267 | return output, max_memory_allocated |
| 268 | |
| 269 | self.model.to(torch_device) |
| 270 | output_without_group_offloading, mem_baseline = run_forward(self.model) |
nothing calls this directly
no test coverage detected