Skip to content

Conversation

@KaparthyReddy
Copy link

Summary

This PR fixes the _init_weights() method in Qwen2_5_VLForConditionalGeneration to safely skip int8 tensors during initialization. Previously, applying normal_() on int8 weights caused a RuntimeError when loading quantized models.

Changes

  • Added dtype check in _init_weights() to only initialize floating-point tensors (float16, float32, bfloat16).
  • Ensures int8 weights from quantized models are skipped safely.
  • Verified fix by successfully loading a quantized Qwen2.5-VL model on CPU.

Motivation

Quantized models (W8A8, int8 weights) could not be loaded directly due to the previous _init_weights() implementation. This fix allows smooth loading without RuntimeError, making contributions compatible with LLMCompressor quantized models.

Verification

  • Model loaded successfully on CPU after applying the fix.
  • _init_weights() safely ignores int8 tensors.

@Rocketknight1
Copy link
Member

cc @MekkCyber for quantization!

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.

Thanks @KaparthyReddy ! I think this the wrong commit

@KaparthyReddy
Copy link
Author

Thanks for the feedback! I’ve updated the PR to modify the correct file under src/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py. _init_weights now safely skips int8 tensors while initializing float tensors correctly.

@github-actions
Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: qwen2_5_vl

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

Hey sorry we merged a big refacto in #41580 !

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.

4 participants