Skip to content

Commit 879bbc1

Browse files
committed
fix: better progress display for second-order samplers
Second-order samplers call the model twice per step, except for the last iteration. Since the progress is updated only for each second call, the last step is never shown. The timing information is also misleading, since it's displaying the number of full steps, but measuring only the last half. Comparing to a first-order sampler, the progress shows the same timing for each iteration, and the same number of steps, but takes almost twice as long. So, change the display to show average time per step, which should give a better idea of the expected time until completion, and update the progress display after all model calls.
1 parent 1c32fa0 commit 879bbc1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

stable-diffusion.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,11 +1130,12 @@ class StableDiffusionGGML {
11301130
}
11311131
struct ggml_tensor* denoised = ggml_dup_tensor(work_ctx, x);
11321132

1133+
int64_t t0 = ggml_time_us();
1134+
11331135
auto denoise = [&](ggml_tensor* input, float sigma, int step) -> ggml_tensor* {
1134-
if (step == 1) {
1136+
if (step == 1 || step == -1) {
11351137
pretty_progress(0, (int)steps, 0);
11361138
}
1137-
int64_t t0 = ggml_time_us();
11381139

11391140
std::vector<float> scaling = denoiser->get_scalings(sigma);
11401141
GGML_ASSERT(scaling.size() == 3);
@@ -1288,8 +1289,9 @@ class StableDiffusionGGML {
12881289
}
12891290

12901291
int64_t t1 = ggml_time_us();
1291-
if (step > 0) {
1292-
pretty_progress(step, (int)steps, (t1 - t0) / 1000000.f);
1292+
if (step != 0) {
1293+
int showstep = std::abs(step);
1294+
pretty_progress(showstep, (int)steps, (t1 - t0) / 1000000.f / showstep);
12931295
// LOG_INFO("step %d sampling completed taking %.2fs", step, (t1 - t0) * 1.0f / 1000000);
12941296
}
12951297
if (denoise_mask != nullptr) {

0 commit comments

Comments
 (0)