Skip to content

CI fails with dev dependencies: AttributeError: 'Qwen2_5_VLForConditionalGeneration' object has no attribute 'language_model' #4601

@albertvillanova

Description

@albertvillanova

CI fails with dev dependencies: https://github.com/huggingface/trl/actions/runs/19767041653/job/56642242755

AttributeError: 'Qwen2_5_VLForConditionalGeneration' object has no attribute 'language_model'

FAILED tests/test_grpo_trainer.py::TestGRPOTrainer::test_training_vlm_and_liger[trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration] - AttributeError: 'Qwen2_5_VLForConditionalGeneration' object has no attribute 'language_model'

Stacktrace:

   >       trainer = GRPOTrainer(
              model=model_id,
              reward_funcs=reward_func,
              args=training_args,
              train_dataset=dataset,
          )
  
  tests/test_grpo_trainer.py:1546: 
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  trl/trainer/grpo_trainer.py:445: in __init__
      super().__init__(
  .venv/lib/python3.12/site-packages/transformers/trainer.py:486: in __init__
      _apply_liger_kernel_to_instance(model=model, **kernel_config)
  .venv/lib/python3.12/site-packages/liger_kernel/transformers/monkey_patch.py:2851: in _apply_liger_kernel_to_instance
      apply_fn(model=model, **applicable_kwargs)
  .venv/lib/python3.12/site-packages/liger_kernel/transformers/monkey_patch.py:1619: in apply_liger_kernel_to_qwen2_5_vl
      text_model: Qwen2_5_VLTextModel = model.language_model
                                        ^^^^^^^^^^^^^^^^^^^^
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  
  self = Qwen2_5_VLForConditionalGeneration(
    (model): Qwen2_5_VLModel(
      (visual): Qwen2_5_VisionTransformerPretrainedModel...tary_emb): Qwen2_5_VLRotaryEmbedding()
      )
    )
    (lm_head): Linear(in_features=16, out_features=151936, bias=False)
  )
  name = 'language_model'
  
      def __getattr__(self, name: str) -> Union[Tensor, "Module"]:
          if "_parameters" in self.__dict__:
              _parameters = self.__dict__["_parameters"]
              if name in _parameters:
                  return _parameters[name]
          if "_buffers" in self.__dict__:
              _buffers = self.__dict__["_buffers"]
              if name in _buffers:
                  return _buffers[name]
          if "_modules" in self.__dict__:
              modules = self.__dict__["_modules"]
              if name in modules:
                  return modules[name]
  >       raise AttributeError(
              f"'{type(self).__name__}' object has no attribute '{name}'"
          )
  E       AttributeError: 'Qwen2_5_VLForConditionalGeneration' object has no attribute 'language_model'
  
  .venv/lib/python3.12/site-packages/torch/nn/modules/module.py:1964: AttributeError

Metadata

Metadata

Labels

🏋 GRPORelated to GRPO🐛 bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions