Skip to content
Merged
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
19 changes: 14 additions & 5 deletions verl/workers/config/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ class HFModelConfig(BaseConfig):
"tokenizer",
"processor",
"local_path",
"local_hf_config_path",
"local_tokenizer_path",
}

path: str = MISSING
local_path: Optional[str] = None
hf_config_path: Optional[str] = None
local_hf_config_path: Optional[str] = None
tokenizer_path: Optional[str] = None
local_tokenizer_path: Optional[str] = None

hf_config: Any = None
generation_config: Any = None
Expand Down Expand Up @@ -82,17 +86,22 @@ def __post_init__(self):
if self.tokenizer_path is None:
self.tokenizer_path = self.path

# constuct tokenizer
self.local_path = copy_to_local(self.path, use_shm=self.use_shm)
self.tokenizer = hf_tokenizer(self.local_path, trust_remote_code=self.trust_remote_code)
self.processor = hf_processor(self.local_path, trust_remote_code=self.trust_remote_code)

self.generation_config = get_generation_config(self.hf_config_path, trust_remote_code=self.trust_remote_code)
# constuct tokenizer
self.local_tokenizer_path = copy_to_local(self.tokenizer_path, use_shm=self.use_shm)
self.tokenizer = hf_tokenizer(self.local_tokenizer_path, trust_remote_code=self.trust_remote_code)
self.processor = hf_processor(self.local_tokenizer_path, trust_remote_code=self.trust_remote_code)

self.local_hf_config_path = copy_to_local(self.hf_config_path, use_shm=self.use_shm)
self.generation_config = get_generation_config(
self.local_hf_config_path, trust_remote_code=self.trust_remote_code
)

# constuct hf_config
attn_implementation = self.override_config.get("attn_implementation", "flash_attention_2")
self.hf_config = AutoConfig.from_pretrained(
self.hf_config_path, trust_remote_code=self.trust_remote_code, attn_implementation=attn_implementation
self.local_hf_config_path, trust_remote_code=self.trust_remote_code, attn_implementation=attn_implementation
)

override_config_kwargs = {
Expand Down
Loading