Spaces:
Runtime error
Runtime error
add cache
Browse files655 unmodified lines656657658659660661662655 unmodified linesguidance = guidance.expand(latents.shape[0])else:guidance = None# 6. Denoising loopwith self.progress_bar(total=num_inference_steps) as progress_bar:for i, t in enumerate(timesteps):655 unmodified lines656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685655 unmodified linesguidance = guidance.expand(latents.shape[0])else:guidance = None## Caching conditions# clean the cachefor name, attn_processor in self.transformer.attn_processors.items():attn_processor.bank_kv.clear()# cache with warmup latentsstart_idx = latents.shape[1] - 32warmup_latents = latents[:, start_idx:, :]warmup_latent_ids = latent_image_ids[start_idx:, :]t = torch.tensor([timesteps[0]], device=device)timestep = t.expand(warmup_latents.shape[0]).to(latents.dtype)_ = self.transformer(hidden_states=warmup_latents,cond_hidden_states=cond_latents,timestep=timestep/ 1000,guidance=guidance,pooled_projections=pooled_prompt_embeds,encoder_hidden_states=prompt_embeds,txt_ids=text_ids,img_ids=warmup_latent_ids,joint_attention_kwargs=self.joint_attention_kwargs,return_dict=False,)[0]# 6. Denoising loopwith self.progress_bar(total=num_inference_steps) as progress_bar:for i, t in enumerate(timesteps):
src/pipeline.py+24-1