stanfordnlp / pyvene

Stanford NLP Python Library for Understanding and Improving PyTorch Models via Interventions
http://pyvene.ai
Apache License 2.0
559 stars 50 forks source link

[Minor] Adding retry to gradient test cases to avoid failure #104

Closed frankaging closed 5 months ago

frankaging commented 5 months ago

Description

Currently, the gradient test cases may fail intermittently due to torch equal tolerance issue. Adding retries to avoid this to keep main branch stable.

Merging unit test cases into a single file for utils.

Testing Done

./juice/scr/wuzhengx/pyvene/pyvene/models/interventions.py:421: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  mask_sigmoid = torch.sigmoid(self.mask / torch.tensor(self.temperature))
.........Removing testing dir ./test_output_dir_prefix-0037c3
Removing testing dir ./test_output_dir_prefix-ddd423
Removing testing dir ./test_output_dir_prefix-ffb32e
Removing testing dir ./test_output_dir_prefix-045942
Removing testing dir ./test_output_dir_prefix-a95c17

----------------------------------------------------------------------
Ran 18 tests in 5.667s

OK

Checklist:

aryamanarora commented 5 months ago

@frankaging why not use torch.isclose()?

frankaging commented 5 months ago

@ZhengPeterWang Adding peter for further refactory