Skip to content

Conversation

@tenderness-git
Copy link
Member

No description provided.

@tenderness-git tenderness-git requested a review from Copilot May 23, 2025 03:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses dtype-related issues and optimizes device memory management by updating model initialization and data transfers across multiple modules. Key changes include:

  • Addition of a dtype parameter when instantiating FluxImagePipeline objects in tools modules.
  • Replacement of torch.cuda.empty_cache() with a unified empty_cache() utility for cross-platform cache clearing.
  • Updates to model and tensor device conversion in pipelines and VAE modules to ensure proper dtype propagation.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
diffsynth_engine/utils/platform.py Introduces a new cross-platform cache clearing utility.
diffsynth_engine/tools/flux_replace_tool.py Updates FluxImagePipeline initialization by adding a dtype parameter.
diffsynth_engine/tools/flux_reference_tool.py Similar update as flux_replace_tool to include dtype in model instantiation.
diffsynth_engine/tools/flux_outpainting_tool.py Modifies pipeline initialization by adding dtype support.
diffsynth_engine/tools/flux_inpainting_tool.py Adjusts pipeline initialization to pass dtype correctly.
diffsynth_engine/pipelines/flux_image.py Improves device model management and cache clearing during noise prediction and latent preparation.
diffsynth_engine/pipelines/base.py Refactors device transfers to utilize empty_cache() and updates tensor conversions using model dtype.
diffsynth_engine/models/vae/vae.py Stores device and dtype on the VAE models to standardize downstream tensor conversions.
diffsynth_engine/models/utils.py Minor cleanup of code comments.

return noise

def encode_image(self, image: torch.Tensor) -> torch.Tensor:
image = image.to(self.device, self.vae_encoder.dtype)
Copy link

Copilot AI May 23, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider using keyword arguments for the to() method (e.g., image.to(device=self.device, dtype=self.vae_encoder.dtype)) to improve code clarity.

Suggested change
image = image.to(self.device, self.vae_encoder.dtype)
image = image.to(device=self.device, dtype=self.vae_encoder.dtype)

Copilot uses AI. Check for mistakes.
@sir1st-inc sir1st-inc self-assigned this May 23, 2025
@tenderness-git tenderness-git enabled auto-merge (squash) May 23, 2025 03:23
@sir1st-inc sir1st-inc self-requested a review May 23, 2025 03:24
@tenderness-git tenderness-git merged commit f3cf5ff into main May 23, 2025
@tenderness-git tenderness-git deleted the dev branch May 23, 2025 03:24
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