File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 19
19
from typing import Any , Optional
20
20
21
21
from omegaconf import OmegaConf
22
- from transformers import PreTrainedTokenizerBase
22
+ from transformers import AutoModel , PreTrainedTokenizerBase
23
23
24
24
from nemo_rl .algorithms .grpo import MasterConfig , grpo_train , setup
25
25
from nemo_rl .algorithms .utils import get_tokenizer
@@ -159,7 +159,17 @@ def main() -> None:
159
159
160
160
init_ray ()
161
161
162
- # setup tokenizer
162
+ # setup tokenizer and preloading model to force HF to download the model and modules
163
+ # to avoid race condition inside generation/policy workers.
164
+ try :
165
+ _ = AutoModel .from_pretrained (
166
+ config ["policy" ]["model_name" ], trust_remote_code = True
167
+ )
168
+ print (f"Model preloaded successfully: { config ['policy' ]['model_name' ]} " )
169
+ except Exception as e :
170
+ print ("WARNIN: error in preloading model, in general it's not a problem: " )
171
+ print (e )
172
+
163
173
tokenizer = get_tokenizer (config ["policy" ]["tokenizer" ])
164
174
assert config ["policy" ]["generation" ] is not None , (
165
175
"A generation config is required for GRPO"
You can’t perform that action at this time.
0 commit comments