natmin322 commited on
Commit
d7fe0d8
·
1 Parent(s): fd8e73c

fix: replace deprecated torch.pinv with torch.linalg.pinv

Browse files
root_gainlora/runtest_colab.ipynb CHANGED
@@ -226,7 +226,7 @@
226
  },
227
  {
228
  "cell_type": "code",
229
- "execution_count": 8,
230
  "id": "6257b4db",
231
  "metadata": {},
232
  "outputs": [
@@ -234,7 +234,7 @@
234
  "name": "stdout",
235
  "output_type": "stream",
236
  "text": [
237
- "/content\n"
238
  ]
239
  }
240
  ],
@@ -304,32 +304,14 @@
304
  "name": "stdout",
305
  "output_type": "stream",
306
  "text": [
307
- "ing: False -----\n",
308
- "tmp\n",
309
- "Traceback (most recent call last):\n",
310
- " File \"/content/Continual/root_gainlora/src/run_t5.py\", line 923, in <module>\n",
311
- " main()\n",
312
- " File \"/content/Continual/root_gainlora/src/run_t5.py\", line 743, in main\n",
313
- " trainer.get_reg_matrix()\n",
314
- " File \"/content/Continual/root_gainlora/src/cl_trainer_gainlora_inflora.py\", line 143, in get_reg_matrix\n",
315
- " self.feature_list, self.feature_trans_list, self._cur_task = self.load_previous_reg_matrix()\n",
316
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
317
- " File \"/content/Continual/root_gainlora/src/cl_trainer_gainlora_inflora.py\", line 118, in load_previous_reg_matrix\n",
318
- " all_dirs = os.listdir(log_path)\n",
319
- " ^^^^^^^^^^^^^^^^^^^^\n",
320
- "FileNotFoundError: [Errno 2] No such file or directory: 'tmp'\n",
321
- "\n",
322
- "RC: 0\n"
323
  ]
324
  }
325
  ],
326
  "source": [
327
- "# Test with real output path and --max_steps 3\n",
328
- "import subprocess\n",
329
- "r = subprocess.run(['bash', '-c', '''\n",
330
- "cd /content/Continual/root_gainlora\n",
331
- "rm -rf /root/.cache/huggingface/modules/datasets_modules/ 2>/dev/null || true\n",
332
- "CUDA_VISIBLE_DEVICES=0 python src/run_t5.py \\\n",
333
  " --do_train --predict_with_generate --model_name_or_path google/flan-t5-large \\\n",
334
  " --data_dir CL_Benchmark \\\n",
335
  " --task_order yelp,amazon,mnli,cb,copa,qqp,rte,imdb,sst2,dbpedia,agnews,yahoo,multirc,boolq,wic \\\n",
@@ -343,10 +325,7 @@
343
  " --evaluation_strategy steps --save_strategy steps --save_total_limit 1 --load_best_model_at_end \\\n",
344
  " --lora_r 8 --lora_alpha 32 --lora_dropout 0.0 --add_instruction_replay --data_replay_freq -1 \\\n",
345
  " --replay_after_n_epoch 0 --mlp_hidden_dim 100 --model_name gainlora_inflora \\\n",
346
- " --threshold 0.995 --transthreshold 0.995 --max_steps 3 2>&1 | tail -15\n",
347
- "'''], capture_output=True, text=True, timeout=300, cwd='/content')\n",
348
- "print(r.stdout[-800:])\n",
349
- "print(\"RC:\", r.returncode)"
350
  ]
351
  }
352
  ],
 
226
  },
227
  {
228
  "cell_type": "code",
229
+ "execution_count": 13,
230
  "id": "6257b4db",
231
  "metadata": {},
232
  "outputs": [
 
234
  "name": "stdout",
235
  "output_type": "stream",
236
  "text": [
237
+ "/\n"
238
  ]
239
  }
240
  ],
 
304
  "name": "stdout",
305
  "output_type": "stream",
306
  "text": [
307
+ "/content/Continual/root_gainlora\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  ]
309
  }
310
  ],
311
  "source": [
312
+ "%cd /content/Continual/root_gainlora\n",
313
+ "!rm -rf /root/.cache/huggingface/modules/datasets_modules/ 2>/dev/null || true\n",
314
+ "!CUDA_VISIBLE_DEVICES=0 python src/run_t5.py \\\n",
 
 
 
315
  " --do_train --predict_with_generate --model_name_or_path google/flan-t5-large \\\n",
316
  " --data_dir CL_Benchmark \\\n",
317
  " --task_order yelp,amazon,mnli,cb,copa,qqp,rte,imdb,sst2,dbpedia,agnews,yahoo,multirc,boolq,wic \\\n",
 
325
  " --evaluation_strategy steps --save_strategy steps --save_total_limit 1 --load_best_model_at_end \\\n",
326
  " --lora_r 8 --lora_alpha 32 --lora_dropout 0.0 --add_instruction_replay --data_replay_freq -1 \\\n",
327
  " --replay_after_n_epoch 0 --mlp_hidden_dim 100 --model_name gainlora_inflora \\\n",
328
+ " --threshold 0.995 --transthreshold 0.995 --max_steps 3 2>&1 | tee /tmp/train_log.txt | tail -30"
 
 
 
329
  ]
330
  }
331
  ],
root_gainlora/src/cl_trainer_gainlora_inflora.py CHANGED
@@ -185,7 +185,7 @@ class GainLoRA_InfLoRA_Trainer(Seq2SeqTrainer):
185
  U, S, V = torch.linalg.svd(cur_trans_matrix)
186
  except RuntimeError:
187
  # SVD failed due to ill-conditioning; use pseudoinverse fallback
188
- p_inv = torch.pinv(cur_trans_matrix)
189
  U, S, V = torch.linalg.svd(p_inv + 1e-4 * torch.eye(p_inv.shape[0], device=p_inv.device, dtype=p_inv.dtype))
190
  module.prompt_key.data[:,index*module.step:(index+1)*module.step].copy_(U[:,:1].T)
191
  # ipdb.set_trace()
 
185
  U, S, V = torch.linalg.svd(cur_trans_matrix)
186
  except RuntimeError:
187
  # SVD failed due to ill-conditioning; use pseudoinverse fallback
188
+ p_inv = torch.linalg.pinv(cur_trans_matrix)
189
  U, S, V = torch.linalg.svd(p_inv + 1e-4 * torch.eye(p_inv.shape[0], device=p_inv.device, dtype=p_inv.dtype))
190
  module.prompt_key.data[:,index*module.step:(index+1)*module.step].copy_(U[:,:1].T)
191
  # ipdb.set_trace()