Support MOSS-VL - #9944
Conversation
| def is_vit_aligner_param(model_arch, parameter_name: str) -> bool: | ||
| for module_prefix in model_arch.vision_tower + model_arch.aligner: | ||
| if f'.{module_prefix}.' in parameter_name: | ||
| if (parameter_name == module_prefix or parameter_name.endswith(f'.{module_prefix}') |
There was a problem hiding this comment.
- parameter_name == module_prefix 是否有意义呢 2. --freeze_aligner false 及 --tuner_type lora_llm 是否会运行报错需要测试下
| else: | ||
| # only ulysses | ||
| position_ids = kwargs.pop('position_ids') | ||
| position_ids = kwargs.pop('position_ids', None) |
There was a problem hiding this comment.
请确认这里对其他模型的开启padding-free/packing时候的影响
| dist_attn, **kwargs): | ||
| # Bypass SP logic when world_size == 1 (SP disabled) or module not in text_model | ||
| if self.world_size == 1 or module.__class__ not in [m.__class__ for m in text_model.modules()]: | ||
| if (self.world_size == 1 or module in self.local_attention_modules |
There was a problem hiding this comment.
if (
self.world_size == 1
or getattr(module, '_sp_local_attention', False)
or module.class not in [m.class for m in text_model.modules()]
)
是否这么处理更合适
| value_states, attention_mask, *args, | ||
| **kwargs) | ||
| dist_attn, origin_attn, **kwargs): | ||
| if (self.world_size == 1 or module in self.local_attention_modules |
There was a problem hiding this comment.
if (
self.world_size == 1
or getattr(module, '_sp_local_attention', False)
or module.class not in [m.class for m in text_model.modules()]
)
是否这么处理更合适
PR #9944 更新说明一、关于本次 push:SP 支持撤出本 PR本次更新将 sequence parallel 支持整体撤出本 PR,改动范围严格限定为:
SP 支持后续将整理为独立 PR 提交。 撤回后本 PR 的范围:模型/模板接入 + 两个 MOSS-VL 必需的通用小修复( 二、回复 tastelikefeet 的 review(
|
PR type
PR information
Add MOSS-VL (8B,
model_type=moss_vl) as a first-class multimodal model for the Transformers backend. The model ships as remote code (48-layer LLM with vision cross-attention every 4 layers, 27-layer ViT with deep-stack features, merger, and a barenn.Parameterseparator token); this PR integrates it without copying the model implementation.Supported
swift infer(image/video) andswift sft: LoRA (target_modules=all-linear) and full-parameterfreeze_vit/freeze_aligner/freeze_llmon the real module boundaries; LoRA target scanning skips the bareseparator_token, LoRA-LLM saves it by exact name--sequence_parallel_size 2/4/8) with SDPA / FlashAttention-2 / FlashAttention-3, includingDP × SP. Cross-attention modules keep full-sequence vision K/V and bypass the all-to-all (marked_sp_local_attentionby the model loader); the text-axis masks (cross_attention_mask,full_text_row_masked_out_mask) are padded/split by a loader-registered pre-hook — no model-specific names in generic SP codelabels_spans(binary strategies only; non-binary loss-scale raises explicitly)MaxLengthErrorNon-goals for this PR:
packing=true/ padding-free, Megatron/TP/PP/CP, RLHF, vLLM/lmdeploy/SGLang, quantization, streaming video.Generic changes, and why each is required by this model
All are behavior-preserving for existing models and carry regression tests.
find_all_linearsskips non-Module paths when scanning LoRA targets: MOSS-VL'sseparator_tokenis a barenn.Parameter(not annn.Module); the previous scan crashed on it, blockingtarget_modules=all-linear.lora_llmmatches aligner parameters by exact name: required to save the trainable bareseparator_tokenin LoRA-LLM checkpoints — prefix-based matching never hits leaf parameters.padding_free=false, SDPA/FA2/FA3): explicit error oneager(previously silently wrong); FA3 registered into the SP-aware mask functions (the missing registration left the mask at local length after the all-to-all and zeroed attention outputs on later ranks at SP≥4); 2D attention masks padded before split (MOSS-VL passes 2D masks through the SP hook).Tests: 22 lightweight tests (no 8B weight download): registration, template/processor golden alignment, collator padding, mixed-media batches, truncation contract, LoRA scanning, SP mask split/localization.
pre-commit run --all-filespasses.Requires:
transformers>=4.57.1,<5,torchcodec(0.7.x for torch 2.8),joblib;flash-attnfor the SP example.Experiment results
OpenMOSS-Team/MOSS-VL-Instruct-0708,lmms-lab/VideoChatGPT)