max seq length
This commit is contained in:
parent
7a6b9b8459
commit
9d94c475ad
2 changed files with 22 additions and 3 deletions
|
|
@ -1952,13 +1952,13 @@ class FastLlamaModel:
|
|||
Trainer._inner_training_loop = _fast_inner_training_loop
|
||||
|
||||
# Save max_seq_length
|
||||
model.max_seq_length = max_position_embeddings
|
||||
model.max_seq_length = max_seq_length
|
||||
internal_model = model
|
||||
while hasattr(internal_model, "model"):
|
||||
internal_model.max_seq_length = max_position_embeddings
|
||||
internal_model.max_seq_length = max_seq_length
|
||||
internal_model = internal_model.model
|
||||
pass
|
||||
internal_model.max_seq_length = max_position_embeddings
|
||||
internal_model.max_seq_length = max_seq_length
|
||||
|
||||
# We check the tokenizer first for errors
|
||||
if fix_tokenizer:
|
||||
|
|
|
|||
|
|
@ -287,6 +287,25 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):
|
|||
extra_args += saving_check
|
||||
pass
|
||||
|
||||
# Edit dataset_num_proc
|
||||
if "dataset_num_proc" in call_args:
|
||||
num_proc_check = \
|
||||
"if dataset_num_proc is None:\n"\
|
||||
" from multiprocessing import cpu_count\n"\
|
||||
" dataset_num_proc = cpu_count()\n"
|
||||
extra_args += num_proc_check
|
||||
pass
|
||||
|
||||
# Check max_seq_length
|
||||
if "max_seq_length" in call_args:
|
||||
length_check = \
|
||||
"if hasattr(model, 'max_seq_length') and model.max_seq_length > max_seq_length:\n"\
|
||||
" print('Unsloth: You set `max_seq_length` as ' + str(max_seq_length) + ' but the\\n'"\
|
||||
" 'model maximum sequence length is ' + str(model.max_seq_length) + '. We will reduce it.')\n"
|
||||
" max_seq_length = model.max_seq_length\n"
|
||||
extra_args += length_check
|
||||
pass
|
||||
|
||||
# Create RLConfig args
|
||||
extra_args = extra_args.split("\n")
|
||||
extra_args = "\n".join(" "*8 + x for x in extra_args)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue