Skip to content

Conversation

@lawrence-cj
Copy link
Contributor

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

@hlky
Copy link
Contributor

hlky commented Mar 17, 2025

@bot /style

@HuggingFaceDocBuilderDev

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
Copy link
Contributor

hlky commented Mar 17, 2025

@bot /style

try:
# For LCM one step sampling
latents = self.scheduler.step(noise_pred, t, latents, **extra_step_kwargs).denoised
except:
Copy link
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
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
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
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
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
Copy link
Contributor

@hlky hlky left a comment

Choose a reason for hiding this comment

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

Thanks @lawrence-cj

@hlky
Copy link
Contributor

hlky commented Mar 20, 2025

Failing tests are unrelated.

@hlky hlky merged commit dc62e69 into huggingface:main Mar 20, 2025
10 of 12 checks passed
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