sayakpaul / diffusers-torchao

End-to-end recipes for optimizing diffusion models with torchao and diffusers (inference and FP8 training).
Apache License 2.0
271 stars 8 forks source link

Attribute "weight" already exists #25

Closed nachoal closed 1 month ago

nachoal commented 2 months ago

Hi @sayakpaul, while reproducing your example I got the following error

Error Type: KeyError
Error Message: "attribute 'weight' already exists"

Traceback (most recent call last):
  File "/handler.py", line 347, in handler
    out = timed_execution("generate_images", generate_images, pipe, job_input)
  File "/handler.py", line 326, in timed_execution
    result = func(*args, **kwargs)
  File "/handler.py", line 211, in generate_images
    out = pipe(
  File "/usr/local/lib/python3.10/dist-packages/diffusers/pipelines/flux/pipeline_flux.py", line 696, in __call__
    noise_pred = self.transformer(
  File "/usr/local/lib/python3.10/dist-packages/torchao/quantization/autoquant.py", line 652, in autoquant_prehook
    module.finalize_autoquant()
  File "/usr/local/lib/python3.10/dist-packages/torchao/quantization/autoquant.py", line 664, in finalize_autoquant
    _change_autoquantizable_to_quantized(
  File "/usr/local/lib/python3.10/dist-packages/torchao/quantization/quant_api.py", line 251, in insert_subclass
    lin.weight = torch.nn.Parameter(
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1746, in __setattr__
    self.register_parameter(name, value)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 553, in register_parameter
    raise KeyError(f"attribute '{name}' already exists")
KeyError: "attribute 'weight' already exists"

Have you seen this one before?

sayakpaul commented 2 months ago

You haven't provided any details (environment, versions, command used to launch benchmarks).

But no, I never experienced the error.

trikim commented 2 months ago

Hi @sayakpaul, while reproducing your example I got the following error

Error Type: KeyError
Error Message: "attribute 'weight' already exists"

Traceback (most recent call last):
  File "/handler.py", line 347, in handler
    out = timed_execution("generate_images", generate_images, pipe, job_input)
  File "/handler.py", line 326, in timed_execution
    result = func(*args, **kwargs)
  File "/handler.py", line 211, in generate_images
    out = pipe(
  File "/usr/local/lib/python3.10/dist-packages/diffusers/pipelines/flux/pipeline_flux.py", line 696, in __call__
    noise_pred = self.transformer(
  File "/usr/local/lib/python3.10/dist-packages/torchao/quantization/autoquant.py", line 652, in autoquant_prehook
    module.finalize_autoquant()
  File "/usr/local/lib/python3.10/dist-packages/torchao/quantization/autoquant.py", line 664, in finalize_autoquant
    _change_autoquantizable_to_quantized(
  File "/usr/local/lib/python3.10/dist-packages/torchao/quantization/quant_api.py", line 251, in insert_subclass
    lin.weight = torch.nn.Parameter(
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1746, in __setattr__
    self.register_parameter(name, value)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 553, in register_parameter
    raise KeyError(f"attribute '{name}' already exists")
KeyError: "attribute 'weight' already exists"

Have you seen this one before?

same error, have you fixed the error?

sayakpaul commented 2 months ago

Code, environment, command.

sayakpaul commented 1 month ago

Closing due to inactivity.