Skip to content

AttributeError in diffusers.models.transformers.transformer_flux - Missing rope Attribute #9267

Description

@rajveer43

Describe the bug

I encountered an issue while working with the diffusers library where an AttributeError is raised because the transformer_flux module does not have an attribute named rope. This problem arises when trying to modify the rope function to handle CUDA devices.

Reproduction

Below is a code snippet that leads to this error:

importtorchfromdiffusersimportFluxPipelineimportdiffusersfromPILimportImageimportmatplotlib.pyplotasplt# Attempt to modify the rope function to handle CUDA device_flux_rope=diffusers.models.transformers.transformer_flux.ropedefnew_flux_rope(pos: torch.Tensor, dim: int, theta: int) ->torch.Tensor:
assertdim%2==0, "The dimension must be even."ifpos.device.type=="cuda":
# Move tensor to CPU for ROPE computation, then move it back to CUDAreturn_flux_rope(pos.to("cpu"), dim, theta).to(device=pos.device)
else:
# Perform ROPE computation directly if tensor is not on CUDAreturn_flux_rope(pos, dim, theta)
# Replace the original rope function with the new onediffusers.models.transformers.transformer_flux.rope=new_flux_rope

The rope function should be accessible in the transformer_flux module to allow customization, such as handling CUDA devices or modifying ROPE computations.

Logs

---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-17-f5d61243cd5c>in<cell line: 8>()
6 7 # Modify the rope function to handle the CPU device only
----> 8 _flux_rope = diffusers.models.transformers.transformer_flux.rope
9 def new_flux_rope(pos: torch.Tensor, dim: int, theta: int) -> torch.Tensor:
10 assert dim % 2 == 0, "The dimension must be even."
AttributeError: module 'diffusers.models.transformers.transformer_flux' has no attribute 'rope'

System Info

0.31.0.dev0(diffuser version)
3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0](python iversion)

Who can help?

@sayakpaul@DN6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleIssues that haven't received updates

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions