Skip to content
Closed
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
2 changes: 0 additions & 2 deletions configs/ci/nightly/multimodal_color_codeword.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ num_infer_gpus = 4
name = "Qwen/Qwen3.5-4B"

[model.vlm]
vision_encoder_attr = "model.visual"
language_model_attr = "model.language_model"

[orchestrator]
batch_size = 256
Expand Down
14 changes: 6 additions & 8 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,12 @@ The experimental `shard_fused_on_dim1 = true` shards fused 2-D weights along dim

The built-in VLM registry covers:

| Family | `model_type` | Vision attr | LM attr |
|---|---|---|---|
| Qwen3.5 | `qwen3_5` | `model.visual` | `model.language_model` |
| Qwen3.5-MoE | `qwen3_5_moe` | `model.visual` | `model.language_model` |
| Family | `model_type` |
|---|---|
| Qwen3.5 | `qwen3_5` |
| Qwen3.5-MoE | `qwen3_5_moe` |

The trainer finds the vision encoder at `model.visual` and the language model at `model.language_model`.

### Enabling VLM Mode

Expand All @@ -158,13 +160,9 @@ optimization_dtype = "bfloat16"
reduce_dtype = "bfloat16"

[model.vlm]
vision_encoder_attr = "model.visual"
language_model_attr = "model.language_model"
# freeze_vision_encoder = true # default; set false to fine-tune the encoder
```

The weight-broadcast key prefix is derived as `{language_model_attr}.layers.` automatically.

VLM training requires a registered custom PrimeRL implementation.

### Limitations
Expand Down
2 changes: 0 additions & 2 deletions examples/extra/vlm/sft-moe.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ ep = 8 # keep in sync with deployment.num_train_gpus
name = "auto"

[model.vlm]
vision_encoder_attr = "model.visual"
language_model_attr = "model.language_model"
freeze_vision_encoder = true

[model.lora]
Expand Down
2 changes: 0 additions & 2 deletions examples/extra/vlm/sft.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ reduce_dtype = "bfloat16"
name = "auto"

[model.vlm]
vision_encoder_attr = "model.visual"
language_model_attr = "model.language_model"
freeze_vision_encoder = true

[model.lora]
Expand Down
9 changes: 0 additions & 9 deletions packages/prime-rl-configs/src/prime_rl/configs/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,6 @@ def resolve_project_dir(self):


class VLMConfig(BaseConfig):
vision_encoder_attr: str
"""Dotted attribute path to the vision encoder module (e.g. ``model.visual``)."""

language_model_attr: str
"""Dotted attribute path to the language model module (e.g. ``model.language_model``)."""

freeze_vision_encoder: bool = True
"""Freeze the vision encoder parameters during training."""

Expand All @@ -200,9 +194,6 @@ class BaseModelConfig(BaseConfig):
trust_remote_code: bool = False
"""Trust remote code when initializing the tokenizer."""

vlm: "VLMConfig | None" = None
"""VLM configuration. Setting this enables vision-language model support."""


class DynamoConfig(BaseConfig):
enabled: bool = True
Expand Down
4 changes: 4 additions & 0 deletions packages/prime-rl-configs/src/prime_rl/configs/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
ResumeConfig,
TrainerLogConfig,
TransportConfig,
VLMConfig,
WeightBroadcastConfig,
ZMQTransportConfig,
)
Expand Down Expand Up @@ -267,6 +268,9 @@ class MoERuntimeConfig(BaseConfig):


class ModelConfig(BaseModelConfig):
vlm: VLMConfig | None = None
"""VLM configuration. Setting this enables vision-language model support."""

conversion_dir: Path | None = None
"""Directory for the auto-converted weights (written to a `prime`/`hf` subdirectory). If not set, we write into the model snapshot directory."""

Expand Down
6 changes: 1 addition & 5 deletions packages/prime-rl-configs/src/prime_rl/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ def propagate(shared_path: str, *targets: str) -> None:
"inference.vllm.model",
"orchestrator.model.name",
)
propagate(
"model.vlm",
"trainer.model.vlm",
"orchestrator.model.vlm",
)
propagate("model.vlm", "trainer.model.vlm")

# [log]
propagate("log.level", "trainer.log.level", "orchestrator.log.level", "inference.log.level")
Expand Down
35 changes: 1 addition & 34 deletions tests/unit/test_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,46 +590,13 @@ def test_multi_node_auto_inference_parallelism():
assert config.inference.vllm.data_parallel_size == 2


def test_orchestrator_vlm_requires_renderer():
with pytest.raises(ValidationError, match="renderer"):
OrchestratorConfig.model_validate(
{
"model": {
"name": "Qwen/Qwen3-VL-4B-Instruct",
"vlm": {
"vision_encoder_attr": "model.visual",
"language_model_attr": "model.language_model",
},
},
"renderer": None,
}
)

config = OrchestratorConfig.model_validate(
{
"model": {
"name": "Qwen/Qwen3-VL-4B-Instruct",
"vlm": {
"vision_encoder_attr": "model.visual",
"language_model_attr": "model.language_model",
},
},
}
)

assert config.renderer is not None


def test_trainer_rejects_vlm_cp_with_ring():
config = {
"model": {
"cp": 2,
"optimization_dtype": "bfloat16",
"reduce_dtype": "bfloat16",
"vlm": {
"vision_encoder_attr": "model.visual",
"language_model_attr": "model.language_model",
},
"vlm": {},
},
}

Expand Down
Loading