fix: sanitize NaN/Inf values before SVD computation
Browse files
root_gainlora/src/cl_trainer_gainlora_inflora.py
CHANGED
|
@@ -195,6 +195,8 @@ class GainLoRA_InfLoRA_Trainer(Seq2SeqTrainer):
|
|
| 195 |
pre_norm = module.prompt_key.detach().norm()
|
| 196 |
for index in module.matrix_trans_3.keys():
|
| 197 |
cur_trans_matrix = module.matrix_trans_3[index]
|
|
|
|
|
|
|
| 198 |
try:
|
| 199 |
U, S, V = torch.linalg.svd(cur_trans_matrix)
|
| 200 |
except Exception:
|
|
|
|
| 195 |
pre_norm = module.prompt_key.detach().norm()
|
| 196 |
for index in module.matrix_trans_3.keys():
|
| 197 |
cur_trans_matrix = module.matrix_trans_3[index]
|
| 198 |
+
# Sanitize non-finite values before SVD
|
| 199 |
+
cur_trans_matrix = torch.nan_to_num(cur_trans_matrix, nan=0.0, posinf=1e6, neginf=-1e6)
|
| 200 |
try:
|
| 201 |
U, S, V = torch.linalg.svd(cur_trans_matrix)
|
| 202 |
except Exception:
|