Skip to content

[fix bug] PixArt inference_steps=1 - #11079

Merged
hlky merged 3 commits into
huggingface:mainfrom
lawrence-cj:main
Mar 20, 2025
Merged

hlky merged 3 commits into
huggingface:mainfrom
lawrence-cj:main

Conversation

@lawrence-cj

Copy link
Copy Markdown
Contributor

This PR fix the bug when PixArt inference with num_inference_steps=1

@hlky

hlky commented Mar 17, 2025

Copy link
Copy Markdown
Contributor

@bot /style

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@hlky

hlky commented Mar 17, 2025

Copy link
Copy Markdown
Contributor

@bot /style

try:
# For LCM one step sampling
latents = self.scheduler.step(noise_pred, t, latents, **extra_step_kwargs).denoised
except:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
except:
except Exception:

At minimum due to ruff. What's the exception type raised here? Is there anything else we can check instead of relying on try/except?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This one is due to the Output difference between

prev_sample: torch.Tensor
denoised: Optional[torch.Tensor] = None

and
prev_sample: torch.Tensor
pred_original_sample: Optional[torch.Tensor] = None

What do you think is better to write here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

gentle ping @hlky

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With return_dict=False a tuple is returned, both denoised and pred_original_sample are at index 1 so we can do

latents = self.scheduler.step(noise_pred, t, latents, **extra_step_kwargs, return_dict=False)[1]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. updated.

@lawrence-cj
lawrence-cj requested a review from hlky March 20, 2025 07:03

@hlky hlky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @lawrence-cj

@hlky

hlky commented Mar 20, 2025

Copy link
Copy Markdown
Contributor

Failing tests are unrelated.

@hlky
hlky merged commit dc62e69 into huggingface:main Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants