Skip to content

Commit 4091e44

Browse files
committed
Ensure we still accept None as value
1 parent 6c40f77 commit 4091e44

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

tests/workers/config/test_model_config_on_cpu.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ def test_target_modules_accepts_list_via_omegaconf(self):
5252
# Verify the list was merged correctly
5353
assert list(merged.target_modules) == ["k_proj", "o_proj", "q_proj", "v_proj"]
5454

55+
def test_target_modules_accepts_none_via_omegaconf(self):
56+
"""Test that target_modules still accepts None values."""
57+
58+
cfg_from_dataclass = OmegaConf.structured(HFModelConfig)
59+
60+
cli_config = OmegaConf.create(
61+
{
62+
"path": self.model_path,
63+
"target_modules": None,
64+
}
65+
)
66+
67+
merged = OmegaConf.merge(cfg_from_dataclass, cli_config)
68+
assert merged.target_modules is None
69+
5570
def test_target_modules_accepts_string_via_omegaconf(self):
5671
"""Test that target_modules still accepts string values."""
5772

verl/workers/config/model.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,19 @@ def __post_init__(self):
204204
if getattr(self.hf_config, "model_type", None) == "kimi_vl":
205205
self.hf_config.text_config.topk_method = "greedy"
206206

207-
# Ensure target_modules is a str or list[str]
208-
if self.target_modules is None:
209-
self.target_modules = "all-linear"
210-
if not isinstance(self.target_modules, (str, list)):
211-
raise TypeError(f"target_modules must be a string or a list of strings, but got {type(self.target_modules).__name__}")
212-
if isinstance(self.target_modules, list):
213-
for x in self.target_modules:
214-
if not isinstance(x, str):
215-
raise TypeError(f"All elements in target_modules list must be strings, but found {type(x).__name__}")
207+
# Ensure target_modules is a str or list[str] (only if not None)
208+
if self.target_modules is not None:
209+
if not isinstance(self.target_modules, (str | list)):
210+
raise TypeError(
211+
"target_modules must be a string or a list of strings, "
212+
f"but got {type(self.target_modules).__name__}"
213+
)
214+
if isinstance(self.target_modules, list):
215+
for x in self.target_modules:
216+
if not isinstance(x, str):
217+
raise TypeError(
218+
f"All elements in target_modules list must be strings, but found {type(x).__name__}"
219+
)
216220

217221
def get_processor(self):
218222
return self.processor if self.processor is not None else self.tokenizer

0 commit comments

Comments
 (0)