Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions swift/model/models/qwen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,13 @@ def _check_qwen_vl_utils(self):
require_version('qwen_vl_utils>=0.0.14')
compat_qwen_vl_utils(image_patch_size=16)

def get_config(self, model_dir: str):
# torch SDPA on MPS currently mis-handles Qwen3-VL GQA during generation.
if self.attn_impl is None and self.model_kwargs.get('device_map') == 'mps':
self.attn_impl = 'eager'
logger.info('Setting attn_impl=eager for Qwen3-VL on MPS.')
return super().get_config(model_dir)

def get_model(self, model_dir: str, config, processor, model_kwargs) -> PreTrainedModel:
from transformers import Qwen3VLForConditionalGeneration
self.auto_model_cls = self.auto_model_cls or Qwen3VLForConditionalGeneration
Expand Down
2 changes: 2 additions & 0 deletions swift/model/models/stepfun.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def get_model(self, model_dir: str, *args, **kwargs) -> PreTrainedModel:
class Step3VLLoader(ModelLoader):

def get_config(self, model_dir: str) -> PretrainedConfig:
if self.attn_impl is None and self.model_kwargs.get('device_map') == 'mps':
self.attn_impl = 'eager'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To maintain consistency with Qwen3VLLoader and improve debugging, it's recommended to add a log message when attn_impl is automatically set to 'eager' for Step3VLLoader on MPS. This provides valuable information to the user about the runtime configuration.

Suggested change
self.attn_impl = 'eager'
self.attn_impl = 'eager'
logger.info('Setting attn_impl=eager for Step3-VL on MPS.')

config = super().get_config(model_dir)
config.vocab_size = config.text_config.vocab_size
return config
Expand Down