Skip to content

Qwen2.5-Omni: Update modeling_qwen2_5_omni.py to fix error when loading quantized weights with AutoAWQ. #37995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 0 commits into from

Conversation

tiger-of-shawn
Copy link

Qwen2.5-Omni: Update modeling_qwen2_5_omni.py to fix loading quantized weights with AutoAWQ.

What does this PR do?

while loading AWQ quantized Qwen-Omni model with AutoAWQ, there will be an error as below:

Traceback (most recent call last):
  File "/nas/yuehu/NEW/AutoAWQ/./examples/quantize_qwen_omni.py", line 188, in <module>
    inference_quantized_model(quant_path)
  File "/nas/yuehu/NEW/AutoAWQ/./examples/quantize_qwen_omni.py", line 123, in inference_quantized_model
    model = AutoAWQForCausalLM.from_quantized(quant_path)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nas/yuehu/NEW/AutoAWQ/awq/models/auto.py", line 125, in from_quantized
    return AWQ_CAUSAL_LM_MODEL_MAP[model_type].from_quantized(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nas/yuehu/NEW/AutoAWQ/awq/models/base.py", line 498, in from_quantized
    model = target_cls.from_config(
            ^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/models/auto/auto_factory.py", line 440, in from_config
    return model_class._from_config(config, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/modeling_utils.py", line 280, in _wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/modeling_utils.py", line 2023, in _from_config
    model = cls(config, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/models/qwen2_5_omni/modeling_qwen2_5_omni.py", line 4386, in __init__
    self.post_init()
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/modeling_utils.py", line 1886, in post_init
    self.init_weights()
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/modeling_utils.py", line 3149, in init_weights
    self.initialize_weights()
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/modeling_utils.py", line 2502, in initialize_weights
    self.smart_apply(self._initialize_weights)
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/modeling_utils.py", line 2493, in smart_apply
    module.smart_apply(module._initialize_weights)
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/modeling_utils.py", line 2493, in smart_apply
    module.smart_apply(module._initialize_weights)
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/modeling_utils.py", line 2495, in smart_apply
    module.smart_apply(fn)
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/modeling_utils.py", line 2495, in smart_apply
    module.smart_apply(fn)
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/modeling_utils.py", line 2495, in smart_apply
    module.smart_apply(fn)
  [Previous line repeated 1 more time]
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/modeling_utils.py", line 2496, in smart_apply
    fn(self)
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/modeling_utils.py", line 2470, in _initialize_weights
    self._init_weights(module)
  File "/root/anaconda3/envs/awq/lib/python3.12/site-packages/transformers/models/qwen2_5_omni/modeling_qwen2_5_omni.py", line 152, in _init_weights
    module.weight.data.fill_(1.0)
    ^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'data'

Fixes # (issue)

this PR can fix the above error.

Who can review?

@ArthurZucker @amyeroberts @qubvel

thanks for your reviewing.

@github-actions github-actions bot marked this pull request as draft May 7, 2025 09:47
Copy link

github-actions bot commented May 7, 2025

Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the Ready for review button (at the bottom of the PR page). This will assign reviewers and trigger CI.

@tiger-of-shawn tiger-of-shawn marked this pull request as ready for review May 7, 2025 09:48
@Rocketknight1
Copy link
Member

cc @MekkCyber for quantization!

@tiger-of-shawn
Copy link
Author

cc @MekkCyber for quantization!

Thanks to @MekkCyber , We have prepared a PR for AutoAWQ to enable support for Qwen2.5-Omni models, pending the approval and merging of this PR.

@tiger-of-shawn
Copy link
Author

cc @MekkCyber for quantization!

Thanks to @MekkCyber , We have prepared a PR for AutoAWQ to enable support for Qwen2.5-Omni models, pending the approval and merging of this PR.

could you please help to review this PR @Rocketknight1 ? there are only 4 lines changed, thank you very much.

@tiger-of-shawn tiger-of-shawn changed the title Qwen2.5-Omni: Update modeling_qwen2_5_omni.py to fix loading quantized weights with AutoAWQ. Qwen2.5-Omni: Update modeling_qwen2_5_omni.py to fix error when loading quantized weights with AutoAWQ. May 8, 2025
Copy link
Contributor

@MekkCyber MekkCyber left a comment

Choose a reason for hiding this comment

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

LGTM thanks for the fix ! can you fix the CI please

@tiger-of-shawn
Copy link
Author

LGTM thanks for the fix ! can you fix the CI please

Okay, I have create a new PR to fix CI error, please refer to #3801 , thanks for your time again.

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