Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sdxl mlperf time bug #1580

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ def __call__(

throughput_warmup_steps = kwargs.get("throughput_warmup_steps", 3)
use_warmup_inference_steps = (
num_batches < throughput_warmup_steps and num_inference_steps > throughput_warmup_steps
num_batches <= throughput_warmup_steps and num_inference_steps > throughput_warmup_steps
)

self._num_timesteps = len(timesteps)
Expand All @@ -769,9 +769,6 @@ def __call__(
if j == throughput_warmup_steps:
ht.hpu.synchronize()
t1 = time.time()
if use_warmup_inference_steps:
ht.hpu.synchronize()
t0_inf = time.time()

latents = latents_batches[0]
latents_batches = torch.roll(latents_batches, shifts=-1, dims=0)
Expand Down Expand Up @@ -841,10 +838,9 @@ def __call__(
hb_profiler.step()
else:
for i in range(num_inference_steps):
if use_warmup_inference_steps and i == throughput_warmup_steps:
if use_warmup_inference_steps and i == throughput_warmup_steps and j == num_batches - 1:
ht.hpu.synchronize()
t1_inf = time.time()
t1 += t1_inf - t0_inf
t1 = time.time()

t = timesteps[0]
timesteps = torch.roll(timesteps, shifts=-1, dims=0)
Expand Down Expand Up @@ -875,10 +871,6 @@ def __call__(
callback_on_step_end_tensor_inputs,
)
hb_profiler.step()
if use_warmup_inference_steps:
ht.hpu.synchronize()
t1 = warmup_inference_steps_time_adjustment(t1, t1_inf, num_inference_steps, throughput_warmup_steps)

if not output_type == "latent":
# make sure the VAE is in float32 mode, as it overflows in float16
needs_upcasting = self.vae.dtype == torch.float16 and self.vae.config.force_upcast
Expand All @@ -897,18 +889,20 @@ def __call__(

output_images.append(image)


hb_profiler.stop()

speed_metrics_prefix = "generation"
ht.hpu.synchronize()

if use_warmup_inference_steps:
ht.hpu.synchronize()
t1 = warmup_inference_steps_time_adjustment(t1, t1, num_inference_steps, throughput_warmup_steps)
if t1 == t0 or use_warmup_inference_steps:
num_samples = num_batches * batch_size
num_steps = (num_inference_steps - throughput_warmup_steps) * num_batches * batch_size
num_samples = batch_size
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could still be more than 1 batch no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we just calculate the latest batch time in use_warmup_inference_steps case(add and j == num_batches - 1 in line 841), so the num_samples is batch_size

num_steps = batch_size * num_inference_steps
else:
num_samples = (num_batches - throughput_warmup_steps) * batch_size
num_steps = (num_batches - throughput_warmup_steps) * num_inference_steps * batch_size

speed_measures = speed_metrics(
split=speed_metrics_prefix,
start_time=t0,
Expand Down