Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Failing AdaLoRA GPU test #2349

Merged
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
30 changes: 19 additions & 11 deletions tests/test_gpu_examples.py
Original file line number Diff line number Diff line change
@@ -370,9 +370,9 @@ def test_4bit_adalora_causalLM(self):
peft_config = AdaLoraConfig(
init_r=6,
target_r=4,
tinit=50,
tfinal=100,
total_step=200,
tinit=2,
tfinal=2,
total_step=6,
deltaT=5,
beta1=0.3,
beta2=0.3,
@@ -404,7 +404,7 @@ def on_optimizer_step(self, args, state, control, **kwargs):
per_device_train_batch_size=4,
gradient_accumulation_steps=4,
warmup_steps=2,
max_steps=3,
max_steps=6,
learning_rate=2e-4,
fp16=True,
logging_steps=1,
@@ -443,9 +443,9 @@ def test_8bit_adalora_causalLM(self):
peft_config = AdaLoraConfig(
init_r=6,
target_r=4,
tinit=50,
tfinal=100,
total_step=200,
tinit=2,
tfinal=2,
total_step=6,
deltaT=5,
beta1=0.3,
beta2=0.3,
@@ -477,7 +477,7 @@ def on_optimizer_step(self, args, state, control, **kwargs):
per_device_train_batch_size=4,
gradient_accumulation_steps=4,
warmup_steps=2,
max_steps=3,
max_steps=6,
learning_rate=2e-4,
fp16=True,
logging_steps=1,
@@ -1494,8 +1494,9 @@ def test_adalora_causalLM(self):
peft_config = AdaLoraConfig(
init_r=6,
target_r=4,
tinit=50,
tfinal=100,
tinit=2,
tfinal=2,
total_step=6,
deltaT=5,
beta1=0.3,
beta2=0.3,
@@ -1513,6 +1514,12 @@ def test_adalora_causalLM(self):
batch = tokenizer(data["train"][:3]["quote"], return_tensors="pt", padding=True)
self._check_inference_finite(model, batch)

class OptimizerStepCallback(TrainerCallback):
def on_optimizer_step(self, args, state, control, **kwargs):
model.update_and_allocate(state.global_step)

step_callback = OptimizerStepCallback()

with tempfile.TemporaryDirectory() as tmp_dir:
trainer = Trainer(
model=model,
@@ -1521,14 +1528,15 @@ def test_adalora_causalLM(self):
per_device_train_batch_size=4,
gradient_accumulation_steps=4,
warmup_steps=2,
max_steps=3,
max_steps=6,
learning_rate=2e-4,
fp16=True,
logging_steps=1,
output_dir=tmp_dir,
),
data_collator=DataCollatorForLanguageModeling(self.tokenizer, mlm=False),
)
trainer.add_callback(step_callback)
model.config.use_cache = False
trainer.train()