Skip to content

Commit 883aece

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 02af48a commit 883aece

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
@@ -1115,11 +1115,12 @@ class StableDiffusionGGML {
11151115
}
11161116
struct ggml_tensor* denoised = ggml_dup_tensor(work_ctx, x);
11171117

1118+
int64_t t0 = ggml_time_us();
1119+
11181120
auto denoise = [&](ggml_tensor* input, float sigma, int step) -> ggml_tensor* {
1119-
if (step == 1) {
1121+
if (step == 1 || step == -1) {
11201122
pretty_progress(0, (int)steps, 0);
11211123
}
1122-
int64_t t0 = ggml_time_us();
11231124

11241125
std::vector<float> scaling = denoiser->get_scalings(sigma);
11251126
GGML_ASSERT(scaling.size() == 3);
@@ -1273,8 +1274,9 @@ class StableDiffusionGGML {
12731274
}
12741275

12751276
int64_t t1 = ggml_time_us();
1276-
if (step > 0) {
1277-
pretty_progress(step, (int)steps, (t1 - t0) / 1000000.f);
1277+
if (step != 0) {
1278+
int showstep = std::abs(step);
1279+
pretty_progress(showstep, (int)steps, (t1 - t0) / 1000000.f / showstep);
12781280
// LOG_INFO("step %d sampling completed taking %.2fs", step, (t1 - t0) * 1.0f / 1000000);
12791281
}
12801282
if (denoise_mask != nullptr) {

0 commit comments

Comments
 (0)