MCPcopy Create free account
hub / github.com/huggingface/diffusers / run_forward

Method run_forward

tests/hooks/test_group_offloading.py:253–267  ·  view source on GitHub ↗
(model)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 4

get_hookMethod · 0.80
backend_empty_cacheFunction · 0.50

Tested by

no test coverage detected