Spaces:
Runtime error
Runtime error
Update grpo_train.py
Browse files- grpo_train.py +7 -4
grpo_train.py
CHANGED
|
@@ -629,9 +629,8 @@ else:
|
|
| 629 |
_cc = (0, 0)
|
| 630 |
|
| 631 |
USE_4BIT = _vram < 40 * 1024**3
|
| 632 |
-
USE_BF16 = _cc >= (8, 0) and not USE_4BIT
|
| 633 |
|
| 634 |
-
TRAIN_DTYPE = torch.
|
| 635 |
|
| 636 |
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 637 |
model_name="unsloth/Llama-3.2-3B-Instruct",
|
|
@@ -654,6 +653,10 @@ model = FastLanguageModel.get_peft_model(
|
|
| 654 |
random_state=3407,
|
| 655 |
)
|
| 656 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 657 |
# =========================
|
| 658 |
# TRAINER
|
| 659 |
# =========================
|
|
@@ -674,8 +677,8 @@ trainer = GRPOTrainer(
|
|
| 674 |
max_completion_length=80,
|
| 675 |
logging_steps=5,
|
| 676 |
warmup_steps=10,
|
| 677 |
-
bf16=
|
| 678 |
-
fp16=
|
| 679 |
report_to="none",
|
| 680 |
),
|
| 681 |
train_dataset=dataset,
|
|
|
|
| 629 |
_cc = (0, 0)
|
| 630 |
|
| 631 |
USE_4BIT = _vram < 40 * 1024**3
|
|
|
|
| 632 |
|
| 633 |
+
TRAIN_DTYPE = torch.float16
|
| 634 |
|
| 635 |
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 636 |
model_name="unsloth/Llama-3.2-3B-Instruct",
|
|
|
|
| 653 |
random_state=3407,
|
| 654 |
)
|
| 655 |
|
| 656 |
+
for _p in model.parameters():
|
| 657 |
+
if _p.dtype in (torch.bfloat16, torch.float32):
|
| 658 |
+
_p.data = _p.data.to(TRAIN_DTYPE)
|
| 659 |
+
|
| 660 |
# =========================
|
| 661 |
# TRAINER
|
| 662 |
# =========================
|
|
|
|
| 677 |
max_completion_length=80,
|
| 678 |
logging_steps=5,
|
| 679 |
warmup_steps=10,
|
| 680 |
+
bf16=False,
|
| 681 |
+
fp16=True,
|
| 682 |
report_to="none",
|
| 683 |
),
|
| 684 |
train_dataset=dataset,
|