@@ -245,39 +245,27 @@ def _run_dit_local_i2i(self, total_steps=None):
245245 def run (self , total_steps = None ):
246246 if total_steps is None :
247247 total_steps = self .model .scheduler .infer_steps
248- run_error = None
249- try :
250- step_indices = range (total_steps )
251- if step_indices :
252- self .model .prepare_offload_weights ()
253-
254- for step_index in step_indices :
255- logger .info (f"==> step_index: { step_index + 1 } / { total_steps } " )
256-
257- with ProfilingContext4DebugL1 ("step_pre" ):
258- self .model .scheduler .step_pre (step_index = step_index )
259-
260- with ProfilingContext4DebugL1 ("🚀 infer_main" ):
261- self .model .infer (self .inputs )
262-
263- with ProfilingContext4DebugL1 ("step_post" ):
264- self .model .scheduler .step_post ()
265-
266- if self .progress_callback :
267- self .progress_callback (((step_index + 1 ) / total_steps ) * 100 , 100 )
268-
269- return self .model .scheduler .latents , self .model .scheduler .generator
270- except BaseException as caught_error :
271- run_error = caught_error
272- raise
273- finally :
274- try :
275- self .model .force_cleanup_offload_weights ()
276- except BaseException as cleanup_error :
277- if run_error is None :
278- raise
279- if hasattr (run_error , "add_note" ):
280- run_error .add_note (f"Flux2 offload cleanup also failed: { cleanup_error !r} " )
248+
249+ self .model .prepare_offload_weights ()
250+
251+ for step_index in range (total_steps ):
252+ logger .info (f"==> step_index: { step_index + 1 } / { total_steps } " )
253+
254+ with ProfilingContext4DebugL1 ("step_pre" ):
255+ self .model .scheduler .step_pre (step_index = step_index )
256+
257+ with ProfilingContext4DebugL1 ("🚀 infer_main" ):
258+ self .model .infer (self .inputs )
259+
260+ with ProfilingContext4DebugL1 ("step_post" ):
261+ self .model .scheduler .step_post ()
262+
263+ if self .progress_callback :
264+ self .progress_callback (((step_index + 1 ) / total_steps ) * 100 , 100 )
265+
266+ self .model .force_cleanup_offload_weights ()
267+
268+ return self .model .scheduler .latents , self .model .scheduler .generator
281269
282270 def get_custom_shape (self ):
283271 default_aspect_ratios = {
0 commit comments