Spaces:
Running on Zero
Running on Zero
Commit ·
9757065
1
Parent(s): 83f6c58
Fix step-done log ordering vs text_encoder offload/pre-VAE-decode
Browse filesThe step-done print used a timestamp captured at callback entry but
printed after the offload/pre-VAE-decode logging (which use fresh
perf_counter() calls), making log lines appear out of chronological
order on the final step. Print step-done immediately after computing
it instead.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -575,6 +575,9 @@ def _make_step_callback(steps, timer, t0, mode: Mode, cuda_ok: bool = False):
|
|
| 575 |
if step_idx == 0:
|
| 576 |
timer.mark("first_step")
|
| 577 |
timer.mark("last_step") # overwritten each step; final value = end of last step
|
|
|
|
|
|
|
|
|
|
| 578 |
# Text encoder is done after prompt encoding, before the denoising loop starts.
|
| 579 |
# Dropping it (~15GB) ahead of VAE decode's fp32-upcast memory spike only pays off
|
| 580 |
# when that spike is big enough to need the headroom (see Mode.offloads_text_encoder_before_decode).
|
|
@@ -596,9 +599,6 @@ def _make_step_callback(steps, timer, t0, mode: Mode, cuda_ok: bool = False):
|
|
| 596 |
if step_idx == steps - 1 and cuda_ok:
|
| 597 |
print(f"[infer] pre-VAE-decode — {_gpu_mem_str(True, sync=True)} | t={time.perf_counter()-t0:.1f}s")
|
| 598 |
torch.cuda.reset_peak_memory_stats()
|
| 599 |
-
delta_ms = (now - (step_times[-2] if len(step_times) > 1 else t0)) * 1000
|
| 600 |
-
tag = " ← includes cold-start (offload hook install + first weight transfer)" if step_idx == 0 else ""
|
| 601 |
-
print(f"[infer] step {step_idx+1}/{steps} done — {delta_ms:.0f}ms{tag} | t={now-t0:.1f}s")
|
| 602 |
return cb_kwargs
|
| 603 |
return _step_cb
|
| 604 |
|
|
|
|
| 575 |
if step_idx == 0:
|
| 576 |
timer.mark("first_step")
|
| 577 |
timer.mark("last_step") # overwritten each step; final value = end of last step
|
| 578 |
+
delta_ms = (now - (step_times[-2] if len(step_times) > 1 else t0)) * 1000
|
| 579 |
+
tag = " ← includes cold-start (offload hook install + first weight transfer)" if step_idx == 0 else ""
|
| 580 |
+
print(f"[infer] step {step_idx+1}/{steps} done — {delta_ms:.0f}ms{tag} | t={now-t0:.1f}s")
|
| 581 |
# Text encoder is done after prompt encoding, before the denoising loop starts.
|
| 582 |
# Dropping it (~15GB) ahead of VAE decode's fp32-upcast memory spike only pays off
|
| 583 |
# when that spike is big enough to need the headroom (see Mode.offloads_text_encoder_before_decode).
|
|
|
|
| 599 |
if step_idx == steps - 1 and cuda_ok:
|
| 600 |
print(f"[infer] pre-VAE-decode — {_gpu_mem_str(True, sync=True)} | t={time.perf_counter()-t0:.1f}s")
|
| 601 |
torch.cuda.reset_peak_memory_stats()
|
|
|
|
|
|
|
|
|
|
| 602 |
return cb_kwargs
|
| 603 |
return _step_cb
|
| 604 |
|