Skip to content

Conversation

@abrichr
Copy link
Member

@abrichr abrichr commented Jan 29, 2026

Summary

  • Fix _load_standard_model() to auto-detect vision-language models and use the correct model class
  • Previously, the function always used AutoModelForCausalLM, which fails for VL models like Qwen2-VL and Qwen2.5-VL
  • Now detects VL models via: model name containing "VL" or "vision", or config having vision_config attribute
  • Uses Qwen2VLForConditionalGeneration for Qwen VL models (with AutoModelForVision2Seq fallback)
  • Sets LoRA task_type to SEQ_2_SEQ_LM for VL models

Test plan

  • Added unit tests for VL model detection logic
  • Tests verify correct model class selection for both VL and text-only models
  • Manual testing with Qwen/Qwen2-VL-7B-Instruct recommended

🤖 Generated with Claude Code

abrichr and others added 3 commits January 29, 2026 15:17
Auto-detect vision-language models (Qwen2-VL, Qwen2.5-VL) and use the
appropriate model class instead of always using AutoModelForCausalLM.

Detection criteria:
- "VL" in model name (case-insensitive)
- "vision" in model name
- vision_config attribute in model config

Model class selection:
- VL models: Qwen2VLForConditionalGeneration (with AutoModelForVision2Seq fallback)
- Text-only models: AutoModelForCausalLM

Also sets task_type to SEQ_2_SEQ_LM for VL models in LoRA config.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… assistant_only_loss

- Add RuntimeError and TypeError to exception handling in _load_standard_model()
  to catch errors when loading Qwen2.5-VL with Qwen2VLForConditionalGeneration
- Disable assistant_only_loss in standard TRL config as it's not supported for
  VL models yet

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@abrichr abrichr merged commit 2b2c1df into main Jan 29, 2026
0 of 4 checks passed
abrichr added a commit that referenced this pull request Jan 29, 2026
Includes VL model support fix (PR #18):
- Auto-detect VL models and use correct model class
- Handle Qwen2VLForConditionalGeneration properly
- Set assistant_only_loss=False for VL models

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

2 participants